Add missing memory barrier for queuing locks
authorJonas Hahnfeld <hahnjo@hahnjo.de>
Fri, 8 Dec 2017 15:07:02 +0000 (15:07 +0000)
committerJonas Hahnfeld <hahnjo@hahnjo.de>
Fri, 8 Dec 2017 15:07:02 +0000 (15:07 +0000)
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

llvm-svn: 320150

openmp/runtime/src/kmp_lock.cpp
openmp/runtime/test/worksharing/single/omp_single_copyprivate.c

index 9c7dcaff74a40fba4c6948dbccc17f34fa6b2e58..fb9edb1727aa5b1355499d88543ed804fa737fe1 100644 (file)
@@ -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
index ef5cd9550633de21243e4828f08262f4ba81099b..2fece5c100a8caf7ec4217931a9cd8539dd44504 100644 (file)
@@ -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++)