[Openmp-commits] [openmp] r274053 - Fix bugs in TAS and futex lock

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Tue Jun 28 12:37:24 PDT 2016


Author: jlpeyton
Date: Tue Jun 28 14:37:24 2016
New Revision: 274053

URL: http://llvm.org/viewvc/llvm-project?rev=274053&view=rev
Log:
Fix bugs in TAS and futex lock

* Incorrect lock value written in __kmp_test_futex_lock
* Incorrect lock value check in tas/futex lock with USE_LOCK_PROFILE on

Patch by Hansang Bae

Modified:
    openmp/trunk/runtime/src/kmp_lock.cpp
    openmp/trunk/runtime/test/lock/omp_test_lock.c

Modified: openmp/trunk/runtime/src/kmp_lock.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_lock.cpp?rev=274053&r1=274052&r2=274053&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_lock.cpp (original)
+++ openmp/trunk/runtime/src/kmp_lock.cpp Tue Jun 28 14:37:24 2016
@@ -91,7 +91,7 @@ __kmp_acquire_tas_lock_timed_template( k
     KMP_MB();
 
 #ifdef USE_LOCK_PROFILE
-    kmp_uint32 curr = TCR_4( lck->lk.poll );
+    kmp_uint32 curr = KMP_LOCK_STRIP( TCR_4( lck->lk.poll ) );
     if ( ( curr != 0 ) && ( curr != gtid + 1 ) )
         __kmp_printf( "LOCK CONTENTION: %p\n", lck );
     /* else __kmp_printf( "." );*/
@@ -393,7 +393,7 @@ __kmp_acquire_futex_lock_timed_template(
     KMP_MB();
 
 #ifdef USE_LOCK_PROFILE
-    kmp_uint32 curr = TCR_4( lck->lk.poll );
+    kmp_uint32 curr = KMP_LOCK_STRIP( TCR_4( lck->lk.poll ) );
     if ( ( curr != 0 ) && ( curr != gtid_code ) )
         __kmp_printf( "LOCK CONTENTION: %p\n", lck );
     /* else __kmp_printf( "." );*/
@@ -487,7 +487,7 @@ __kmp_acquire_futex_lock_with_checks( km
 int
 __kmp_test_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid )
 {
-    if ( KMP_COMPARE_AND_STORE_ACQ32( & ( lck->lk.poll ), KMP_LOCK_FREE(futex), KMP_LOCK_BUSY(gtid+1, futex) << 1 ) ) {
+    if ( KMP_COMPARE_AND_STORE_ACQ32( & ( lck->lk.poll ), KMP_LOCK_FREE(futex), KMP_LOCK_BUSY((gtid+1) << 1, futex) ) ) {
         KMP_FSYNC_ACQUIRED( lck );
         return TRUE;
     }

Modified: openmp/trunk/runtime/test/lock/omp_test_lock.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/lock/omp_test_lock.c?rev=274053&r1=274052&r2=274053&view=diff
==============================================================================
--- openmp/trunk/runtime/test/lock/omp_test_lock.c (original)
+++ openmp/trunk/runtime/test/lock/omp_test_lock.c Tue Jun 28 14:37:24 2016
@@ -1,4 +1,6 @@
 // RUN: %libomp-compile-and-run
+// RUN: env KMP_LOCK_KIND=tas %libomp-run
+// RUN: env KMP_LOCK_KIND=futex %libomp-run
 #include <stdio.h>
 #include "omp_testsuite.h"
 




More information about the Openmp-commits mailing list