diff options
| author | Jonas Hahnfeld <hahnjo@hahnjo.de> | 2017-11-22 17:15:20 +0000 |
|---|---|---|
| committer | Jonas Hahnfeld <hahnjo@hahnjo.de> | 2017-11-22 17:15:20 +0000 |
| commit | 221e7bb1fc5643cfb9225fc3be395fe3b7e82177 (patch) | |
| tree | 97d0a972d573ef763095258001968c8386f8779d /openmp/runtime/src/kmp_csupport.cpp | |
| parent | 318dd729ccdac49d2bf1e67099656e6fae3a9246 (diff) | |
| download | bcm5719-llvm-221e7bb1fc5643cfb9225fc3be395fe3b7e82177.tar.gz bcm5719-llvm-221e7bb1fc5643cfb9225fc3be395fe3b7e82177.zip | |
Fix for OMP doacross implementation on Power
Power has a weak consistency model so we need memory barriers to
make writes (both from runtime and from user code) available for
all threads.
Differential Revision: https://reviews.llvm.org/D40175
llvm-svn: 318848
Diffstat (limited to 'openmp/runtime/src/kmp_csupport.cpp')
| -rw-r--r-- | openmp/runtime/src/kmp_csupport.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/openmp/runtime/src/kmp_csupport.cpp b/openmp/runtime/src/kmp_csupport.cpp index e6faedf5715..c843dbe59e0 100644 --- a/openmp/runtime/src/kmp_csupport.cpp +++ b/openmp/runtime/src/kmp_csupport.cpp @@ -3815,7 +3815,9 @@ void __kmpc_doacross_init(ident_t *loc, int gtid, int num_dims, if (flags == NULL) { // we are the first thread, allocate the array of flags size_t size = trace_count / 8 + 8; // in bytes, use single bit per iteration - sh_buf->doacross_flags = (kmp_uint32 *)__kmp_thread_calloc(th, size, 1); + flags = (kmp_uint32 *)__kmp_thread_calloc(th, size, 1); + KMP_MB(); + sh_buf->doacross_flags = flags; } else if (flags == (kmp_uint32 *)1) { #if KMP_32_BIT_ARCH // initialization is still in progress, need to wait @@ -3824,6 +3826,9 @@ void __kmpc_doacross_init(ident_t *loc, int gtid, int num_dims, while (*(volatile kmp_int64 *)&sh_buf->doacross_flags == 1LL) #endif KMP_YIELD(TRUE); + KMP_MB(); + } else { + KMP_MB(); } KMP_DEBUG_ASSERT(sh_buf->doacross_flags > (kmp_uint32 *)1); // check ptr value pr_buf->th_doacross_flags = @@ -3919,6 +3924,7 @@ void __kmpc_doacross_wait(ident_t *loc, int gtid, long long *vec) { while ((flag & pr_buf->th_doacross_flags[iter_number]) == 0) { KMP_YIELD(TRUE); } + KMP_MB(); KA_TRACE(20, ("__kmpc_doacross_wait() exit: T#%d wait for iter %lld completed\n", gtid, (iter_number << 5) + shft)); @@ -3971,6 +3977,7 @@ void __kmpc_doacross_post(ident_t *loc, int gtid, long long *vec) { shft = iter_number % 32; // use 32-bit granularity iter_number >>= 5; // divided by 32 flag = 1 << shft; + KMP_MB(); if ((flag & pr_buf->th_doacross_flags[iter_number]) == 0) KMP_TEST_THEN_OR32(&pr_buf->th_doacross_flags[iter_number], flag); KA_TRACE(20, ("__kmpc_doacross_post() exit: T#%d iter %lld posted\n", gtid, |

