Skip to content

Commit f20f03a

Browse files
committed
Merge branch 'scheduling_parent' into ompd
Conflicts: runtime/src/kmp_csupport.c
2 parents 83b6181 + e529152 commit f20f03a

File tree

9 files changed

+101
-10
lines changed

9 files changed

+101
-10
lines changed

runtime/src/include/45/ompt.h.var

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
\
2626
macro (ompt_get_idle_frame) \
2727
macro (ompt_get_task_frame) \
28+
macro (ompt_get_scheduling_task_frame) \
2829
\
2930
macro (ompt_get_state) \
3031
\
@@ -408,6 +409,10 @@ OMPT_API_FUNCTION(ompt_frame_t *, ompt_get_task_frame, (
408409
int depth
409410
));
410411

412+
OMPT_API_FUNCTION(ompt_frame_t *, ompt_get_scheduling_task_frame, (
413+
int depth
414+
));
415+
411416

412417

413418
/****************************************************************************

runtime/src/kmp_csupport.c

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,20 @@ __kmpc_fork_call(ident_t *loc, kmp_int32 argc, kmpc_micro microtask, ...)
301301
va_start( ap, microtask );
302302

303303
#if OMPT_SUPPORT
304-
int tid = __kmp_tid_from_gtid( gtid );
305-
kmp_info_t *master_th = __kmp_threads[ gtid ];
306-
kmp_team_t *parent_team = master_th->th.th_team;
304+
ompt_frame_t* ompt_frame;
307305
if (ompt_enabled) {
308-
parent_team->t.t_implicit_task_taskdata[tid].
309-
ompt_task_info.frame.reenter_runtime_frame = __builtin_frame_address(1);
306+
kmp_info_t *master_th = __kmp_threads[ gtid ];
307+
kmp_team_t *parent_team = master_th->th.th_team;
308+
ompt_lw_taskteam_t *lwt = parent_team->t.ompt_serialized_team_info;
309+
if (lwt)
310+
ompt_frame = &(lwt->ompt_task_info.frame);
311+
else
312+
{
313+
int tid = __kmp_tid_from_gtid( gtid );
314+
ompt_frame = &(parent_team->t.t_implicit_task_taskdata[tid].
315+
ompt_task_info.frame);
316+
}
317+
ompt_frame->reenter_runtime_frame = __builtin_frame_address(1);
310318
}
311319
#endif
312320

@@ -340,8 +348,7 @@ __kmpc_fork_call(ident_t *loc, kmp_int32 argc, kmpc_micro microtask, ...)
340348

341349
#if OMPT_SUPPORT
342350
if (ompt_enabled) {
343-
parent_team->t.t_implicit_task_taskdata[tid].
344-
ompt_task_info.frame.reenter_runtime_frame = 0;
351+
ompt_frame->reenter_runtime_frame = NULL;
345352
}
346353
#endif
347354
}
@@ -678,6 +685,14 @@ __kmpc_barrier(ident_t *loc, kmp_int32 global_tid)
678685
__kmp_check_barrier( global_tid, ct_barrier, loc );
679686
}
680687

688+
#if OMPT_SUPPORT && OMPT_TRACE
689+
ompt_frame_t * ompt_frame;
690+
if (ompt_enabled ) {
691+
ompt_frame = &( __kmp_threads[ global_tid ] -> th.th_team ->
692+
t.t_implicit_task_taskdata[__kmp_tid_from_gtid(global_tid)].ompt_task_info.frame);
693+
ompt_frame->reenter_runtime_frame = __builtin_frame_address(1);
694+
}
695+
#endif
681696
__kmp_threads[ global_tid ]->th.th_ident = loc;
682697
// TODO: explicit barrier_wait_id:
683698
// this function is called when 'barrier' directive is present or
@@ -687,6 +702,11 @@ __kmpc_barrier(ident_t *loc, kmp_int32 global_tid)
687702
// 4) no sync is required
688703

689704
__kmp_barrier( bs_plain_barrier, global_tid, FALSE, 0, NULL, NULL );
705+
#if OMPT_SUPPORT && OMPT_TRACE
706+
if (ompt_enabled ) {
707+
ompt_frame->reenter_runtime_frame = NULL;
708+
}
709+
#endif
690710
}
691711

692712
/* The BARRIER for a MASTER section is always explicit */

runtime/src/kmp_runtime.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,9 @@ __kmp_fork_call(
15581558
, exit_runtime_p
15591559
#endif
15601560
);
1561+
#if OMPT_SUPPORT
1562+
*exit_runtime_p=0;
1563+
#endif
15611564
}
15621565

15631566
#if OMPT_SUPPORT
@@ -1760,6 +1763,9 @@ __kmp_fork_call(
17601763
, exit_runtime_p
17611764
#endif
17621765
);
1766+
#if OMPT_SUPPORT
1767+
*exit_runtime_p=0;
1768+
#endif
17631769
}
17641770

17651771
#if OMPT_SUPPORT
@@ -1867,6 +1873,9 @@ __kmp_fork_call(
18671873
, exit_runtime_p
18681874
#endif
18691875
);
1876+
#if OMPT_SUPPORT
1877+
*exit_runtime_p=0;
1878+
#endif
18701879
}
18711880

18721881
#if OMPT_SUPPORT
@@ -6844,6 +6853,9 @@ __kmp_invoke_task_func( int gtid )
68446853
, exit_runtime_p
68456854
#endif
68466855
);
6856+
#if OMPT_SUPPORT
6857+
*exit_runtime_p=0;
6858+
#endif
68476859
}
68486860

68496861
#if USE_ITT_BUILD

runtime/src/kmp_tasking.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,9 @@ __kmp_task_start( kmp_int32 gtid, kmp_task_t * task, kmp_taskdata_t * current_ta
458458
taskdata->ompt_task_info.task_id,
459459
taskdata->ompt_task_info.function);
460460
}
461+
if (ompt_enabled)
462+
taskdata->ompt_task_info.scheduling_parent = current_task;
463+
461464
#endif
462465
#if OMP_40_ENABLED && OMPT_SUPPORT && OMPT_TRACE
463466
/* OMPT emit all dependences if requested by the tool */

runtime/src/ompd-specific.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const char * * ompd_dll_locations=NULL;
2626
const char * ompd_my_dll_locations[2] = {"libompd_intel.so",NULL};
2727
uint64_t ompd_state=0;
2828

29-
int ompd_rtl_version = 6;
29+
int ompd_rtl_version = 7;
3030

3131
void ompd_init()
3232
{

runtime/src/ompd-specific.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ OMPD_ACCESS(kmp_base_info_t, ompt_thread_info) \
3434
OMPD_ACCESS(kmp_base_root_t, r_in_parallel) \
3535
\
3636
OMPD_ACCESS(kmp_base_team_t, ompt_team_info) \
37+
OMPD_ACCESS(kmp_base_team_t, ompt_serialized_team_info) \
3738
OMPD_ACCESS(kmp_base_team_t, t_active_level) \
3839
OMPD_ACCESS(kmp_base_team_t, t_implicit_task_taskdata) \
3940
OMPD_ACCESS(kmp_base_team_t, t_master_tid) \
@@ -71,6 +72,7 @@ OMPD_ACCESS(kmp_taskdata_t, td_team) \
7172
OMPD_ACCESS(kmp_team_p, t) \
7273
\
7374
OMPD_ACCESS(ompt_task_info_t, frame) \
75+
OMPD_ACCESS(ompt_task_info_t, scheduling_parent) \
7476
OMPD_ACCESS(ompt_task_info_t, task_id) \
7577
OMPD_ACCESS(ompt_task_info_t, function) \
7678
\
@@ -82,6 +84,10 @@ OMPD_ACCESS(ompt_thread_info_t, wait_id) \
8284
\
8385
OMPD_ACCESS(ompt_frame_t, reenter_runtime_frame) \
8486
OMPD_ACCESS(ompt_frame_t, exit_runtime_frame) \
87+
\
88+
OMPD_ACCESS(ompt_lw_taskteam_t, parent) \
89+
OMPD_ACCESS(ompt_lw_taskteam_t, ompt_team_info) \
90+
OMPD_ACCESS(ompt_lw_taskteam_t, ompt_task_info)
8591

8692

8793
#define OMPD_FOREACH_BITFIELD(OMPD_BITFIELD) \

runtime/src/ompt-general.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,11 @@ OMPT_API_ROUTINE ompt_frame_t *ompt_get_task_frame(int depth)
421421
return __ompt_get_task_frame_internal(depth);
422422
}
423423

424+
OMPT_API_ROUTINE ompt_frame_t *ompt_get_scheduling_task_frame(int depth)
425+
{
426+
return __ompt_get_scheduling_task_frame_internal(depth);
427+
}
428+
424429

425430
OMPT_API_ROUTINE void *ompt_get_task_function(int depth)
426431
{

runtime/src/ompt-internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ typedef struct ompt_callbacks_s {
2323
#undef ompt_event_macro
2424
} ompt_callbacks_t;
2525

26-
26+
typedef struct kmp_taskdata kmp_taskdata_t;
2727

2828
typedef struct {
2929
ompt_frame_t frame;
3030
void* function;
3131
ompt_task_id_t task_id;
32+
kmp_taskdata_t * scheduling_parent;
3233
#if OMP_40_ENABLED
3334
int ndeps;
3435
ompt_task_dependence_t *deps;

runtime/src/ompt-specific.c

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ __ompt_get_teaminfo(int depth, int *size)
6060

6161
// next heavyweight team (if any) after
6262
// lightweight teams are exhausted
63-
if (!lwt && team) team=team->t.t_parent;
63+
if (!lwt && team) {
64+
team=team->t.t_parent;
65+
if (team) {
66+
lwt = LWT_FROM_TEAM(team);
67+
}
68+
}
6469

6570
depth--;
6671
}
@@ -119,6 +124,32 @@ __ompt_get_taskinfo(int depth)
119124
return info;
120125
}
121126

127+
ompt_task_info_t *
128+
__ompt_get_scheduling_taskinfo(int depth)
129+
{
130+
ompt_task_info_t *info = NULL;
131+
kmp_info_t *thr = ompt_get_thread();
132+
133+
if (thr) {
134+
kmp_taskdata_t *taskdata = thr->th.th_current_task;
135+
// ompt_lw_taskteam_t *lwt = LWT_FROM_TEAM(taskdata->td_team);
136+
137+
while (depth > 0) {
138+
139+
if (taskdata) {
140+
taskdata = taskdata->ompt_task_info.scheduling_parent;
141+
}else{
142+
return NULL;
143+
}
144+
depth--;
145+
}
146+
147+
info = &taskdata->ompt_task_info;
148+
}
149+
150+
return info;
151+
}
152+
122153

123154

124155
//******************************************************************************
@@ -320,6 +351,14 @@ __ompt_get_task_frame_internal(int depth)
320351
return frame;
321352
}
322353

354+
ompt_frame_t *
355+
__ompt_get_scheduling_task_frame_internal(int depth)
356+
{
357+
ompt_task_info_t *info = __ompt_get_scheduling_taskinfo(depth);
358+
ompt_frame_t *frame = info ? frame = &info->frame : NULL;
359+
return frame;
360+
}
361+
323362

324363
//----------------------------------------------------------
325364
// team support

0 commit comments

Comments
 (0)