[Openmp-commits] [openmp] r250526 - [OMPT] Add OMPT events for API locking
Jonathan Peyton via Openmp-commits
openmp-commits at lists.llvm.org
Fri Oct 16 09:52:59 PDT 2015
Author: jlpeyton
Date: Fri Oct 16 11:52:58 2015
New Revision: 250526
URL: http://llvm.org/viewvc/llvm-project?rev=250526&view=rev
Log:
[OMPT] Add OMPT events for API locking
This fix implements the following OMPT events for the API locking routines:
* ompt_event_acquired_lock
* ompt_event_acquired_nest_lock_first
* ompt_event_acquired_nest_lock_next
* ompt_event_init_lock
* ompt_event_init_nest_lock
* ompt_event_destroy_lock
* ompt_event_destroy_nest_lock
For the acquired events the depths of the locks ist required, so a return value
was added similiar to the return values we already have for the release lock
routines.
Patch by Tim Cramer
Differential Revision: http://reviews.llvm.org/D13689
Modified:
openmp/trunk/runtime/src/kmp_csupport.c
openmp/trunk/runtime/src/kmp_lock.cpp
openmp/trunk/runtime/src/kmp_lock.h
openmp/trunk/runtime/src/ompt-event-specific.h
Modified: openmp/trunk/runtime/src/kmp_csupport.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_csupport.c?rev=250526&r1=250525&r2=250526&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_csupport.c (original)
+++ openmp/trunk/runtime/src/kmp_csupport.c Fri Oct 16 11:52:58 2015
@@ -1801,6 +1801,13 @@ __kmpc_init_lock( ident_t * loc, kmp_int
INIT_LOCK( lck );
__kmp_set_user_lock_location( lck, loc );
+#if OMPT_SUPPORT && OMPT_TRACE
+ if (ompt_enabled &&
+ ompt_callbacks.ompt_callback(ompt_event_init_lock)) {
+ ompt_callbacks.ompt_callback(ompt_event_init_lock)((uint64_t) lck);
+ }
+#endif
+
#if USE_ITT_BUILD
__kmp_itt_lock_creating( lck );
#endif /* USE_ITT_BUILD */
@@ -1870,6 +1877,13 @@ __kmpc_init_nest_lock( ident_t * loc, km
INIT_NESTED_LOCK( lck );
__kmp_set_user_lock_location( lck, loc );
+#if OMPT_SUPPORT && OMPT_TRACE
+ if (ompt_enabled &&
+ ompt_callbacks.ompt_callback(ompt_event_init_nest_lock)) {
+ ompt_callbacks.ompt_callback(ompt_event_init_nest_lock)((uint64_t) lck);
+ }
+#endif
+
#if USE_ITT_BUILD
__kmp_itt_lock_creating( lck );
#endif /* USE_ITT_BUILD */
@@ -1908,6 +1922,13 @@ __kmpc_destroy_lock( ident_t * loc, kmp_
lck = __kmp_lookup_user_lock( user_lock, "omp_destroy_lock" );
}
+#if OMPT_SUPPORT && OMPT_TRACE
+ if (ompt_enabled &&
+ ompt_callbacks.ompt_callback(ompt_event_destroy_lock)) {
+ ompt_callbacks.ompt_callback(ompt_event_destroy_lock)((uint64_t) lck);
+ }
+#endif
+
#if USE_ITT_BUILD
__kmp_itt_lock_destroyed( lck );
#endif /* USE_ITT_BUILD */
@@ -1959,6 +1980,13 @@ __kmpc_destroy_nest_lock( ident_t * loc,
lck = __kmp_lookup_user_lock( user_lock, "omp_destroy_nest_lock" );
}
+#if OMPT_SUPPORT && OMPT_TRACE
+ if (ompt_enabled &&
+ ompt_callbacks.ompt_callback(ompt_event_destroy_nest_lock)) {
+ ompt_callbacks.ompt_callback(ompt_event_destroy_nest_lock)((uint64_t) lck);
+ }
+#endif
+
#if USE_ITT_BUILD
__kmp_itt_lock_destroyed( lck );
#endif /* USE_ITT_BUILD */
@@ -2034,6 +2062,13 @@ __kmpc_set_lock( ident_t * loc, kmp_int3
__kmp_itt_lock_acquired( lck );
#endif /* USE_ITT_BUILD */
+#if OMPT_SUPPORT && OMPT_TRACE
+ if (ompt_enabled &&
+ ompt_callbacks.ompt_callback(ompt_event_acquired_lock)) {
+ ompt_callbacks.ompt_callback(ompt_event_acquired_lock)((uint64_t) lck);
+ }
+#endif
+
#endif // KMP_USE_DYNAMIC_LOCK
}
@@ -2050,6 +2085,7 @@ __kmpc_set_nest_lock( ident_t * loc, kmp
#endif
#else // KMP_USE_DYNAMIC_LOCK
+ int acquire_status;
kmp_user_lock_p lck;
if ( ( __kmp_user_lock_kind == lk_tas ) && ( sizeof( lck->tas.lk.poll )
@@ -2071,12 +2107,24 @@ __kmpc_set_nest_lock( ident_t * loc, kmp
__kmp_itt_lock_acquiring( lck );
#endif /* USE_ITT_BUILD */
- ACQUIRE_NESTED_LOCK( lck, gtid );
+ ACQUIRE_NESTED_LOCK( lck, gtid, &acquire_status );
#if USE_ITT_BUILD
__kmp_itt_lock_acquired( lck );
#endif /* USE_ITT_BUILD */
#endif // KMP_USE_DYNAMIC_LOCK
+
+#if OMPT_SUPPORT && OMPT_TRACE
+ if (ompt_enabled) {
+ if (acquire_status == KMP_LOCK_ACQUIRED_FIRST) {
+ if(ompt_callbacks.ompt_callback(ompt_event_acquired_nest_lock_first))
+ ompt_callbacks.ompt_callback(ompt_event_acquired_nest_lock_first)((uint64_t) lck);
+ } else {
+ if(ompt_callbacks.ompt_callback(ompt_event_acquired_nest_lock_next))
+ ompt_callbacks.ompt_callback(ompt_event_acquired_nest_lock_next)((uint64_t) lck);
+ }
+ }
+#endif
}
void
Modified: openmp/trunk/runtime/src/kmp_lock.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_lock.cpp?rev=250526&r1=250525&r2=250526&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_lock.cpp (original)
+++ openmp/trunk/runtime/src/kmp_lock.cpp Fri Oct 16 11:52:58 2015
@@ -84,7 +84,7 @@ __kmp_is_tas_lock_nestable( kmp_tas_lock
return lck->lk.depth_locked != -1;
}
-__forceinline static void
+__forceinline static int
__kmp_acquire_tas_lock_timed_template( kmp_tas_lock_t *lck, kmp_int32 gtid )
{
KMP_MB();
@@ -99,7 +99,7 @@ __kmp_acquire_tas_lock_timed_template( k
if ( ( lck->lk.poll == DYNA_LOCK_FREE(tas) )
&& KMP_COMPARE_AND_STORE_ACQ32( & ( lck->lk.poll ), DYNA_LOCK_FREE(tas), DYNA_LOCK_BUSY(gtid+1, tas) ) ) {
KMP_FSYNC_ACQUIRED(lck);
- return;
+ return KMP_LOCK_ACQUIRED_FIRST;
}
kmp_uint32 spins;
@@ -127,15 +127,16 @@ __kmp_acquire_tas_lock_timed_template( k
}
}
KMP_FSYNC_ACQUIRED( lck );
+ return KMP_LOCK_ACQUIRED_FIRST;
}
-void
+int
__kmp_acquire_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid )
{
- __kmp_acquire_tas_lock_timed_template( lck, gtid );
+ return __kmp_acquire_tas_lock_timed_template( lck, gtid );
}
-static void
+static int
__kmp_acquire_tas_lock_with_checks( kmp_tas_lock_t *lck, kmp_int32 gtid )
{
char const * const func = "omp_set_lock";
@@ -146,7 +147,7 @@ __kmp_acquire_tas_lock_with_checks( kmp_
if ( ( gtid >= 0 ) && ( __kmp_get_tas_lock_owner( lck ) == gtid ) ) {
KMP_FATAL( LockIsAlreadyOwned, func );
}
- __kmp_acquire_tas_lock( lck, gtid );
+ return __kmp_acquire_tas_lock( lck, gtid );
}
int
@@ -241,28 +242,30 @@ __kmp_destroy_tas_lock_with_checks( kmp_
// nested test and set locks
//
-void
+int
__kmp_acquire_nested_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid )
{
KMP_DEBUG_ASSERT( gtid >= 0 );
if ( __kmp_get_tas_lock_owner( lck ) == gtid ) {
lck->lk.depth_locked += 1;
+ return KMP_LOCK_ACQUIRED_NEXT;
}
else {
__kmp_acquire_tas_lock_timed_template( lck, gtid );
lck->lk.depth_locked = 1;
+ return KMP_LOCK_ACQUIRED_FIRST;
}
}
-static void
+static int
__kmp_acquire_nested_tas_lock_with_checks( kmp_tas_lock_t *lck, kmp_int32 gtid )
{
char const * const func = "omp_set_nest_lock";
if ( ! __kmp_is_tas_lock_nestable( lck ) ) {
KMP_FATAL( LockSimpleUsedAsNestable, func );
}
- __kmp_acquire_nested_tas_lock( lck, gtid );
+ return __kmp_acquire_nested_tas_lock( lck, gtid );
}
int
@@ -381,7 +384,7 @@ __kmp_is_futex_lock_nestable( kmp_futex_
return lck->lk.depth_locked != -1;
}
-__forceinline static void
+__forceinline static int
__kmp_acquire_futex_lock_timed_template( kmp_futex_lock_t *lck, kmp_int32 gtid )
{
kmp_int32 gtid_code = ( gtid + 1 ) << 1;
@@ -457,15 +460,16 @@ __kmp_acquire_futex_lock_timed_template(
KMP_FSYNC_ACQUIRED( lck );
KA_TRACE( 1000, ("__kmp_acquire_futex_lock: lck:%p(0x%x), T#%d exiting\n",
lck, lck->lk.poll, gtid ) );
+ return KMP_LOCK_ACQUIRED_FIRST;
}
-void
+int
__kmp_acquire_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid )
{
- __kmp_acquire_futex_lock_timed_template( lck, gtid );
+ return __kmp_acquire_futex_lock_timed_template( lck, gtid );
}
-static void
+static int
__kmp_acquire_futex_lock_with_checks( kmp_futex_lock_t *lck, kmp_int32 gtid )
{
char const * const func = "omp_set_lock";
@@ -476,7 +480,7 @@ __kmp_acquire_futex_lock_with_checks( km
if ( ( gtid >= 0 ) && ( __kmp_get_futex_lock_owner( lck ) == gtid ) ) {
KMP_FATAL( LockIsAlreadyOwned, func );
}
- __kmp_acquire_futex_lock( lck, gtid );
+ return __kmp_acquire_futex_lock( lck, gtid );
}
int
@@ -587,28 +591,30 @@ __kmp_destroy_futex_lock_with_checks( km
// nested futex locks
//
-void
+int
__kmp_acquire_nested_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid )
{
KMP_DEBUG_ASSERT( gtid >= 0 );
if ( __kmp_get_futex_lock_owner( lck ) == gtid ) {
lck->lk.depth_locked += 1;
+ return KMP_LOCK_ACQUIRED_NEXT;
}
else {
__kmp_acquire_futex_lock_timed_template( lck, gtid );
lck->lk.depth_locked = 1;
+ return KMP_LOCK_ACQUIRED_FIRST;
}
}
-static void
+static int
__kmp_acquire_nested_futex_lock_with_checks( kmp_futex_lock_t *lck, kmp_int32 gtid )
{
char const * const func = "omp_set_nest_lock";
if ( ! __kmp_is_futex_lock_nestable( lck ) ) {
KMP_FATAL( LockSimpleUsedAsNestable, func );
}
- __kmp_acquire_nested_futex_lock( lck, gtid );
+ return __kmp_acquire_nested_futex_lock( lck, gtid );
}
int
@@ -734,7 +740,7 @@ __kmp_bakery_check(kmp_uint value, kmp_u
return FALSE;
}
-__forceinline static void
+__forceinline static int
__kmp_acquire_ticket_lock_timed_template( kmp_ticket_lock_t *lck, kmp_int32 gtid )
{
kmp_uint32 my_ticket;
@@ -750,19 +756,20 @@ __kmp_acquire_ticket_lock_timed_template
if ( TCR_4( lck->lk.now_serving ) == my_ticket ) {
KMP_FSYNC_ACQUIRED(lck);
- return;
+ return KMP_LOCK_ACQUIRED_FIRST;
}
KMP_WAIT_YIELD( &lck->lk.now_serving, my_ticket, __kmp_bakery_check, lck );
KMP_FSYNC_ACQUIRED(lck);
+ return KMP_LOCK_ACQUIRED_FIRST;
}
-void
+int
__kmp_acquire_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid )
{
- __kmp_acquire_ticket_lock_timed_template( lck, gtid );
+ return __kmp_acquire_ticket_lock_timed_template( lck, gtid );
}
-static void
+static int
__kmp_acquire_ticket_lock_with_checks( kmp_ticket_lock_t *lck, kmp_int32 gtid )
{
char const * const func = "omp_set_lock";
@@ -779,6 +786,7 @@ __kmp_acquire_ticket_lock_with_checks( k
__kmp_acquire_ticket_lock( lck, gtid );
lck->lk.owner_id = gtid + 1;
+ return KMP_LOCK_ACQUIRED_FIRST;
}
int
@@ -905,13 +913,14 @@ __kmp_destroy_ticket_lock_with_checks( k
// nested ticket locks
//
-void
+int
__kmp_acquire_nested_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid )
{
KMP_DEBUG_ASSERT( gtid >= 0 );
if ( __kmp_get_ticket_lock_owner( lck ) == gtid ) {
lck->lk.depth_locked += 1;
+ return KMP_LOCK_ACQUIRED_NEXT;
}
else {
__kmp_acquire_ticket_lock_timed_template( lck, gtid );
@@ -919,10 +928,11 @@ __kmp_acquire_nested_ticket_lock( kmp_ti
lck->lk.depth_locked = 1;
KMP_MB();
lck->lk.owner_id = gtid + 1;
+ return KMP_LOCK_ACQUIRED_FIRST;
}
}
-static void
+static int
__kmp_acquire_nested_ticket_lock_with_checks( kmp_ticket_lock_t *lck, kmp_int32 gtid )
{
char const * const func = "omp_set_nest_lock";
@@ -932,7 +942,7 @@ __kmp_acquire_nested_ticket_lock_with_ch
if ( ! __kmp_is_ticket_lock_nestable( lck ) ) {
KMP_FATAL( LockSimpleUsedAsNestable, func );
}
- __kmp_acquire_nested_ticket_lock( lck, gtid );
+ return __kmp_acquire_nested_ticket_lock( lck, gtid );
}
int
@@ -1196,7 +1206,7 @@ __kmp_is_queuing_lock_nestable( kmp_queu
template <bool takeTime>
/* [TLW] The unused template above is left behind because of what BEB believes is a
potential compiler problem with __forceinline. */
-__forceinline static void
+__forceinline static int
__kmp_acquire_queuing_lock_timed_template( kmp_queuing_lock_t *lck,
kmp_int32 gtid )
{
@@ -1323,7 +1333,7 @@ __kmp_acquire_queuing_lock_timed_templat
#endif
KMP_FSYNC_ACQUIRED( lck );
- return; /* lock holder cannot be on queue */
+ return KMP_LOCK_ACQUIRED_FIRST; /* lock holder cannot be on queue */
}
enqueued = FALSE;
}
@@ -1376,7 +1386,7 @@ __kmp_acquire_queuing_lock_timed_templat
#endif
/* got lock, we were dequeued by the thread that released lock */
- return;
+ return KMP_LOCK_ACQUIRED_FIRST;
}
/* Yield if number of threads > number of logical processors */
@@ -1390,17 +1400,18 @@ __kmp_acquire_queuing_lock_timed_templat
}
KMP_ASSERT2( 0, "should not get here" );
+ return KMP_LOCK_ACQUIRED_FIRST;
}
-void
+int
__kmp_acquire_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid )
{
KMP_DEBUG_ASSERT( gtid >= 0 );
- __kmp_acquire_queuing_lock_timed_template<false>( lck, gtid );
+ return __kmp_acquire_queuing_lock_timed_template<false>( lck, gtid );
}
-static void
+static int
__kmp_acquire_queuing_lock_with_checks( kmp_queuing_lock_t *lck,
kmp_int32 gtid )
{
@@ -1418,6 +1429,7 @@ __kmp_acquire_queuing_lock_with_checks(
__kmp_acquire_queuing_lock( lck, gtid );
lck->lk.owner_id = gtid + 1;
+ return KMP_LOCK_ACQUIRED_FIRST;
}
int
@@ -1689,13 +1701,14 @@ __kmp_destroy_queuing_lock_with_checks(
// nested queuing locks
//
-void
+int
__kmp_acquire_nested_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid )
{
KMP_DEBUG_ASSERT( gtid >= 0 );
if ( __kmp_get_queuing_lock_owner( lck ) == gtid ) {
lck->lk.depth_locked += 1;
+ return KMP_LOCK_ACQUIRED_NEXT;
}
else {
__kmp_acquire_queuing_lock_timed_template<false>( lck, gtid );
@@ -1703,10 +1716,11 @@ __kmp_acquire_nested_queuing_lock( kmp_q
lck->lk.depth_locked = 1;
KMP_MB();
lck->lk.owner_id = gtid + 1;
+ return KMP_LOCK_ACQUIRED_FIRST;
}
}
-static void
+static int
__kmp_acquire_nested_queuing_lock_with_checks( kmp_queuing_lock_t *lck, kmp_int32 gtid )
{
char const * const func = "omp_set_nest_lock";
@@ -1716,7 +1730,7 @@ __kmp_acquire_nested_queuing_lock_with_c
if ( ! __kmp_is_queuing_lock_nestable( lck ) ) {
KMP_FATAL( LockSimpleUsedAsNestable, func );
}
- __kmp_acquire_nested_queuing_lock( lck, gtid );
+ return __kmp_acquire_nested_queuing_lock( lck, gtid );
}
int
@@ -2458,7 +2472,7 @@ __kmp_is_drdpa_lock_nestable( kmp_drdpa_
return lck->lk.depth_locked != -1;
}
-__forceinline static void
+__forceinline static int
__kmp_acquire_drdpa_lock_timed_template( kmp_drdpa_lock_t *lck, kmp_int32 gtid )
{
kmp_uint64 ticket = KMP_TEST_THEN_INC64((kmp_int64 *)&lck->lk.next_ticket);
@@ -2621,15 +2635,16 @@ __kmp_acquire_drdpa_lock_timed_template(
lck->lk.cleanup_ticket = TCR_8(lck->lk.next_ticket);
}
}
+ return KMP_LOCK_ACQUIRED_FIRST;
}
-void
+int
__kmp_acquire_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid )
{
- __kmp_acquire_drdpa_lock_timed_template( lck, gtid );
+ return __kmp_acquire_drdpa_lock_timed_template( lck, gtid );
}
-static void
+static int
__kmp_acquire_drdpa_lock_with_checks( kmp_drdpa_lock_t *lck, kmp_int32 gtid )
{
char const * const func = "omp_set_lock";
@@ -2646,6 +2661,7 @@ __kmp_acquire_drdpa_lock_with_checks( km
__kmp_acquire_drdpa_lock( lck, gtid );
lck->lk.owner_id = gtid + 1;
+ return KMP_LOCK_ACQUIRED_FIRST;
}
int
@@ -2813,13 +2829,14 @@ __kmp_destroy_drdpa_lock_with_checks( km
// nested drdpa ticket locks
//
-void
+int
__kmp_acquire_nested_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid )
{
KMP_DEBUG_ASSERT( gtid >= 0 );
if ( __kmp_get_drdpa_lock_owner( lck ) == gtid ) {
lck->lk.depth_locked += 1;
+ return KMP_LOCK_ACQUIRED_NEXT;
}
else {
__kmp_acquire_drdpa_lock_timed_template( lck, gtid );
@@ -2827,6 +2844,7 @@ __kmp_acquire_nested_drdpa_lock( kmp_drd
lck->lk.depth_locked = 1;
KMP_MB();
lck->lk.owner_id = gtid + 1;
+ return KMP_LOCK_ACQUIRED_FIRST;
}
}
@@ -3567,14 +3585,14 @@ size_t __kmp_base_user_lock_size = 0;
size_t __kmp_user_lock_size = 0;
kmp_int32 ( *__kmp_get_user_lock_owner_ )( kmp_user_lock_p lck ) = NULL;
-void ( *__kmp_acquire_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid ) = NULL;
+int ( *__kmp_acquire_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid ) = NULL;
int ( *__kmp_test_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid ) = NULL;
int ( *__kmp_release_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid ) = NULL;
void ( *__kmp_init_user_lock_with_checks_ )( kmp_user_lock_p lck ) = NULL;
void ( *__kmp_destroy_user_lock_ )( kmp_user_lock_p lck ) = NULL;
void ( *__kmp_destroy_user_lock_with_checks_ )( kmp_user_lock_p lck ) = NULL;
-void ( *__kmp_acquire_nested_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid ) = NULL;
+int ( *__kmp_acquire_nested_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid ) = NULL;
int ( *__kmp_test_nested_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid ) = NULL;
int ( *__kmp_release_nested_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid ) = NULL;
Modified: openmp/trunk/runtime/src/kmp_lock.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_lock.h?rev=250526&r1=250525&r2=250526&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_lock.h (original)
+++ openmp/trunk/runtime/src/kmp_lock.h Fri Oct 16 11:52:58 2015
@@ -159,13 +159,13 @@ typedef union kmp_tas_lock kmp_tas_lock_
//
#define KMP_TAS_LOCK_INITIALIZER( lock ) { { 0, 0 } }
-extern void __kmp_acquire_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid );
+extern int __kmp_acquire_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid );
extern int __kmp_test_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid );
extern int __kmp_release_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid );
extern void __kmp_init_tas_lock( kmp_tas_lock_t *lck );
extern void __kmp_destroy_tas_lock( kmp_tas_lock_t *lck );
-extern void __kmp_acquire_nested_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid );
+extern int __kmp_acquire_nested_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid );
extern int __kmp_test_nested_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid );
extern int __kmp_release_nested_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid );
extern void __kmp_init_nested_tas_lock( kmp_tas_lock_t *lck );
@@ -173,7 +173,8 @@ extern void __kmp_destroy_nested_tas_loc
#define KMP_LOCK_RELEASED 1
#define KMP_LOCK_STILL_HELD 0
-
+#define KMP_LOCK_ACQUIRED_FIRST 1
+#define KMP_LOCK_ACQUIRED_NEXT 0
#if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64)
@@ -213,13 +214,13 @@ typedef union kmp_futex_lock kmp_futex_l
//
#define KMP_FUTEX_LOCK_INITIALIZER( lock ) { { 0, 0 } }
-extern void __kmp_acquire_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid );
+extern int __kmp_acquire_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid );
extern int __kmp_test_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid );
extern int __kmp_release_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid );
extern void __kmp_init_futex_lock( kmp_futex_lock_t *lck );
extern void __kmp_destroy_futex_lock( kmp_futex_lock_t *lck );
-extern void __kmp_acquire_nested_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid );
+extern int __kmp_acquire_nested_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid );
extern int __kmp_test_nested_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid );
extern int __kmp_release_nested_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid );
extern void __kmp_init_nested_futex_lock( kmp_futex_lock_t *lck );
@@ -261,14 +262,14 @@ typedef union kmp_ticket_lock kmp_ticket
//
#define KMP_TICKET_LOCK_INITIALIZER( lock ) { { (kmp_ticket_lock_t *) & (lock), NULL, 0, 0, 0, -1 } }
-extern void __kmp_acquire_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid );
+extern int __kmp_acquire_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid );
extern int __kmp_test_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid );
extern int __kmp_test_ticket_lock_with_cheks( kmp_ticket_lock_t *lck, kmp_int32 gtid );
extern int __kmp_release_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid );
extern void __kmp_init_ticket_lock( kmp_ticket_lock_t *lck );
extern void __kmp_destroy_ticket_lock( kmp_ticket_lock_t *lck );
-extern void __kmp_acquire_nested_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid );
+extern int __kmp_acquire_nested_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid );
extern int __kmp_test_nested_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid );
extern int __kmp_release_nested_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid );
extern void __kmp_init_nested_ticket_lock( kmp_ticket_lock_t *lck );
@@ -364,13 +365,13 @@ union KMP_ALIGN_CACHE kmp_queuing_lock {
typedef union kmp_queuing_lock kmp_queuing_lock_t;
-extern void __kmp_acquire_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid );
+extern int __kmp_acquire_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid );
extern int __kmp_test_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid );
extern int __kmp_release_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid );
extern void __kmp_init_queuing_lock( kmp_queuing_lock_t *lck );
extern void __kmp_destroy_queuing_lock( kmp_queuing_lock_t *lck );
-extern void __kmp_acquire_nested_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid );
+extern int __kmp_acquire_nested_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid );
extern int __kmp_test_nested_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid );
extern int __kmp_release_nested_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid );
extern void __kmp_init_nested_queuing_lock( kmp_queuing_lock_t *lck );
@@ -468,13 +469,13 @@ union KMP_ALIGN_CACHE kmp_drdpa_lock {
typedef union kmp_drdpa_lock kmp_drdpa_lock_t;
-extern void __kmp_acquire_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid );
+extern int __kmp_acquire_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid );
extern int __kmp_test_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid );
extern int __kmp_release_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid );
extern void __kmp_init_drdpa_lock( kmp_drdpa_lock_t *lck );
extern void __kmp_destroy_drdpa_lock( kmp_drdpa_lock_t *lck );
-extern void __kmp_acquire_nested_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid );
+extern int __kmp_acquire_nested_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid );
extern int __kmp_test_nested_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid );
extern int __kmp_release_nested_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid );
extern void __kmp_init_nested_drdpa_lock( kmp_drdpa_lock_t *lck );
@@ -500,10 +501,10 @@ typedef kmp_ticket_lock_t kmp_bootstrap_
#define KMP_BOOTSTRAP_LOCK_INITIALIZER( lock ) KMP_TICKET_LOCK_INITIALIZER( (lock) )
-static inline void
+static inline int
__kmp_acquire_bootstrap_lock( kmp_bootstrap_lock_t *lck )
{
- __kmp_acquire_ticket_lock( lck, KMP_GTID_DNE );
+ return __kmp_acquire_ticket_lock( lck, KMP_GTID_DNE );
}
static inline int
@@ -545,10 +546,10 @@ __kmp_destroy_bootstrap_lock( kmp_bootst
typedef kmp_ticket_lock_t kmp_lock_t;
-static inline void
+static inline int
__kmp_acquire_lock( kmp_lock_t *lck, kmp_int32 gtid )
{
- __kmp_acquire_ticket_lock( lck, gtid );
+ return __kmp_acquire_ticket_lock( lck, gtid );
}
static inline int
@@ -636,7 +637,7 @@ __kmp_get_user_lock_owner( kmp_user_lock
return ( *__kmp_get_user_lock_owner_ )( lck );
}
-extern void ( *__kmp_acquire_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid );
+extern int ( *__kmp_acquire_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid );
#if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64)
@@ -678,11 +679,11 @@ extern void ( *__kmp_acquire_user_lock_w
}
#else
-static inline void
+static inline int
__kmp_acquire_user_lock_with_checks( kmp_user_lock_p lck, kmp_int32 gtid )
{
KMP_DEBUG_ASSERT( __kmp_acquire_user_lock_with_checks_ != NULL );
- ( *__kmp_acquire_user_lock_with_checks_ )( lck, gtid );
+ return ( *__kmp_acquire_user_lock_with_checks_ )( lck, gtid );
}
#endif
@@ -759,11 +760,11 @@ __kmp_destroy_user_lock_with_checks( kmp
( *__kmp_destroy_user_lock_with_checks_ )( lck );
}
-extern void ( *__kmp_acquire_nested_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid );
+extern int ( *__kmp_acquire_nested_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid );
#if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
-#define __kmp_acquire_nested_user_lock_with_checks(lck,gtid) \
+#define __kmp_acquire_nested_user_lock_with_checks(lck,gtid,depth) \
if (__kmp_user_lock_kind == lk_tas) { \
if ( __kmp_env_consistency_check ) { \
char const * const func = "omp_set_nest_lock"; \
@@ -774,6 +775,7 @@ extern void ( *__kmp_acquire_nested_user
} \
if ( lck->tas.lk.poll - 1 == gtid ) { \
lck->tas.lk.depth_locked += 1; \
+ *depth = KMP_LOCK_ACQUIRED_NEXT; \
} else { \
if ( ( lck->tas.lk.poll != 0 ) || \
( ! KMP_COMPARE_AND_STORE_ACQ32( &(lck->tas.lk.poll), 0, gtid + 1 ) ) ) { \
@@ -795,19 +797,20 @@ extern void ( *__kmp_acquire_nested_user
} \
} \
lck->tas.lk.depth_locked = 1; \
+ *depth = KMP_LOCK_ACQUIRED_FIRST; \
} \
KMP_FSYNC_ACQUIRED( lck ); \
} else { \
KMP_DEBUG_ASSERT( __kmp_acquire_nested_user_lock_with_checks_ != NULL ); \
- ( *__kmp_acquire_nested_user_lock_with_checks_ )( lck, gtid ); \
+ *depth = ( *__kmp_acquire_nested_user_lock_with_checks_ )( lck, gtid ); \
}
#else
static inline void
-__kmp_acquire_nested_user_lock_with_checks( kmp_user_lock_p lck, kmp_int32 gtid )
+__kmp_acquire_nested_user_lock_with_checks( kmp_user_lock_p lck, kmp_int32 gtid, int* depth )
{
KMP_DEBUG_ASSERT( __kmp_acquire_nested_user_lock_with_checks_ != NULL );
- ( *__kmp_acquire_nested_user_lock_with_checks_ )( lck, gtid );
+ *depth = ( *__kmp_acquire_nested_user_lock_with_checks_ )( lck, gtid );
}
#endif
@@ -940,7 +943,7 @@ extern void __kmp_set_user_lock_vptrs( k
// Macros for binding user lock functions.
//
#define KMP_BIND_USER_LOCK_TEMPLATE(nest, kind, suffix) { \
- __kmp_acquire##nest##user_lock_with_checks_ = ( void (*)( kmp_user_lock_p, kmp_int32 ) ) \
+ __kmp_acquire##nest##user_lock_with_checks_ = ( int (*)( kmp_user_lock_p, kmp_int32 ) ) \
__kmp_acquire##nest##kind##_##suffix; \
__kmp_release##nest##user_lock_with_checks_ = ( int (*)( kmp_user_lock_p, kmp_int32 ) ) \
__kmp_release##nest##kind##_##suffix; \
Modified: openmp/trunk/runtime/src/ompt-event-specific.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/ompt-event-specific.h?rev=250526&r1=250525&r2=250526&view=diff
==============================================================================
--- openmp/trunk/runtime/src/ompt-event-specific.h (original)
+++ openmp/trunk/runtime/src/ompt-event-specific.h Fri Oct 16 11:52:58 2015
@@ -126,18 +126,18 @@
#define ompt_event_wait_atomic_implemented ompt_event_MAY_ALWAYS_TRACE
#define ompt_event_wait_ordered_implemented ompt_event_MAY_ALWAYS_TRACE
-#define ompt_event_acquired_lock_implemented ompt_event_UNIMPLEMENTED
-#define ompt_event_acquired_nest_lock_first_implemented ompt_event_UNIMPLEMENTED
-#define ompt_event_acquired_nest_lock_next_implemented ompt_event_UNIMPLEMENTED
+#define ompt_event_acquired_lock_implemented ompt_event_MAY_ALWAYS_TRACE
+#define ompt_event_acquired_nest_lock_first_implemented ompt_event_MAY_ALWAYS_TRACE
+#define ompt_event_acquired_nest_lock_next_implemented ompt_event_MAY_ALWAYS_TRACE
#define ompt_event_acquired_critical_implemented ompt_event_UNIMPLEMENTED
#define ompt_event_acquired_atomic_implemented ompt_event_MAY_ALWAYS_TRACE
#define ompt_event_acquired_ordered_implemented ompt_event_MAY_ALWAYS_TRACE
-#define ompt_event_init_lock_implemented ompt_event_UNIMPLEMENTED
-#define ompt_event_init_nest_lock_implemented ompt_event_UNIMPLEMENTED
+#define ompt_event_init_lock_implemented ompt_event_MAY_ALWAYS_TRACE
+#define ompt_event_init_nest_lock_implemented ompt_event_MAY_ALWAYS_TRACE
-#define ompt_event_destroy_lock_implemented ompt_event_UNIMPLEMENTED
-#define ompt_event_destroy_nest_lock_implemented ompt_event_UNIMPLEMENTED
+#define ompt_event_destroy_lock_implemented ompt_event_MAY_ALWAYS_TRACE
+#define ompt_event_destroy_nest_lock_implemented ompt_event_MAY_ALWAYS_TRACE
#define ompt_event_flush_implemented ompt_event_UNIMPLEMENTED
More information about the Openmp-commits
mailing list