aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Hahnfeld <hahnjo@hahnjo.de>2017-12-08 15:07:02 +0000
committerJonas Hahnfeld <hahnjo@hahnjo.de>2017-12-08 15:07:02 +0000
commitc549ebcc764d60c3f187cbd10a7cb6112f841315 (patch)
tree2f41b704081cf4469df5ae870fde6610dbb6eca8
parent5a07983cf589c66eba013ea59d76ff828582eab7 (diff)
Add missing memory barrier for queuing locks
Otherwise I see hangs in the omp_single_copyprivate test when compiling in release mode. With the debug assertions, I get a failure `head > 0 && tail > 0`. Differential Revision: https://reviews.llvm.org/D40722 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@320150 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--runtime/src/kmp_lock.cpp1
-rw-r--r--runtime/test/worksharing/single/omp_single_copyprivate.c2
2 files changed, 2 insertions, 1 deletions
diff --git a/runtime/src/kmp_lock.cpp b/runtime/src/kmp_lock.cpp
index 9c7dcaf..fb9edb1 100644
--- a/runtime/src/kmp_lock.cpp
+++ b/runtime/src/kmp_lock.cpp
@@ -1456,6 +1456,7 @@ int __kmp_release_queuing_lock(kmp_queuing_lock_t *lck, kmp_int32 gtid) {
}
dequeued = FALSE;
} else {
+ KMP_MB();
tail = *tail_id_p;
if (head == tail) { /* only one thread on the queue */
#ifdef DEBUG_QUEUING_LOCKS
diff --git a/runtime/test/worksharing/single/omp_single_copyprivate.c b/runtime/test/worksharing/single/omp_single_copyprivate.c
index ef5cd95..2fece5c 100644
--- a/runtime/test/worksharing/single/omp_single_copyprivate.c
+++ b/runtime/test/worksharing/single/omp_single_copyprivate.c
@@ -13,7 +13,7 @@ int test_omp_single_copyprivate()
result = 0;
nr_iterations = 0;
- #pragma omp parallel
+ #pragma omp parallel num_threads(4)
{
int i;
for (i = 0; i < LOOPCOUNT; i++)