From 1400715c0591646c9e05b163cf3db97e45ea47dc Mon Sep 17 00:00:00 2001 From: Lisandro Dalcin Date: Sun, 30 Jul 2023 15:25:19 +0300 Subject: [PATCH] fix: Protect local memory stores with shmem_barrier_all() --- src/libshmem/fallback.h | 4 ++-- src/libshmem/memalloc.h | 2 +- src/shmem4py/shmem.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libshmem/fallback.h b/src/libshmem/fallback.h index ae0b757..808fd74 100644 --- a/src/libshmem/fallback.h +++ b/src/libshmem/fallback.h @@ -311,7 +311,7 @@ static inline long *_py_shmem_pSync() _py_shmem_pSync_array = (long *) shmem_malloc(SHMEM_SYNC_SIZE * sizeof(long)); for (int i = 0; i < SHMEM_SYNC_SIZE; i++) _py_shmem_pSync_array[i] = SHMEM_SYNC_VALUE; - shmem_sync_all(); + shmem_barrier_all(); } return _py_shmem_pSync_array; } @@ -328,7 +328,7 @@ static inline void *_py_shmem_pWrk(size_t nreduce, size_t eltsize) shmem_free(_py_shmem_pWrk_array); _py_shmem_pWrk_size = wrk_size; _py_shmem_pWrk_array = shmem_malloc(wrk_size); - shmem_sync_all(); + shmem_barrier_all(); } return _py_shmem_pWrk_array; } diff --git a/src/libshmem/memalloc.h b/src/libshmem/memalloc.h index a799cb7..d9a9af6 100644 --- a/src/libshmem/memalloc.h +++ b/src/libshmem/memalloc.h @@ -13,7 +13,7 @@ static void *shmem_py_alloc(size_t size, size_t align, long hints, int clear) } if (clear) { memset(ptr, 0, size); - shmem_sync_all(); + shmem_barrier_all(); } return ptr; } diff --git a/src/shmem4py/shmem.py b/src/shmem4py/shmem.py index 53ed984..3d373b7 100644 --- a/src/shmem4py/shmem.py +++ b/src/shmem4py/shmem.py @@ -889,7 +889,7 @@ def array( if tmp.ndim > 1: a.strides = tmp.strides np.copyto(a, tmp, casting='no') - lib.shmem_sync_all() + lib.shmem_barrier_all() return a @@ -969,7 +969,7 @@ def ones( """ a = new_array(shape, dtype, order, align=align, hints=hints, clear=False) np.copyto(a, 1, casting='unsafe') - lib.shmem_sync_all() + lib.shmem_barrier_all() return a @@ -1001,7 +1001,7 @@ def full( dtype = np.array(fill_value).dtype a = new_array(shape, dtype, order, align=align, hints=hints, clear=False) np.copyto(a, fill_value, casting='unsafe') - lib.shmem_sync_all() + lib.shmem_barrier_all() return a