[Openmp-commits] [openmp] r281464 - [OMPT] Align implementation of reenter frame address to latest (frozen) version of OMPT spec
Jonas Hahnfeld via Openmp-commits
openmp-commits at lists.llvm.org
Wed Sep 14 06:59:13 PDT 2016
Author: hahnfeld
Date: Wed Sep 14 08:59:13 2016
New Revision: 281464
URL: http://llvm.org/viewvc/llvm-project?rev=281464&view=rev
Log:
[OMPT] Align implementation of reenter frame address to latest (frozen) version of OMPT spec
The latest OMPT spec changed the semantic of a tasks reenter frame to be the application frame, that will be entered, when the runtime frame drops.
Before it was the last frame in the runtime. This doesn't work for some gcc execution pathes or even clang generated code for :
Since there is no runtime frame between the executed task and the encountering task.
The test case compares exit and reenter addresses against addresses captured in application code
Patch by Joachim Protze!
Differential Revision: https://reviews.llvm.org/D23305
Modified:
openmp/trunk/runtime/src/kmp_csupport.c
openmp/trunk/runtime/src/kmp_gsupport.c
openmp/trunk/runtime/src/kmp_runtime.c
openmp/trunk/runtime/src/kmp_tasking.c
openmp/trunk/runtime/src/ompt-specific.c
openmp/trunk/runtime/test/ompt/parallel/nested.c
Modified: openmp/trunk/runtime/src/kmp_csupport.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_csupport.c?rev=281464&r1=281463&r2=281464&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_csupport.c (original)
+++ openmp/trunk/runtime/src/kmp_csupport.c Wed Sep 14 08:59:13 2016
@@ -306,7 +306,7 @@ __kmpc_fork_call(ident_t *loc, kmp_int32
kmp_team_t *parent_team = master_th->th.th_team;
if (ompt_enabled) {
parent_team->t.t_implicit_task_taskdata[tid].
- ompt_task_info.frame.reenter_runtime_frame = __builtin_frame_address(0);
+ ompt_task_info.frame.reenter_runtime_frame = __builtin_frame_address(1);
}
#endif
@@ -341,7 +341,7 @@ __kmpc_fork_call(ident_t *loc, kmp_int32
#if OMPT_SUPPORT
if (ompt_enabled) {
parent_team->t.t_implicit_task_taskdata[tid].
- ompt_task_info.frame.reenter_runtime_frame = 0;
+ ompt_task_info.frame.reenter_runtime_frame = NULL;
}
#endif
}
@@ -396,7 +396,7 @@ __kmpc_fork_teams(ident_t *loc, kmp_int3
int tid = __kmp_tid_from_gtid( gtid );
if (ompt_enabled) {
parent_team->t.t_implicit_task_taskdata[tid].
- ompt_task_info.frame.reenter_runtime_frame = __builtin_frame_address(0);
+ ompt_task_info.frame.reenter_runtime_frame = __builtin_frame_address(1);
}
#endif
@@ -678,6 +678,14 @@ __kmpc_barrier(ident_t *loc, kmp_int32 g
__kmp_check_barrier( global_tid, ct_barrier, loc );
}
+#if OMPT_SUPPORT && OMPT_TRACE
+ ompt_frame_t * ompt_frame;
+ if (ompt_enabled ) {
+ ompt_frame = &( __kmp_threads[ global_tid ] -> th.th_team ->
+ t.t_implicit_task_taskdata[__kmp_tid_from_gtid(global_tid)].ompt_task_info.frame);
+ ompt_frame->reenter_runtime_frame = __builtin_frame_address(1);
+ }
+#endif
__kmp_threads[ global_tid ]->th.th_ident = loc;
// TODO: explicit barrier_wait_id:
// this function is called when 'barrier' directive is present or
@@ -687,6 +695,11 @@ __kmpc_barrier(ident_t *loc, kmp_int32 g
// 4) no sync is required
__kmp_barrier( bs_plain_barrier, global_tid, FALSE, 0, NULL, NULL );
+#if OMPT_SUPPORT && OMPT_TRACE
+ if (ompt_enabled ) {
+ ompt_frame->reenter_runtime_frame = NULL;
+ }
+#endif
}
/* The BARRIER for a MASTER section is always explicit */
Modified: openmp/trunk/runtime/src/kmp_gsupport.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_gsupport.c?rev=281464&r1=281463&r2=281464&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_gsupport.c (original)
+++ openmp/trunk/runtime/src/kmp_gsupport.c Wed Sep 14 08:59:13 2016
@@ -416,7 +416,7 @@ __kmp_GOMP_serialized_parallel(ident_t *
__kmp_allocate(sizeof(ompt_lw_taskteam_t));
__ompt_lw_taskteam_init(lwt, thr, gtid, (void *) task, ompt_parallel_id);
lwt->ompt_task_info.task_id = my_ompt_task_id;
- lwt->ompt_task_info.frame.exit_runtime_frame = 0;
+ lwt->ompt_task_info.frame.exit_runtime_frame = NULL;
__ompt_lw_taskteam_link(lwt, thr);
#if OMPT_TRACE
@@ -442,7 +442,7 @@ xexpand(KMP_API_NAME_GOMP_PARALLEL_START
if (ompt_enabled) {
parent_frame = __ompt_get_task_frame_internal(0);
- parent_frame->reenter_runtime_frame = __builtin_frame_address(0);
+ parent_frame->reenter_runtime_frame = __builtin_frame_address(1);
}
#endif
@@ -495,7 +495,7 @@ xexpand(KMP_API_NAME_GOMP_PARALLEL_END)(
// Record that we re-entered the runtime system in the implicit
// task frame representing the parallel region.
ompt_frame = &task_info->frame;
- ompt_frame->reenter_runtime_frame = __builtin_frame_address(0);
+ ompt_frame->reenter_runtime_frame = __builtin_frame_address(1);
// unlink if necessary. no-op if there is not a lightweight task.
ompt_lw_taskteam_t *lwt = __ompt_lw_taskteam_unlink(thr);
@@ -509,7 +509,7 @@ xexpand(KMP_API_NAME_GOMP_PARALLEL_END)(
// remaining deepest task knows the stack frame where the runtime
// was reentered.
ompt_frame = __ompt_get_task_frame_internal(0);
- ompt_frame->reenter_runtime_frame = __builtin_frame_address(0);
+ ompt_frame->reenter_runtime_frame = __builtin_frame_address(1);
}
#endif
}
@@ -525,7 +525,7 @@ xexpand(KMP_API_NAME_GOMP_PARALLEL_END)(
// Set reenter frame in parent task, which will become current task
// in the midst of join. This is needed before the end_parallel callback.
ompt_frame = __ompt_get_task_frame_internal(1);
- ompt_frame->reenter_runtime_frame = __builtin_frame_address(0);
+ ompt_frame->reenter_runtime_frame = __builtin_frame_address(1);
}
#endif
@@ -555,7 +555,7 @@ xexpand(KMP_API_NAME_GOMP_PARALLEL_END)(
if (ompt_enabled) {
// Record that we re-entered the runtime system in the frame that
// created the parallel region.
- ompt_frame->reenter_runtime_frame = __builtin_frame_address(0);
+ ompt_frame->reenter_runtime_frame = __builtin_frame_address(1);
if (ompt_callbacks.ompt_callback(ompt_event_parallel_end)) {
ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
@@ -898,7 +898,7 @@ LOOP_NEXT_ULL(xexpand(KMP_API_NAME_GOMP_
ompt_frame_t *parent_frame; \
if (ompt_enabled) { \
parent_frame = __ompt_get_task_frame_internal(0); \
- parent_frame->reenter_runtime_frame = __builtin_frame_address(0); \
+ parent_frame->reenter_runtime_frame = __builtin_frame_address(1); \
}
@@ -1002,7 +1002,7 @@ xexpand(KMP_API_NAME_GOMP_TASK)(void (*f
#if OMPT_SUPPORT
if (ompt_enabled) {
thread->th.ompt_thread_info = oldInfo;
- taskdata->ompt_task_info.frame.exit_runtime_frame = 0;
+ taskdata->ompt_task_info.frame.exit_runtime_frame = NULL;
}
#endif
}
@@ -1101,7 +1101,7 @@ xexpand(KMP_API_NAME_GOMP_PARALLEL_SECTI
if (ompt_enabled) {
parent_frame = __ompt_get_task_frame_internal(0);
- parent_frame->reenter_runtime_frame = __builtin_frame_address(0);
+ parent_frame->reenter_runtime_frame = __builtin_frame_address(1);
}
#endif
Modified: openmp/trunk/runtime/src/kmp_runtime.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_runtime.c?rev=281464&r1=281463&r2=281464&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_runtime.c (original)
+++ openmp/trunk/runtime/src/kmp_runtime.c Wed Sep 14 08:59:13 2016
@@ -1550,7 +1550,7 @@ __kmp_fork_call(
#if OMPT_SUPPORT
if (ompt_enabled) {
#if OMPT_TRACE
- lw_taskteam.ompt_task_info.frame.exit_runtime_frame = 0;
+ lw_taskteam.ompt_task_info.frame.exit_runtime_frame = NULL;
if (ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)) {
ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)(
@@ -1746,7 +1746,7 @@ __kmp_fork_call(
#if OMPT_SUPPORT
if (ompt_enabled) {
- lw_taskteam.ompt_task_info.frame.exit_runtime_frame = 0;
+ lw_taskteam.ompt_task_info.frame.exit_runtime_frame = NULL;
#if OMPT_TRACE
if (ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)) {
@@ -1853,7 +1853,7 @@ __kmp_fork_call(
#if OMPT_SUPPORT
if (ompt_enabled) {
#if OMPT_TRACE
- lw_taskteam.ompt_task_info.frame.exit_runtime_frame = 0;
+ lw_taskteam.ompt_task_info.frame.exit_runtime_frame = NULL;
if (ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)) {
ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)(
@@ -1885,7 +1885,7 @@ __kmp_fork_call(
unwrapped_task, ompt_parallel_id);
lwt->ompt_task_info.task_id = __ompt_task_id_new(gtid);
- lwt->ompt_task_info.frame.exit_runtime_frame = 0;
+ lwt->ompt_task_info.frame.exit_runtime_frame = NULL;
__ompt_lw_taskteam_link(lwt, master_th);
#endif
@@ -2434,7 +2434,7 @@ __kmp_join_call(ident_t *loc, int gtid
ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)(
parallel_id, task_info->task_id);
}
- task_info->frame.exit_runtime_frame = 0;
+ task_info->frame.exit_runtime_frame = NULL;
task_info->task_id = 0;
}
#endif
@@ -5503,7 +5503,7 @@ __kmp_launch_thread( kmp_info_t *this_th
#if OMPT_SUPPORT
if (ompt_enabled) {
/* no frame set while outside task */
- task_info->frame.exit_runtime_frame = 0;
+ task_info->frame.exit_runtime_frame = NULL;
this_thr->th.ompt_thread_info.state = ompt_state_overhead;
}
@@ -5522,7 +5522,7 @@ __kmp_launch_thread( kmp_info_t *this_th
ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)(
my_parallel_id, task_info->task_id);
}
- task_info->frame.exit_runtime_frame = 0;
+ task_info->frame.exit_runtime_frame = NULL;
task_info->task_id = 0;
}
#endif
Modified: openmp/trunk/runtime/src/kmp_tasking.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_tasking.c?rev=281464&r1=281463&r2=281464&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_tasking.c (original)
+++ openmp/trunk/runtime/src/kmp_tasking.c Wed Sep 14 08:59:13 2016
@@ -1258,7 +1258,7 @@ __kmp_invoke_task( kmp_int32 gtid, kmp_t
#if OMPT_SUPPORT
if (ompt_enabled) {
thread->th.ompt_thread_info = oldInfo;
- taskdata->ompt_task_info.frame.exit_runtime_frame = 0;
+ taskdata->ompt_task_info.frame.exit_runtime_frame = NULL;
}
#endif
@@ -1334,7 +1334,7 @@ __kmp_omp_task( kmp_int32 gtid, kmp_task
#if OMPT_SUPPORT
if (ompt_enabled) {
new_taskdata->ompt_task_info.frame.reenter_runtime_frame =
- __builtin_frame_address(0);
+ __builtin_frame_address(1);
}
#endif
@@ -1354,7 +1354,7 @@ __kmp_omp_task( kmp_int32 gtid, kmp_task
#if OMPT_SUPPORT
if (ompt_enabled) {
- new_taskdata->ompt_task_info.frame.reenter_runtime_frame = 0;
+ new_taskdata->ompt_task_info.frame.reenter_runtime_frame = NULL;
}
#endif
@@ -1419,7 +1419,7 @@ __kmpc_omp_taskwait( ident_t *loc_ref, k
my_task_id = taskdata->ompt_task_info.task_id;
my_parallel_id = team->t.ompt_team_info.parallel_id;
- taskdata->ompt_task_info.frame.reenter_runtime_frame = __builtin_frame_address(0);
+ taskdata->ompt_task_info.frame.reenter_runtime_frame = __builtin_frame_address(1);
if (ompt_callbacks.ompt_callback(ompt_event_taskwait_begin)) {
ompt_callbacks.ompt_callback(ompt_event_taskwait_begin)(
my_parallel_id, my_task_id);
@@ -1469,7 +1469,7 @@ __kmpc_omp_taskwait( ident_t *loc_ref, k
ompt_callbacks.ompt_callback(ompt_event_taskwait_end)(
my_parallel_id, my_task_id);
}
- taskdata->ompt_task_info.frame.reenter_runtime_frame = 0;
+ taskdata->ompt_task_info.frame.reenter_runtime_frame = NULL;
}
#endif
}
Modified: openmp/trunk/runtime/src/ompt-specific.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/ompt-specific.c?rev=281464&r1=281463&r2=281464&view=diff
==============================================================================
--- openmp/trunk/runtime/src/ompt-specific.c (original)
+++ openmp/trunk/runtime/src/ompt-specific.c Wed Sep 14 08:59:13 2016
@@ -257,8 +257,8 @@ __ompt_lw_taskteam_init(ompt_lw_taskteam
lwt->ompt_team_info.parallel_id = ompt_pid;
lwt->ompt_team_info.microtask = microtask;
lwt->ompt_task_info.task_id = 0;
- lwt->ompt_task_info.frame.reenter_runtime_frame = 0;
- lwt->ompt_task_info.frame.exit_runtime_frame = 0;
+ lwt->ompt_task_info.frame.reenter_runtime_frame = NULL;
+ lwt->ompt_task_info.frame.exit_runtime_frame = NULL;
lwt->ompt_task_info.function = NULL;
lwt->parent = 0;
}
Modified: openmp/trunk/runtime/test/ompt/parallel/nested.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/parallel/nested.c?rev=281464&r1=281463&r2=281464&view=diff
==============================================================================
--- openmp/trunk/runtime/test/ompt/parallel/nested.c (original)
+++ openmp/trunk/runtime/test/ompt/parallel/nested.c Wed Sep 14 08:59:13 2016
@@ -7,16 +7,22 @@
int main()
{
omp_set_nested(1);
+ print_frame(0);
#pragma omp parallel num_threads(4)
{
+ print_frame(1);
print_ids(0);
print_ids(1);
+ print_frame(0);
#pragma omp parallel num_threads(4)
{
+ print_frame(1);
print_ids(0);
print_ids(1);
print_ids(2);
+ print_frame(0);
+ #pragma omp barrier
}
}
@@ -40,18 +46,23 @@ int main()
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_parallel_end: parallel_id=[[PARALLEL_ID]], task_id=[[PARENT_TASK_ID]], invoker=[[PARALLEL_INVOKER]]
- // THREADS: 0: NULL_POINTER=[[NULL:.*$]]
- // THREADS: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_parallel_begin: parent_task_id=[[PARENT_TASK_ID:[0-9]+]], parent_task_frame.exit=[[NULL]], parent_task_frame.reenter={{0x[0-f]+}}, parallel_id=[[PARALLEL_ID:[0-9]+]], requested_team_size=4, parallel_function=0x{{[0-f]+}}, invoker=[[PARALLEL_INVOKER:.+]]
+ // THREADS: {{^}}0: NULL_POINTER=[[NULL:.*$]]
+ // THREADS: {{^}}[[MASTER_ID:[0-9]+]]: __builtin_frame_address(0)=[[MAIN_REENTER:0x[0-f]+]]
+ // THREADS: {{^}}[[MASTER_ID]]: ompt_event_parallel_begin: parent_task_id=[[PARENT_TASK_ID:[0-9]+]], parent_task_frame.exit=[[NULL]], parent_task_frame.reenter=[[MAIN_REENTER]], parallel_id=[[PARALLEL_ID:[0-9]+]], requested_team_size=4, parallel_function=0x{{[0-f]+}}, invoker=[[PARALLEL_INVOKER:.+]]
// nested parallel masters
// THREADS: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
- // THREADS: {{^}}[[MASTER_ID]]: level 0: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
- // THREADS: {{^}}[[MASTER_ID]]: level 1: parallel_id=0, task_id=[[PARENT_TASK_ID]]
- // THREADS: {{^}}[[MASTER_ID]]: ompt_event_parallel_begin: parent_task_id=[[IMPLICIT_TASK_ID]], parent_task_frame.exit={{0x[0-f]+}}, parent_task_frame.reenter={{0x[0-f]+}}, parallel_id=[[NESTED_PARALLEL_ID:[0-9]+]], requested_team_size=4, parallel_function=[[NESTED_PARALLEL_FUNCTION:0x[0-f]+]], invoker=[[PARALLEL_INVOKER]]
+ // THREADS: {{^}}[[MASTER_ID]]: __builtin_frame_address(1)=[[EXIT:0x[0-f]+]]
+ // THREADS: {{^}}[[MASTER_ID]]: level 0: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]], exit_frame=[[EXIT]], reenter_frame=[[NULL]]
+ // THREADS: {{^}}[[MASTER_ID]]: level 1: parallel_id=0, task_id=[[PARENT_TASK_ID]], exit_frame=[[NULL]], reenter_frame=[[MAIN_REENTER]]
+ // THREADS: {{^}}[[MASTER_ID]]: __builtin_frame_address(0)=[[REENTER:0x[0-f]+]]
+ // THREADS: {{^}}[[MASTER_ID]]: ompt_event_parallel_begin: parent_task_id=[[IMPLICIT_TASK_ID]], parent_task_frame.exit=[[EXIT]], parent_task_frame.reenter=[[REENTER]], parallel_id=[[NESTED_PARALLEL_ID:[0-9]+]], requested_team_size=4, parallel_function=[[NESTED_PARALLEL_FUNCTION:0x[0-f]+]], invoker=[[PARALLEL_INVOKER]]
// THREADS: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin: parallel_id=[[NESTED_PARALLEL_ID]], task_id=[[NESTED_IMPLICIT_TASK_ID:[0-9]+]]
- // THREADS: {{^}}[[MASTER_ID]]: level 0: parallel_id=[[NESTED_PARALLEL_ID]], task_id=[[NESTED_IMPLICIT_TASK_ID]]
- // THREADS: {{^}}[[MASTER_ID]]: level 1: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
- // THREADS: {{^}}[[MASTER_ID]]: level 2: parallel_id=0, task_id=[[PARENT_TASK_ID]]
+ // THREADS: {{^}}[[MASTER_ID]]: __builtin_frame_address(1)=[[NESTED_EXIT:0x[0-f]+]]
+ // THREADS: {{^}}[[MASTER_ID]]: level 0: parallel_id=[[NESTED_PARALLEL_ID]], task_id=[[NESTED_IMPLICIT_TASK_ID]], exit_frame=[[NESTED_EXIT]], reenter_frame=[[NULL]]
+ // THREADS: {{^}}[[MASTER_ID]]: level 1: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]], exit_frame=[[EXIT]], reenter_frame=[[REENTER]]
+ // THREADS: {{^}}[[MASTER_ID]]: level 2: parallel_id=0, task_id=[[PARENT_TASK_ID]], exit_frame=[[NULL]], reenter_frame=[[MAIN_REENTER]]
+ // THREADS: {{^}}[[MASTER_ID]]: __builtin_frame_address(0)=[[NESTED_REENTER:0x[0-f]+]]
// THREADS-NOT: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end
// THREADS: {{^}}[[MASTER_ID]]: ompt_event_barrier_begin: parallel_id=[[NESTED_PARALLEL_ID]], task_id=[[NESTED_IMPLICIT_TASK_ID]]
// THREADS: {{^}}[[MASTER_ID]]: ompt_event_barrier_end: parallel_id=[[NESTED_PARALLEL_ID]], task_id=[[NESTED_IMPLICIT_TASK_ID]]
More information about the Openmp-commits
mailing list