Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <tstellar@redhat.com>2017-11-27 20:29:37 +0300
committerTom Stellard <tstellar@redhat.com>2017-11-27 20:29:37 +0300
commitc510d367885d88781fc0e54624ef78cf1c600268 (patch)
tree70eed83eb15159d95ca1d2c5ab7f9bf85960ebb6
parent786065d5886b43cdb67b327b5e76f6ac2a56f796 (diff)
Merging r318658:
------------------------------------------------------------------------ r318658 | achurbanov | 2017-11-20 08:00:42 -0800 (Mon, 20 Nov 2017) | 4 lines Fixed OMP doacross implementation on 32-bit platforms. Differential Revision: https://reviews.llvm.org/D40171 ------------------------------------------------------------------------ llvm-svn: 319053
-rw-r--r--openmp/runtime/src/kmp_csupport.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/openmp/runtime/src/kmp_csupport.cpp b/openmp/runtime/src/kmp_csupport.cpp
index 8b7067d9c42d..1f61870f574e 100644
--- a/openmp/runtime/src/kmp_csupport.cpp
+++ b/openmp/runtime/src/kmp_csupport.cpp
@@ -3095,23 +3095,30 @@ void __kmpc_doacross_init(ident_t *loc, int gtid, int num_dims,
__kmp_wait_yield_4((volatile kmp_uint32 *)&sh_buf->doacross_buf_idx, idx,
__kmp_eq_4, NULL);
}
+#if KMP_32_BIT_ARCH
// Check if we are the first thread. After the CAS the first thread gets 0,
// others get 1 if initialization is in progress, allocated pointer otherwise.
+ // Treat pointer as volatile integer (value 0 or 1) until memory is allocated.
+ flags = (kmp_uint32 *)KMP_COMPARE_AND_STORE_RET32(
+ (volatile kmp_int32 *)&sh_buf->doacross_flags, NULL, 1);
+#else
flags = (kmp_uint32 *)KMP_COMPARE_AND_STORE_RET64(
- (kmp_int64 *)&sh_buf->doacross_flags, NULL, (kmp_int64)1);
+ (volatile kmp_int64 *)&sh_buf->doacross_flags, NULL, 1LL);
+#endif
if (flags == NULL) {
// we are the first thread, allocate the array of flags
- kmp_int64 size =
- trace_count / 8 + 8; // in bytes, use single bit per iteration
+ 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);
- } else if ((kmp_int64)flags == 1) {
+ } else if (flags == (kmp_uint32 *)1) {
+#if KMP_32_BIT_ARCH
// initialization is still in progress, need to wait
- while ((volatile kmp_int64)sh_buf->doacross_flags == 1) {
+ while (*(volatile kmp_int32 *)&sh_buf->doacross_flags == 1)
+#else
+ while (*(volatile kmp_int64 *)&sh_buf->doacross_flags == 1LL)
+#endif
KMP_YIELD(TRUE);
- }
}
- KMP_DEBUG_ASSERT((kmp_int64)sh_buf->doacross_flags >
- 1); // check value of pointer
+ KMP_DEBUG_ASSERT(sh_buf->doacross_flags > (kmp_uint32 *)1); // check ptr value
pr_buf->th_doacross_flags =
sh_buf->doacross_flags; // save private copy in order to not
// touch shared buffer on each iteration