From e90b09129aedef2015f151df1fb7bcfbb91343f9 Mon Sep 17 00:00:00 2001 From: Andre Vehreschild Date: Fri, 8 Oct 2021 13:57:11 +0200 Subject: [PATCH 1/2] Fix refing static arrays. - Do not manipulation the memptr but add to data_offset. --- src/mpi/mpi_caf.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/mpi/mpi_caf.c b/src/mpi/mpi_caf.c index 04ab2fa9..4461aa94 100644 --- a/src/mpi/mpi_caf.c +++ b/src/mpi/mpi_caf.c @@ -4673,8 +4673,8 @@ PREFIX(get_by_ref) (caf_token_t token, int image_index, size = 1; while (riter) { - dprint("caf_ref = %p, offset = %zd, remote_mem = %p, global_win(data, desc)) = (%d, %d)\n", - riter, data_offset, remote_memptr, access_data_through_global_win, + dprint("caf_ref = %p, type = %d, offset = %zd, remote_mem = %p, global_win(data, desc)) = (%d, %d)\n", + riter, riter->type, data_offset, remote_memptr, access_data_through_global_win, access_desc_through_global_win); switch (riter->type) { @@ -4996,7 +4996,7 @@ case kind: \ delta = riter->u.a.dim[i].v.nvec; #define KINDCASE(kind, type) \ case kind: \ - remote_memptr += \ + data_offset += \ ((type *)riter->u.a.dim[i].v.vector)[0] * riter->item_size; \ break @@ -5026,15 +5026,14 @@ case kind: \ riter->u.a.dim[i].s.stride, riter->u.a.dim[i].s.start, riter->u.a.dim[i].s.end); - remote_memptr += riter->u.a.dim[i].s.start - * riter->u.a.dim[i].s.stride - * riter->item_size; + data_offset += riter->u.a.dim[i].s.start + * riter->u.a.dim[i].s.stride + * riter->item_size; break; case CAF_ARR_REF_SINGLE: delta = 1; - remote_memptr += riter->u.a.dim[i].s.start - * riter->u.a.dim[i].s.stride - * riter->item_size; + data_offset += riter->u.a.dim[i].s.start + * riter->item_size; break; case CAF_ARR_REF_OPEN_END: /* This and OPEN_START are mapped to a RANGE and therefore can From a92ba10a9deb3772e995481f8caa7b552691d6cf Mon Sep 17 00:00:00 2001 From: Andre Vehreschild Date: Fri, 8 Oct 2021 14:40:39 +0200 Subject: [PATCH 2/2] Add testcase for static array access. --- CMakeLists.txt | 1 + src/tests/unit/send-get/CMakeLists.txt | 1 + src/tests/unit/send-get/get_static_array.f90 | 23 ++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 src/tests/unit/send-get/get_static_array.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b4f6c87..7e11a420 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -795,6 +795,7 @@ if(opencoarrays_aware_compiler) add_caf_test(get_with_offset_1d 2 get_with_offset_1d) add_caf_test(whole_get_array 2 whole_get_array) add_caf_test(strided_get 2 strided_get) + add_caf_test(get_static_array 2 get_static_array) # Pure send tests add_caf_test(send_array 2 send_array) diff --git a/src/tests/unit/send-get/CMakeLists.txt b/src/tests/unit/send-get/CMakeLists.txt index 8de3ab27..7dff2b4d 100644 --- a/src/tests/unit/send-get/CMakeLists.txt +++ b/src/tests/unit/send-get/CMakeLists.txt @@ -13,6 +13,7 @@ caf_compile_executable(strided_get strided_get.f90) caf_compile_executable(get_with_vector_index get_with_vector_index.f90) ## Inquiry functions (these are gets that could be optimized in the future to communicate only the descriptors) caf_compile_executable(alloc_comp_multidim_shape alloc_comp_multidim_shape.F90) +caf_compile_executable(get_static_array get_static_array.f90) ## Pure send() tests caf_compile_executable(send_array send_array_test.f90) diff --git a/src/tests/unit/send-get/get_static_array.f90 b/src/tests/unit/send-get/get_static_array.f90 new file mode 100644 index 00000000..5721b3d0 --- /dev/null +++ b/src/tests/unit/send-get/get_static_array.f90 @@ -0,0 +1,23 @@ +program get_static_array + type :: container + integer, allocatable :: stuff(:) + end type + + type(container) :: co_containers(10)[*] + + if (this_image() == 1) then + allocate(co_containers(2)%stuff(4)) + co_containers(2)%stuff = [1,2,3,4] + end if + + sync all + + if (this_image() == 2) then + if (any(co_containers(2)[1]%stuff /= [1,2,3,4])) then + error stop "Test failed." + else + print *, "Test passed." + end if + end if +end program +