Skip to content

Commit d081872

Browse files
committed
Initial steps to move the builtin_return_address call to the entry-point
1 parent 7b9c6db commit d081872

File tree

4 files changed

+208
-7
lines changed

4 files changed

+208
-7
lines changed

runtime/src/kmp_barrier.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@ __kmp_barrier(enum barrier_type bt, int gtid, int is_split, size_t reduce_size,
10991099
#if OMPT_SUPPORT
11001100
ompt_task_data_t* my_task_data;
11011101
ompt_parallel_data_t* my_parallel_data;
1102+
void* return_address;
11021103
#endif
11031104

11041105
KA_TRACE(15, ("__kmp_barrier: T#%d(%d:%d) has arrived\n",
@@ -1107,24 +1108,25 @@ __kmp_barrier(enum barrier_type bt, int gtid, int is_split, size_t reduce_size,
11071108
ANNOTATE_BARRIER_BEGIN(&team->t.t_bar);
11081109
#if OMPT_SUPPORT
11091110
if (ompt_enabled) {
1110-
#if OMPT_OPTIONAL
11111111
my_task_data = OMPT_CUR_TASK_DATA(this_thr);
11121112
my_parallel_data = OMPT_CUR_TEAM_DATA(this_thr);
1113+
return_address = OMPT_LOAD_RETURN_ADDRESS(this_thr);
11131114
if (ompt_callbacks.ompt_callback(ompt_callback_sync_region)) {
11141115
ompt_callbacks.ompt_callback(ompt_callback_sync_region)(
11151116
ompt_sync_region_barrier,
11161117
ompt_scope_begin,
11171118
my_parallel_data,
11181119
my_task_data,
1119-
OMPT_GET_RETURN_ADDRESS(1));
1120+
return_address);
11201121
}
1122+
#if OMPT_OPTIONAL
11211123
if (ompt_callbacks.ompt_callback(ompt_callback_sync_region_wait)) {
11221124
ompt_callbacks.ompt_callback(ompt_callback_sync_region_wait)(
11231125
ompt_sync_region_barrier,
11241126
ompt_scope_begin,
11251127
my_parallel_data,
11261128
my_task_data,
1127-
OMPT_GET_RETURN_ADDRESS(1));
1129+
return_address);
11281130
}
11291131
#endif
11301132
// It is OK to report the barrier state after the barrier begin callback.
@@ -1348,15 +1350,15 @@ __kmp_barrier(enum barrier_type bt, int gtid, int is_split, size_t reduce_size,
13481350
ompt_scope_end,
13491351
my_parallel_data,
13501352
my_task_data,
1351-
OMPT_GET_RETURN_ADDRESS(1));
1353+
return_address);
13521354
}
13531355
if (ompt_callbacks.ompt_callback(ompt_callback_sync_region)) {
13541356
ompt_callbacks.ompt_callback(ompt_callback_sync_region)(
13551357
ompt_sync_region_barrier,
13561358
ompt_scope_end,
13571359
my_parallel_data,
13581360
my_task_data,
1359-
OMPT_GET_RETURN_ADDRESS(1));
1361+
return_address);
13601362
}
13611363
#endif
13621364
this_thr->th.ompt_thread_info.state = ompt_state_work_parallel;

runtime/src/kmp_csupport.cpp

Lines changed: 122 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,12 +715,13 @@ __kmpc_barrier(ident_t *loc, kmp_int32 global_tid)
715715
__kmp_check_barrier( global_tid, ct_barrier, loc );
716716
}
717717

718-
#if OMPT_SUPPORT && OMPT_OPTIONAL
718+
#if OMPT_SUPPORT
719719
ompt_frame_t * ompt_frame;
720720
if (ompt_enabled ) {
721721
__ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
722722
if ( ompt_frame->reenter_runtime_frame == NULL )
723723
ompt_frame->reenter_runtime_frame = OMPT_GET_FRAME_ADDRESS(1);
724+
OMPT_STORE_KMP_RETURN_ADDRESS(global_tid);
724725
}
725726
#endif
726727
__kmp_threads[ global_tid ]->th.th_ident = loc;
@@ -1528,10 +1529,24 @@ __kmpc_barrier_master(ident_t *loc, kmp_int32 global_tid)
15281529
if ( __kmp_env_consistency_check )
15291530
__kmp_check_barrier( global_tid, ct_barrier, loc );
15301531

1532+
#if OMPT_SUPPORT
1533+
ompt_frame_t * ompt_frame;
1534+
if (ompt_enabled ) {
1535+
__ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
1536+
if ( ompt_frame->reenter_runtime_frame == NULL )
1537+
ompt_frame->reenter_runtime_frame = OMPT_GET_FRAME_ADDRESS(1);
1538+
OMPT_STORE_KMP_RETURN_ADDRESS(global_tid);
1539+
}
1540+
#endif
15311541
#if USE_ITT_NOTIFY
15321542
__kmp_threads[global_tid]->th.th_ident = loc;
15331543
#endif
15341544
status = __kmp_barrier( bs_plain_barrier, global_tid, TRUE, 0, NULL, NULL );
1545+
#if OMPT_SUPPORT && OMPT_OPTIONAL
1546+
if (ompt_enabled ) {
1547+
ompt_frame->reenter_runtime_frame = NULL;
1548+
}
1549+
#endif
15351550

15361551
return (status != 0) ? 0 : 1;
15371552
}
@@ -1580,10 +1595,24 @@ __kmpc_barrier_master_nowait( ident_t * loc, kmp_int32 global_tid )
15801595
__kmp_check_barrier( global_tid, ct_barrier, loc );
15811596
}
15821597

1598+
#if OMPT_SUPPORT
1599+
ompt_frame_t * ompt_frame;
1600+
if (ompt_enabled ) {
1601+
__ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
1602+
if ( ompt_frame->reenter_runtime_frame == NULL )
1603+
ompt_frame->reenter_runtime_frame = OMPT_GET_FRAME_ADDRESS(1);
1604+
OMPT_STORE_KMP_RETURN_ADDRESS(global_tid);
1605+
}
1606+
#endif
15831607
#if USE_ITT_NOTIFY
15841608
__kmp_threads[global_tid]->th.th_ident = loc;
15851609
#endif
15861610
__kmp_barrier( bs_plain_barrier, global_tid, FALSE, 0, NULL, NULL );
1611+
#if OMPT_SUPPORT && OMPT_OPTIONAL
1612+
if (ompt_enabled ) {
1613+
ompt_frame->reenter_runtime_frame = NULL;
1614+
}
1615+
#endif
15871616

15881617
ret = __kmpc_master (loc, global_tid);
15891618

@@ -1953,6 +1982,15 @@ __kmpc_copyprivate( ident_t *loc, kmp_int32 gtid, size_t cpy_size, void *cpy_dat
19531982

19541983
if (didit) *data_ptr = cpy_data;
19551984

1985+
#if OMPT_SUPPORT
1986+
ompt_frame_t * ompt_frame;
1987+
if (ompt_enabled ) {
1988+
__ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
1989+
if ( ompt_frame->reenter_runtime_frame == NULL )
1990+
ompt_frame->reenter_runtime_frame = OMPT_GET_FRAME_ADDRESS(1);
1991+
OMPT_STORE_KMP_RETURN_ADDRESS(gtid);
1992+
}
1993+
#endif
19561994
/* This barrier is not a barrier region boundary */
19571995
#if USE_ITT_NOTIFY
19581996
__kmp_threads[gtid]->th.th_ident = loc;
@@ -1964,10 +2002,20 @@ __kmpc_copyprivate( ident_t *loc, kmp_int32 gtid, size_t cpy_size, void *cpy_dat
19642002
/* Consider next barrier the user-visible barrier for barrier region boundaries */
19652003
/* Nesting checks are already handled by the single construct checks */
19662004

2005+
#if OMPT_SUPPORT
2006+
if (ompt_enabled ) {
2007+
OMPT_STORE_KMP_RETURN_ADDRESS(gtid);
2008+
}
2009+
#endif
19672010
#if USE_ITT_NOTIFY
19682011
__kmp_threads[gtid]->th.th_ident = loc; // TODO: check if it is needed (e.g. tasks can overwrite the location)
19692012
#endif
19702013
__kmp_barrier( bs_plain_barrier, gtid, FALSE , 0, NULL, NULL );
2014+
#if OMPT_SUPPORT && OMPT_OPTIONAL
2015+
if (ompt_enabled ) {
2016+
ompt_frame->reenter_runtime_frame = NULL;
2017+
}
2018+
#endif
19712019
}
19722020

19732021
/* -------------------------------------------------------------------------- */
@@ -3271,11 +3319,28 @@ __kmpc_reduce_nowait(
32713319

32723320
// this barrier should be invisible to a customer and to the threading profile tool
32733321
// (it's neither a terminating barrier nor customer's code, it's used for an internal purpose)
3322+
#if OMPT_SUPPORT
3323+
//JP: can this barrier potentially leed to task scheduling?
3324+
//JP: as long as there is a barrier in the implementation, OMPT should and will provide the barrier events
3325+
// so we set-up the necessary frame/return addresses.
3326+
ompt_frame_t * ompt_frame;
3327+
if (ompt_enabled ) {
3328+
__ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
3329+
if ( ompt_frame->reenter_runtime_frame == NULL )
3330+
ompt_frame->reenter_runtime_frame = OMPT_GET_FRAME_ADDRESS(1);
3331+
OMPT_STORE_KMP_RETURN_ADDRESS(global_tid);
3332+
}
3333+
#endif
32743334
#if USE_ITT_NOTIFY
32753335
__kmp_threads[global_tid]->th.th_ident = loc;
32763336
#endif
32773337
retval = __kmp_barrier( UNPACK_REDUCTION_BARRIER( packed_reduction_method ), global_tid, FALSE, reduce_size, reduce_data, reduce_func );
32783338
retval = ( retval != 0 ) ? ( 0 ) : ( 1 );
3339+
#if OMPT_SUPPORT && OMPT_OPTIONAL
3340+
if (ompt_enabled ) {
3341+
ompt_frame->reenter_runtime_frame = NULL;
3342+
}
3343+
#endif
32793344

32803345
// all other workers except master should do this pop here
32813346
// ( none of other workers will get to __kmpc_end_reduce_nowait() )
@@ -3424,11 +3489,25 @@ __kmpc_reduce(
34243489
//case tree_reduce_block:
34253490
// this barrier should be visible to a customer and to the threading profile tool
34263491
// (it's a terminating barrier on constructs if NOWAIT not specified)
3492+
#if OMPT_SUPPORT
3493+
ompt_frame_t * ompt_frame;
3494+
if (ompt_enabled ) {
3495+
__ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
3496+
if ( ompt_frame->reenter_runtime_frame == NULL )
3497+
ompt_frame->reenter_runtime_frame = OMPT_GET_FRAME_ADDRESS(1);
3498+
OMPT_STORE_KMP_RETURN_ADDRESS(global_tid);
3499+
}
3500+
#endif
34273501
#if USE_ITT_NOTIFY
34283502
__kmp_threads[global_tid]->th.th_ident = loc; // needed for correct notification of frames
34293503
#endif
34303504
retval = __kmp_barrier( UNPACK_REDUCTION_BARRIER( packed_reduction_method ), global_tid, TRUE, reduce_size, reduce_data, reduce_func );
34313505
retval = ( retval != 0 ) ? ( 0 ) : ( 1 );
3506+
#if OMPT_SUPPORT && OMPT_OPTIONAL
3507+
if (ompt_enabled ) {
3508+
ompt_frame->reenter_runtime_frame = NULL;
3509+
}
3510+
#endif
34323511

34333512
// all other workers except master should do this pop here
34343513
// ( none of other workers except master will enter __kmpc_end_reduce() )
@@ -3476,28 +3555,70 @@ __kmpc_end_reduce( ident_t *loc, kmp_int32 global_tid, kmp_critical_name *lck )
34763555
__kmp_end_critical_section_reduce_block( loc, global_tid, lck );
34773556

34783557
// TODO: implicit barrier: should be exposed
3558+
#if OMPT_SUPPORT
3559+
ompt_frame_t * ompt_frame;
3560+
if (ompt_enabled ) {
3561+
__ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
3562+
if ( ompt_frame->reenter_runtime_frame == NULL )
3563+
ompt_frame->reenter_runtime_frame = OMPT_GET_FRAME_ADDRESS(1);
3564+
OMPT_STORE_KMP_RETURN_ADDRESS(global_tid);
3565+
}
3566+
#endif
34793567
#if USE_ITT_NOTIFY
34803568
__kmp_threads[global_tid]->th.th_ident = loc;
34813569
#endif
34823570
__kmp_barrier( bs_plain_barrier, global_tid, FALSE, 0, NULL, NULL );
3571+
#if OMPT_SUPPORT && OMPT_OPTIONAL
3572+
if (ompt_enabled ) {
3573+
ompt_frame->reenter_runtime_frame = NULL;
3574+
}
3575+
#endif
34833576

34843577
} else if( packed_reduction_method == empty_reduce_block ) {
34853578

34863579
// usage: if team size == 1, no synchronization is required ( Intel platforms only )
34873580

34883581
// TODO: implicit barrier: should be exposed
3582+
#if OMPT_SUPPORT
3583+
ompt_frame_t * ompt_frame;
3584+
if (ompt_enabled ) {
3585+
__ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
3586+
if ( ompt_frame->reenter_runtime_frame == NULL )
3587+
ompt_frame->reenter_runtime_frame = OMPT_GET_FRAME_ADDRESS(1);
3588+
OMPT_STORE_KMP_RETURN_ADDRESS(global_tid);
3589+
}
3590+
#endif
34893591
#if USE_ITT_NOTIFY
34903592
__kmp_threads[global_tid]->th.th_ident = loc;
34913593
#endif
34923594
__kmp_barrier( bs_plain_barrier, global_tid, FALSE, 0, NULL, NULL );
3595+
#if OMPT_SUPPORT && OMPT_OPTIONAL
3596+
if (ompt_enabled ) {
3597+
ompt_frame->reenter_runtime_frame = NULL;
3598+
}
3599+
#endif
34933600

34943601
} else if( packed_reduction_method == atomic_reduce_block ) {
34953602

3603+
#if OMPT_SUPPORT
3604+
ompt_frame_t * ompt_frame;
3605+
if (ompt_enabled ) {
3606+
__ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
3607+
if ( ompt_frame->reenter_runtime_frame == NULL )
3608+
ompt_frame->reenter_runtime_frame = OMPT_GET_FRAME_ADDRESS(1);
3609+
OMPT_STORE_KMP_RETURN_ADDRESS(global_tid);
3610+
}
3611+
#endif
34963612
// TODO: implicit barrier: should be exposed
34973613
#if USE_ITT_NOTIFY
34983614
__kmp_threads[global_tid]->th.th_ident = loc;
34993615
#endif
35003616
__kmp_barrier( bs_plain_barrier, global_tid, FALSE, 0, NULL, NULL );
3617+
#if OMPT_SUPPORT && OMPT_OPTIONAL
3618+
if (ompt_enabled ) {
3619+
ompt_frame->reenter_runtime_frame = NULL;
3620+
}
3621+
#endif
35013622

35023623
} else if( TEST_REDUCTION_METHOD( packed_reduction_method, tree_reduce_block ) ) {
35033624

0 commit comments

Comments
 (0)