Skip to content

Commit

Permalink
[OMPT] Add OMPT events for API locking
Browse files Browse the repository at this point in the history
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

llvm-svn: 250526
  • Loading branch information
jpeyton52 committed Oct 16, 2015
1 parent eda01c3 commit 0e6d457
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 73 deletions.
50 changes: 49 additions & 1 deletion openmp/runtime/src/kmp_csupport.c
Expand Up @@ -1801,6 +1801,13 @@ __kmpc_init_lock( ident_t * loc, kmp_int32 gtid, void ** user_lock ) {
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 */
Expand Down Expand Up @@ -1870,6 +1877,13 @@ __kmpc_init_nest_lock( ident_t * loc, kmp_int32 gtid, void ** user_lock ) {
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 */
Expand Down Expand Up @@ -1908,6 +1922,13 @@ __kmpc_destroy_lock( ident_t * loc, kmp_int32 gtid, void ** user_lock ) {
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 */
Expand Down Expand Up @@ -1959,6 +1980,13 @@ __kmpc_destroy_nest_lock( ident_t * loc, kmp_int32 gtid, void ** user_lock ) {
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 */
Expand Down Expand Up @@ -2034,6 +2062,13 @@ __kmpc_set_lock( ident_t * loc, kmp_int32 gtid, void ** user_lock ) {
__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
}

Expand All @@ -2050,6 +2085,7 @@ __kmpc_set_nest_lock( ident_t * loc, kmp_int32 gtid, void ** user_lock ) {
#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 )
Expand All @@ -2071,12 +2107,24 @@ __kmpc_set_nest_lock( ident_t * loc, kmp_int32 gtid, void ** user_lock ) {
__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
Expand Down

0 comments on commit 0e6d457

Please sign in to comment.