-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Meaningful support for raw array creation.
- Loading branch information
Showing
9 changed files
with
77 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
packages: futhark.cabal | ||
index-state: 2024-02-25T13:57:21Z | ||
index-state: 2024-03-04T18:26:54Z | ||
|
||
package futhark | ||
ghc-options: -j -fwrite-ide-info -hiedir=.hie |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
entry main (xs: []i32) = map (+2) xs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Fiddling around with the raw arrays API. | ||
|
||
#include "raw.h" | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <assert.h> | ||
|
||
int main() { | ||
struct futhark_context_config *cfg = futhark_context_config_new(); | ||
struct futhark_context *ctx = futhark_context_new(cfg); | ||
|
||
#ifdef FUTHARK_BACKEND_c | ||
|
||
int32_t data[3] = {1,2,3}; | ||
|
||
struct futhark_i32_1d *in = futhark_new_raw_i32_1d(ctx, (unsigned char*)&data, 3); | ||
assert(in != NULL); | ||
struct futhark_i32_1d *out; | ||
|
||
assert(futhark_entry_main(ctx, &out, in) == FUTHARK_SUCCESS); | ||
|
||
int32_t *out_ptr = (int32_t*)futhark_values_raw_i32_1d(ctx, out); | ||
|
||
assert(futhark_context_sync(ctx) == FUTHARK_SUCCESS); | ||
|
||
assert(out_ptr[0] == 3); | ||
assert(out_ptr[1] == 4); | ||
assert(out_ptr[2] == 5); | ||
|
||
futhark_free_i32_1d(ctx, in); | ||
futhark_free_i32_1d(ctx, out); | ||
|
||
#endif | ||
|
||
futhark_context_free(ctx); | ||
futhark_context_config_free(cfg); | ||
} |