Skip to content

Commit

Permalink
Merge branch 'master' into ci-mi100
Browse files Browse the repository at this point in the history
  • Loading branch information
athas committed Aug 15, 2024
2 parents 312ba0b + b745206 commit c24d70e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

* Interpreter no longer crashes on attributes in patterns.

* Fixes to array indexing through C API when using GPU backends.

## [0.25.19]

### Added
Expand Down
4 changes: 3 additions & 1 deletion docs/c-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ tuple is simply a record with numeric fields.
The projection and construction functions are equivalent in
functionality to writing entry points by hand, and so serve only to
cut down on boilerplate. Important things to be aware of:
cut down on boilerplate. Important things to be aware of:
1. The objects constructed though these functions have their own
lifetime (like any objects returned from an entry point) and must
Expand All @@ -405,6 +405,8 @@ cut down on boilerplate. Important things to be aware of:
always, you don't have to worry about this if you never write entry
points that consume their arguments.
3. You must synchronise before using any scalar results.
The precise functions generated depend on the fields of the record.
The following functions assume a record with Futhark-level type ``type
t = {foo: t1, bar: t2}`` where ``t1`` and ``t2`` are also opaque
Expand Down
4 changes: 2 additions & 2 deletions src/Futhark/CodeGen/Backends/GenericC/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ recordArrayIndexFunctions space _types desc rank elemtype vds = do
-- variable.
copy
CopyNoBarrier
[C.cexp|&v->$id:(tupleField j)|]
[C.cexp|(unsigned char*)&v->$id:(tupleField j)|]
[C.cexp|0|]
DefaultSpace
[C.cexp|arr->$id:(tupleField j)->mem.mem|]
Expand All @@ -571,7 +571,7 @@ recordArrayIndexFunctions space _types desc rank elemtype vds = do
CopyNoBarrier
[C.cexp|v->$id:(tupleField j)->mem.mem|]
[C.cexp|0|]
DefaultSpace
space
[C.cexp|arr->$id:(tupleField j)->mem.mem|]
(indexExp pt r [C.cexp|arr->$id:(tupleField j)->shape|])
space
Expand Down
1 change: 1 addition & 0 deletions tests_lib/c/test_opaque_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void test1(struct futhark_context *ctx) {

float out1_host[2];
assert(futhark_values_f32_1d(ctx, out1, out1_host) == 0);
assert(futhark_context_sync(ctx) == 0);
assert(memcmp(out1_host, b, sizeof(float)*2) == 0);

assert(futhark_free_opaque_7e1a81531cc3c23bb9093ed822aec320(ctx, out) == 0);
Expand Down
4 changes: 4 additions & 0 deletions tests_lib/c/test_record_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,25 @@ void test1(struct futhark_context *ctx) {
// Test indexing: in bounds.
struct futhark_opaque_tup2_i32_tup2_f32_f32* trip_fut;
assert(futhark_index_opaque_arr1d_tup2_i32_tup2_f32_f32(ctx, &trip_fut, a_b_b_fut, 1) == 0);
assert(futhark_context_sync(ctx) == 0); // XXX, would be nice if this was not required.
struct futhark_opaque_tup2_f32_f32* pair_fut;
assert(futhark_project_opaque_tup2_i32_tup2_f32_f32_1(ctx, &pair_fut, trip_fut) == 0);
{
int x;
assert(futhark_project_opaque_tup2_i32_tup2_f32_f32_0(ctx, &x, trip_fut) == 0);
assert(futhark_context_sync(ctx) == 0);
assert(x == a[1]);
}
{
float x;
assert(futhark_project_opaque_tup2_f32_f32_0(ctx, &x, pair_fut) == 0);
assert(futhark_context_sync(ctx) == 0);
assert(x == b[1]);
}
{
float x;
assert(futhark_project_opaque_tup2_f32_f32_1(ctx, &x, pair_fut) == 0);
assert(futhark_context_sync(ctx) == 0);
assert(x == b[1]);
}

Expand Down

0 comments on commit c24d70e

Please sign in to comment.