[Openmp-commits] [PATCH] D40722: Add missing memory barrier for queuing locks

Jonas Hahnfeld via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Dec 1 06:35:54 PST 2017


Hahnfeld created this revision.
Herald added a subscriber: openmp-commits.

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`.


Repository:
  rOMP OpenMP

https://reviews.llvm.org/D40722

Files:
  runtime/src/kmp_lock.cpp
  runtime/test/worksharing/single/omp_single_copyprivate.c


Index: runtime/test/worksharing/single/omp_single_copyprivate.c
===================================================================
--- runtime/test/worksharing/single/omp_single_copyprivate.c
+++ runtime/test/worksharing/single/omp_single_copyprivate.c
@@ -13,7 +13,7 @@
 
   result = 0;
   nr_iterations = 0;
-  #pragma omp parallel
+  #pragma omp parallel num_threads(4)
   {
     int i;
     for (i = 0; i < LOOPCOUNT; i++)
Index: runtime/src/kmp_lock.cpp
===================================================================
--- runtime/src/kmp_lock.cpp
+++ runtime/src/kmp_lock.cpp
@@ -1456,6 +1456,7 @@
       }
       dequeued = FALSE;
     } else {
+      KMP_MB();
       tail = *tail_id_p;
       if (head == tail) { /* only one thread on the queue */
 #ifdef DEBUG_QUEUING_LOCKS


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40722.125128.patch
Type: text/x-patch
Size: 789 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20171201/bb0b49aa/attachment.bin>


More information about the Openmp-commits mailing list