Skip to content

Commit

Permalink
[OMPT] Simplify control variable logic for OMPT
Browse files Browse the repository at this point in the history
Prior to this change, OMPT had a status flag ompt_status, which could take
several values. This was due to an earlier OMPT design that had several levels
of enablement (ready, disabled, tracking state, tracking callbacks). The
current OMPT design has OMPT support either on or off.
This revision replaces ompt_status with a boolean flag ompt_enabled, which 
simplifies the runtime logic for OMPT.

Patch by John Mellor-Crummey

Differential Revision: http://reviews.llvm.org/D12999

llvm-svn: 248189
  • Loading branch information
jpeyton52 committed Sep 21, 2015
1 parent be58ff8 commit b68a85d
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 157 deletions.
6 changes: 3 additions & 3 deletions openmp/runtime/src/kmp_atomic.h
Expand Up @@ -371,7 +371,7 @@ static inline void
__kmp_acquire_atomic_lock( kmp_atomic_lock_t *lck, kmp_int32 gtid )
{
#if OMPT_SUPPORT && OMPT_TRACE
if ((ompt_status == ompt_status_track_callback) &&
if (ompt_enabled &&
ompt_callbacks.ompt_callback(ompt_event_wait_atomic)) {
ompt_callbacks.ompt_callback(ompt_event_wait_atomic)(
(ompt_wait_id_t) lck);
Expand All @@ -381,7 +381,7 @@ __kmp_acquire_atomic_lock( kmp_atomic_lock_t *lck, kmp_int32 gtid )
__kmp_acquire_queuing_lock( lck, gtid );

#if OMPT_SUPPORT && OMPT_TRACE
if ((ompt_status == ompt_status_track_callback) &&
if (ompt_enabled &&
ompt_callbacks.ompt_callback(ompt_event_acquired_atomic)) {
ompt_callbacks.ompt_callback(ompt_event_acquired_atomic)(
(ompt_wait_id_t) lck);
Expand All @@ -400,7 +400,7 @@ __kmp_release_atomic_lock( kmp_atomic_lock_t *lck, kmp_int32 gtid )
{
__kmp_release_queuing_lock( lck, gtid );
#if OMPT_SUPPORT && OMPT_BLAME
if ((ompt_status == ompt_status_track_callback) &&
if (ompt_enabled &&
ompt_callbacks.ompt_callback(ompt_event_release_atomic)) {
ompt_callbacks.ompt_callback(ompt_event_release_atomic)(
(ompt_wait_id_t) lck);
Expand Down
40 changes: 18 additions & 22 deletions openmp/runtime/src/kmp_barrier.cpp
Expand Up @@ -1057,25 +1057,23 @@ __kmp_barrier(enum barrier_type bt, int gtid, int is_split, size_t reduce_size,
gtid, __kmp_team_from_gtid(gtid)->t.t_id, __kmp_tid_from_gtid(gtid)));

#if OMPT_SUPPORT
if (ompt_status & ompt_status_track) {
if (ompt_enabled) {
#if OMPT_BLAME
if (ompt_status == ompt_status_track_callback) {
my_task_id = team->t.t_implicit_task_taskdata[tid].ompt_task_info.task_id;
my_parallel_id = team->t.ompt_team_info.parallel_id;
my_task_id = team->t.t_implicit_task_taskdata[tid].ompt_task_info.task_id;
my_parallel_id = team->t.ompt_team_info.parallel_id;

#if OMPT_TRACE
if (this_thr->th.ompt_thread_info.state == ompt_state_wait_single) {
if (ompt_callbacks.ompt_callback(ompt_event_single_others_end)) {
ompt_callbacks.ompt_callback(ompt_event_single_others_end)(
my_parallel_id, my_task_id);
}
}
#endif
if (ompt_callbacks.ompt_callback(ompt_event_barrier_begin)) {
ompt_callbacks.ompt_callback(ompt_event_barrier_begin)(
if (this_thr->th.ompt_thread_info.state == ompt_state_wait_single) {
if (ompt_callbacks.ompt_callback(ompt_event_single_others_end)) {
ompt_callbacks.ompt_callback(ompt_event_single_others_end)(
my_parallel_id, my_task_id);
}
}
}
#endif
if (ompt_callbacks.ompt_callback(ompt_event_barrier_begin)) {
ompt_callbacks.ompt_callback(ompt_event_barrier_begin)(
my_parallel_id, my_task_id);
}
#endif
// It is OK to report the barrier state after the barrier begin callback.
// According to the OMPT specification, a compliant implementation may
Expand Down Expand Up @@ -1280,10 +1278,9 @@ __kmp_barrier(enum barrier_type bt, int gtid, int is_split, size_t reduce_size,
gtid, __kmp_team_from_gtid(gtid)->t.t_id, __kmp_tid_from_gtid(gtid), status));

#if OMPT_SUPPORT
if (ompt_status & ompt_status_track) {
if (ompt_enabled) {
#if OMPT_BLAME
if ((ompt_status == ompt_status_track_callback) &&
ompt_callbacks.ompt_callback(ompt_event_barrier_end)) {
if (ompt_callbacks.ompt_callback(ompt_event_barrier_end)) {
ompt_callbacks.ompt_callback(ompt_event_barrier_end)(
my_parallel_id, my_task_id);
}
Expand Down Expand Up @@ -1385,7 +1382,7 @@ __kmp_join_barrier(int gtid)

#if OMPT_SUPPORT
#if OMPT_TRACE
if ((ompt_status == ompt_status_track_callback) &&
if (ompt_enabled &&
ompt_callbacks.ompt_callback(ompt_event_barrier_begin)) {
ompt_callbacks.ompt_callback(ompt_event_barrier_begin)(
team->t.ompt_team_info.parallel_id,
Expand Down Expand Up @@ -1517,14 +1514,13 @@ __kmp_join_barrier(int gtid)
KA_TRACE(10, ("__kmp_join_barrier: T#%d(%d:%d) leaving\n", gtid, team_id, tid));

#if OMPT_SUPPORT
if (ompt_status & ompt_status_track) {
if (ompt_enabled) {
#if OMPT_BLAME
if ((ompt_status == ompt_status_track_callback) &&
ompt_callbacks.ompt_callback(ompt_event_barrier_end)) {
if (ompt_callbacks.ompt_callback(ompt_event_barrier_end)) {
ompt_callbacks.ompt_callback(ompt_event_barrier_end)(
team->t.ompt_team_info.parallel_id,
team->t.t_implicit_task_taskdata[tid].ompt_task_info.task_id);
}
}
#endif

// return to default state
Expand Down
36 changes: 17 additions & 19 deletions openmp/runtime/src/kmp_csupport.c
Expand Up @@ -304,7 +304,7 @@ __kmpc_fork_call(ident_t *loc, kmp_int32 argc, kmpc_micro microtask, ...)
int tid = __kmp_tid_from_gtid( gtid );
kmp_info_t *master_th = __kmp_threads[ gtid ];
kmp_team_t *parent_team = master_th->th.th_team;
if (ompt_status & ompt_status_track) {
if (ompt_enabled) {
parent_team->t.t_implicit_task_taskdata[tid].
ompt_task_info.frame.reenter_runtime_frame = __builtin_frame_address(0);
}
Expand Down Expand Up @@ -339,7 +339,7 @@ __kmpc_fork_call(ident_t *loc, kmp_int32 argc, kmpc_micro microtask, ...)
va_end( ap );

#if OMPT_SUPPORT
if (ompt_status & ompt_status_track) {
if (ompt_enabled) {
parent_team->t.t_implicit_task_taskdata[tid].
ompt_task_info.frame.reenter_runtime_frame = 0;
}
Expand Down Expand Up @@ -398,7 +398,7 @@ __kmpc_fork_teams(ident_t *loc, kmp_int32 argc, kmpc_micro microtask, ...)
#if OMPT_SUPPORT
kmp_team_t *parent_team = this_thr->th.th_team;
int tid = __kmp_tid_from_gtid( gtid );
if (ompt_status & ompt_status_track) {
if (ompt_enabled) {
parent_team->t.t_implicit_task_taskdata[tid].
ompt_task_info.frame.reenter_runtime_frame = __builtin_frame_address(0);
}
Expand Down Expand Up @@ -432,7 +432,7 @@ __kmpc_fork_teams(ident_t *loc, kmp_int32 argc, kmpc_micro microtask, ...)
);

#if OMPT_SUPPORT
if (ompt_status & ompt_status_track) {
if (ompt_enabled) {
parent_team->t.t_implicit_task_taskdata[tid].
ompt_task_info.frame.reenter_runtime_frame = NULL;
}
Expand Down Expand Up @@ -747,7 +747,7 @@ __kmpc_master(ident_t *loc, kmp_int32 global_tid)

#if OMPT_SUPPORT && OMPT_TRACE
if (status) {
if ((ompt_status == ompt_status_track_callback) &&
if (ompt_enabled &&
ompt_callbacks.ompt_callback(ompt_event_master_begin)) {
kmp_info_t *this_thr = __kmp_threads[ global_tid ];
kmp_team_t *team = this_thr -> th.th_team;
Expand Down Expand Up @@ -796,7 +796,7 @@ __kmpc_end_master(ident_t *loc, kmp_int32 global_tid)
#if OMPT_SUPPORT && OMPT_TRACE
kmp_info_t *this_thr = __kmp_threads[ global_tid ];
kmp_team_t *team = this_thr -> th.th_team;
if ((ompt_status == ompt_status_track_callback) &&
if (ompt_enabled &&
ompt_callbacks.ompt_callback(ompt_event_master_end)) {
int tid = __kmp_tid_from_gtid( global_tid );
ompt_callbacks.ompt_callback(ompt_event_master_end)(
Expand Down Expand Up @@ -841,14 +841,13 @@ __kmpc_ordered( ident_t * loc, kmp_int32 gtid )
th = __kmp_threads[ gtid ];

#if OMPT_SUPPORT && OMPT_TRACE
if (ompt_status & ompt_status_track) {
if (ompt_enabled) {
/* OMPT state update */
th->th.ompt_thread_info.wait_id = (uint64_t) loc;
th->th.ompt_thread_info.state = ompt_state_wait_ordered;

/* OMPT event callback */
if ((ompt_status == ompt_status_track_callback) &&
ompt_callbacks.ompt_callback(ompt_event_wait_ordered)) {
if (ompt_callbacks.ompt_callback(ompt_event_wait_ordered)) {
ompt_callbacks.ompt_callback(ompt_event_wait_ordered)(
th->th.ompt_thread_info.wait_id);
}
Expand All @@ -861,14 +860,13 @@ __kmpc_ordered( ident_t * loc, kmp_int32 gtid )
__kmp_parallel_deo( & gtid, & cid, loc );

#if OMPT_SUPPORT && OMPT_TRACE
if (ompt_status & ompt_status_track) {
if (ompt_enabled) {
/* OMPT state update */
th->th.ompt_thread_info.state = ompt_state_work_parallel;
th->th.ompt_thread_info.wait_id = 0;

/* OMPT event callback */
if ((ompt_status == ompt_status_track_callback) &&
ompt_callbacks.ompt_callback(ompt_event_acquired_ordered)) {
if (ompt_callbacks.ompt_callback(ompt_event_acquired_ordered)) {
ompt_callbacks.ompt_callback(ompt_event_acquired_ordered)(
th->th.ompt_thread_info.wait_id);
}
Expand Down Expand Up @@ -908,7 +906,7 @@ __kmpc_end_ordered( ident_t * loc, kmp_int32 gtid )
__kmp_parallel_dxo( & gtid, & cid, loc );

#if OMPT_SUPPORT && OMPT_BLAME
if ((ompt_status == ompt_status_track_callback) &&
if (ompt_enabled &&
ompt_callbacks.ompt_callback(ompt_event_release_ordered)) {
ompt_callbacks.ompt_callback(ompt_event_release_ordered)(
th->th.ompt_thread_info.wait_id);
Expand Down Expand Up @@ -1287,7 +1285,7 @@ __kmpc_end_critical(ident_t *loc, kmp_int32 global_tid, kmp_critical_name *crit)
__kmp_release_user_lock_with_checks( lck, global_tid );

#if OMPT_SUPPORT && OMPT_BLAME
if ((ompt_status == ompt_status_track_callback) &&
if (ompt_enabled &&
ompt_callbacks.ompt_callback(ompt_event_release_critical)) {
ompt_callbacks.ompt_callback(ompt_event_release_critical)(
(uint64_t) lck);
Expand Down Expand Up @@ -1423,7 +1421,7 @@ __kmpc_single(ident_t *loc, kmp_int32 global_tid)
kmp_team_t *team = this_thr -> th.th_team;
int tid = __kmp_tid_from_gtid( global_tid );

if ((ompt_status == ompt_status_track_callback)) {
if (ompt_enabled) {
if (rc) {
if (ompt_callbacks.ompt_callback(ompt_event_single_in_block_begin)) {
ompt_callbacks.ompt_callback(ompt_event_single_in_block_begin)(
Expand Down Expand Up @@ -1465,7 +1463,7 @@ __kmpc_end_single(ident_t *loc, kmp_int32 global_tid)
kmp_team_t *team = this_thr -> th.th_team;
int tid = __kmp_tid_from_gtid( global_tid );

if ((ompt_status == ompt_status_track_callback) &&
if (ompt_enabled &&
ompt_callbacks.ompt_callback(ompt_event_single_in_block_end)) {
ompt_callbacks.ompt_callback(ompt_event_single_in_block_end)(
team->t.ompt_team_info.parallel_id,
Expand All @@ -1491,7 +1489,7 @@ __kmpc_for_static_fini( ident_t *loc, kmp_int32 global_tid )
kmp_team_t *team = this_thr -> th.th_team;
int tid = __kmp_tid_from_gtid( global_tid );

if ((ompt_status == ompt_status_track_callback) &&
if (ompt_enabled &&
ompt_callbacks.ompt_callback(ompt_event_loop_end)) {
ompt_callbacks.ompt_callback(ompt_event_loop_end)(
team->t.ompt_team_info.parallel_id,
Expand Down Expand Up @@ -2141,7 +2139,7 @@ __kmpc_unset_lock( ident_t *loc, kmp_int32 gtid, void **user_lock )
RELEASE_LOCK( lck, gtid );

#if OMPT_SUPPORT && OMPT_BLAME
if ((ompt_status == ompt_status_track_callback) &&
if (ompt_enabled &&
ompt_callbacks.ompt_callback(ompt_event_release_lock)) {
ompt_callbacks.ompt_callback(ompt_event_release_lock)((uint64_t) lck);
}
Expand Down Expand Up @@ -2202,7 +2200,7 @@ __kmpc_unset_nest_lock( ident_t *loc, kmp_int32 gtid, void **user_lock )
int release_status;
release_status = RELEASE_NESTED_LOCK( lck, gtid );
#if OMPT_SUPPORT && OMPT_BLAME
if (ompt_status == ompt_status_track_callback) {
if (ompt_enabled) {
if (release_status == KMP_LOCK_RELEASED) {
if (ompt_callbacks.ompt_callback(ompt_event_release_nest_lock_last)) {
ompt_callbacks.ompt_callback(ompt_event_release_nest_lock_last)(
Expand Down
4 changes: 2 additions & 2 deletions openmp/runtime/src/kmp_dispatch.cpp
Expand Up @@ -1209,7 +1209,7 @@ __kmp_dispatch_init(
#endif // ( KMP_STATIC_STEAL_ENABLED && USE_STEALING )

#if OMPT_SUPPORT && OMPT_TRACE
if ((ompt_status == ompt_status_track_callback) &&
if (ompt_enabled &&
ompt_callbacks.ompt_callback(ompt_event_loop_begin)) {
ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
Expand Down Expand Up @@ -1373,7 +1373,7 @@ __kmp_dispatch_finish_chunk( int gtid, ident_t *loc )
#if OMPT_SUPPORT && OMPT_TRACE
#define OMPT_LOOP_END \
if (status == 0) { \
if ((ompt_status == ompt_status_track_callback) && \
if (ompt_enabled && \
ompt_callbacks.ompt_callback(ompt_event_loop_end)) { \
ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL); \
ompt_task_info_t *task_info = __ompt_get_taskinfo(0); \
Expand Down

0 comments on commit b68a85d

Please sign in to comment.