Skip to content

Commit 33a4a18

Browse files
authored
Merge pull request #285 from bonachea/co_reduce_cdata
issue #284: Fix prif_co_reduce cdata passing
2 parents b14eb15 + d2999c5 commit 33a4a18

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/caffeine/caffeine.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,11 @@ void caf_co_reduce(
416416

417417
if (result_image) {
418418
ev = gex_Coll_ReduceToOneNB(
419-
team, result_image-1, a_address, a_address, GEX_DT_USER, c_sizeof_a, num_elements, GEX_OP_USER, user_op, &c_sizeof_a, 0
419+
team, result_image-1, a_address, a_address, GEX_DT_USER, c_sizeof_a, num_elements, GEX_OP_USER, user_op, client_data, 0
420420
);
421421
} else {
422422
ev = gex_Coll_ReduceToAllNB(
423-
team, a_address, a_address, GEX_DT_USER, c_sizeof_a, num_elements, GEX_OP_USER, user_op, &c_sizeof_a, 0
423+
team, a_address, a_address, GEX_DT_USER, c_sizeof_a, num_elements, GEX_OP_USER, user_op, client_data, 0
424424
);
425425
}
426426
gex_Event_Wait(ev);

test/prif_co_reduce_test.F90

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#include "test-utils.F90"
2+
#include "julienne-assert-macros.h"
23

34
module prif_co_reduce_test_m
4-
use iso_c_binding, only: c_ptr, c_funptr, c_size_t, c_f_pointer, c_f_procpointer, c_funloc, c_loc, c_null_ptr
5+
use iso_c_binding, only: c_ptr, c_funptr, c_size_t, c_f_pointer, c_f_procpointer, c_funloc, c_loc, c_null_ptr, c_associated
56
use prif, only : prif_co_reduce, prif_num_images, prif_this_image_no_coarray, prif_operation_wrapper_interface
67
use julienne_m, only : &
7-
operator(.all.) &
8+
call_julienne_assert_ &
9+
,operator(.all.) &
810
,operator(.also.) &
911
,operator(.approximates.) &
1012
,operator(.equalsExpected.) &
@@ -44,6 +46,8 @@ module prif_co_reduce_test_m
4446
end type
4547
#endif
4648

49+
integer, target :: dummy
50+
4751
contains
4852

4953
pure function subject() result(test_subject)
@@ -93,6 +97,9 @@ subroutine and_wrapper(arg1, arg2_and_out, count, cdata) bind(C)
9397
integer(c_size_t) :: i
9498

9599
if (count == 0) return
100+
! this expression is buggy as of Julienne 3.6.0 (julienne#166)
101+
!call_julienne_assert(cdata .equalsExpected. c_null_ptr)
102+
call_julienne_assert(.not. c_associated(cdata))
96103
call c_f_pointer(arg1, lhs, [count])
97104
call c_f_pointer(arg2_and_out, rhs_and_result, [count])
98105
do i = 1, count
@@ -120,7 +127,7 @@ function check_derived_type_reduction() result(diag)
120127
call prif_num_images(ni)
121128

122129
my_val = values(:, mod(me-1, size(values,2))+1)
123-
call prif_co_reduce(my_val, op, c_null_ptr)
130+
call prif_co_reduce(my_val, op, c_loc(dummy))
124131

125132
allocate(tmp(size(values,1),ni))
126133
tmp = reshape([(values(:, mod(i-1,size(values,2))+1), i = 1, ni)], [size(values,1),ni])
@@ -159,6 +166,7 @@ subroutine pair_adder(arg1, arg2_and_out, count, cdata) bind(C)
159166
integer(c_size_t) :: i
160167

161168
if (count == 0) return
169+
call_julienne_assert(cdata .equalsExpected. c_loc(dummy))
162170
call c_f_pointer(arg1, lhs, [count])
163171
call c_f_pointer(arg2_and_out, rhs_and_result, [count])
164172
do i = 1, count

0 commit comments

Comments
 (0)