summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/src
diff options
context:
space:
mode:
authorHansang Bae <hansang.bae@intel.com>2019-08-03 02:38:53 +0000
committerHansang Bae <hansang.bae@intel.com>2019-08-03 02:38:53 +0000
commit67e93a1ae00f10450bfc1cfc1ca78498712f4b1f (patch)
tree88a72274b190dd17f608215b42fe2827b82f32b3 /openmp/runtime/src
parent25ab1c6471ff5f447ca75c66e6abee31620bcc03 (diff)
downloadbcm5719-llvm-67e93a1ae00f10450bfc1cfc1ca78498712f4b1f.tar.gz
bcm5719-llvm-67e93a1ae00f10450bfc1cfc1ca78498712f4b1f.zip
Add OMPT support for teams construct
This change adds OMPT support for events from teams construct. Differential Revision: https://reviews.llvm.org/D64025 llvm-svn: 367746
Diffstat (limited to 'openmp/runtime/src')
-rw-r--r--openmp/runtime/src/kmp_csupport.cpp3
-rw-r--r--openmp/runtime/src/kmp_runtime.cpp160
-rw-r--r--openmp/runtime/src/kmp_wait_release.h5
-rw-r--r--openmp/runtime/src/ompt-internal.h1
-rw-r--r--openmp/runtime/src/ompt-specific.cpp7
-rw-r--r--openmp/runtime/src/ompt-specific.h2
6 files changed, 129 insertions, 49 deletions
diff --git a/openmp/runtime/src/kmp_csupport.cpp b/openmp/runtime/src/kmp_csupport.cpp
index ec3252ebbcd..d39bf9af433 100644
--- a/openmp/runtime/src/kmp_csupport.cpp
+++ b/openmp/runtime/src/kmp_csupport.cpp
@@ -545,7 +545,8 @@ void __kmpc_end_serialized_parallel(ident_t *loc, kmp_int32 global_tid) {
if (ompt_enabled.ompt_callback_parallel_end) {
ompt_callbacks.ompt_callback(ompt_callback_parallel_end)(
&(serial_team->t.ompt_team_info.parallel_data), parent_task_data,
- ompt_parallel_invoker_program, OMPT_LOAD_RETURN_ADDRESS(global_tid));
+ ompt_parallel_invoker_program | ompt_parallel_team,
+ OMPT_LOAD_RETURN_ADDRESS(global_tid));
}
__ompt_lw_taskteam_unlink(this_thr);
this_thr->th.ompt_thread_info.state = ompt_state_overhead;
diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp
index 684dc50e8b7..bec87a6ee2e 100644
--- a/openmp/runtime/src/kmp_runtime.cpp
+++ b/openmp/runtime/src/kmp_runtime.cpp
@@ -1190,8 +1190,8 @@ void __kmp_serialized_parallel(ident_t *loc, kmp_int32 global_tid) {
ompt_callbacks.ompt_callback(ompt_callback_parallel_begin)(
&(parent_task_info->task_data), &(parent_task_info->frame),
- &ompt_parallel_data, team_size, ompt_parallel_invoker_program,
- codeptr);
+ &ompt_parallel_data, team_size,
+ ompt_parallel_invoker_program | ompt_parallel_team, codeptr);
}
}
#endif // OMPT_SUPPORT
@@ -1481,9 +1481,13 @@ int __kmp_fork_call(ident_t *loc, int gtid,
int team_size = master_set_numthreads
? master_set_numthreads
: get__nproc_2(parent_team, master_tid);
+ int flags = OMPT_INVOKER(call_context) |
+ ((microtask == (microtask_t)__kmp_teams_master)
+ ? ompt_parallel_league
+ : ompt_parallel_team);
ompt_callbacks.ompt_callback(ompt_callback_parallel_begin)(
- parent_task_data, ompt_frame, &ompt_parallel_data, team_size,
- OMPT_INVOKER(call_context), return_address);
+ parent_task_data, ompt_frame, &ompt_parallel_data, team_size, flags,
+ return_address);
}
master_th->th.ompt_thread_info.state = ompt_state_overhead;
}
@@ -1512,9 +1516,7 @@ int __kmp_fork_call(ident_t *loc, int gtid,
// AC: we are in serialized parallel
__kmpc_serialized_parallel(loc, gtid);
KMP_DEBUG_ASSERT(parent_team->t.t_serialized > 1);
- // AC: need this in order enquiry functions work
- // correctly, will restore at join time
- parent_team->t.t_serialized--;
+
#if OMPT_SUPPORT
void *dummy;
void **exit_frame_p;
@@ -1532,11 +1534,12 @@ int __kmp_fork_call(ident_t *loc, int gtid,
/* OMPT implicit task begin */
implicit_task_data = OMPT_CUR_TASK_DATA(master_th);
if (ompt_enabled.ompt_callback_implicit_task) {
- ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
- ompt_scope_begin, OMPT_CUR_TEAM_DATA(master_th),
- implicit_task_data, 1, __kmp_tid_from_gtid(gtid), ompt_task_implicit); // TODO: Can this be ompt_task_initial?
OMPT_CUR_TASK_INFO(master_th)
->thread_num = __kmp_tid_from_gtid(gtid);
+ ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
+ ompt_scope_begin, OMPT_CUR_TEAM_DATA(master_th),
+ implicit_task_data, 1,
+ OMPT_CUR_TASK_INFO(master_th)->thread_num, ompt_task_implicit);
}
/* OMPT state */
@@ -1545,6 +1548,9 @@ int __kmp_fork_call(ident_t *loc, int gtid,
exit_frame_p = &dummy;
}
#endif
+ // AC: need to decrement t_serialized for enquiry functions to work
+ // correctly, will restore at join time
+ parent_team->t.t_serialized--;
{
KMP_TIME_PARTITIONED_BLOCK(OMP_parallel);
@@ -1564,14 +1570,15 @@ int __kmp_fork_call(ident_t *loc, int gtid,
if (ompt_enabled.ompt_callback_implicit_task) {
ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
ompt_scope_end, NULL, implicit_task_data, 1,
- OMPT_CUR_TASK_INFO(master_th)->thread_num, ompt_task_implicit); // TODO: Can this be ompt_task_initial?
+ OMPT_CUR_TASK_INFO(master_th)->thread_num, ompt_task_implicit);
}
+ ompt_parallel_data = *OMPT_CUR_TEAM_DATA(master_th);
__ompt_lw_taskteam_unlink(master_th);
-
if (ompt_enabled.ompt_callback_parallel_end) {
ompt_callbacks.ompt_callback(ompt_callback_parallel_end)(
- OMPT_CUR_TEAM_DATA(master_th), OMPT_CUR_TASK_DATA(master_th),
- OMPT_INVOKER(call_context), return_address);
+ &ompt_parallel_data, OMPT_CUR_TASK_DATA(master_th),
+ OMPT_INVOKER(call_context) | ompt_parallel_team,
+ return_address);
}
master_th->th.ompt_thread_info.state = ompt_state_overhead;
}
@@ -1586,6 +1593,15 @@ int __kmp_fork_call(ident_t *loc, int gtid,
parent_team->t.t_level++;
parent_team->t.t_def_allocator = master_th->th.th_def_allocator; // save
+#if OMPT_SUPPORT
+ if (ompt_enabled.enabled) {
+ ompt_lw_taskteam_t lw_taskteam;
+ __ompt_lw_taskteam_init(&lw_taskteam, master_th, gtid,
+ &ompt_parallel_data, return_address);
+ __ompt_lw_taskteam_link(&lw_taskteam, master_th, 1, true);
+ }
+#endif
+
/* Change number of threads in the team if requested */
if (master_set_numthreads) { // The parallel has num_threads clause
if (master_set_numthreads < master_th->th.th_teams_size.nth) {
@@ -1729,11 +1745,13 @@ int __kmp_fork_call(ident_t *loc, int gtid,
task_info = OMPT_CUR_TASK_INFO(master_th);
exit_frame_p = &(task_info->frame.exit_frame.ptr);
if (ompt_enabled.ompt_callback_implicit_task) {
- ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
- ompt_scope_begin, OMPT_CUR_TEAM_DATA(master_th),
- &(task_info->task_data), 1, __kmp_tid_from_gtid(gtid), ompt_task_implicit); // TODO: Can this be ompt_task_initial?
OMPT_CUR_TASK_INFO(master_th)
->thread_num = __kmp_tid_from_gtid(gtid);
+ ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
+ ompt_scope_begin, OMPT_CUR_TEAM_DATA(master_th),
+ &(task_info->task_data), 1,
+ OMPT_CUR_TASK_INFO(master_th)->thread_num,
+ ompt_task_implicit);
}
/* OMPT state */
@@ -1761,14 +1779,16 @@ int __kmp_fork_call(ident_t *loc, int gtid,
if (ompt_enabled.ompt_callback_implicit_task) {
ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
ompt_scope_end, NULL, &(task_info->task_data), 1,
- OMPT_CUR_TASK_INFO(master_th)->thread_num, ompt_task_implicit); // TODO: Can this be ompt_task_initial?
+ OMPT_CUR_TASK_INFO(master_th)->thread_num,
+ ompt_task_implicit);
}
-
+ ompt_parallel_data = *OMPT_CUR_TEAM_DATA(master_th);
__ompt_lw_taskteam_unlink(master_th);
if (ompt_enabled.ompt_callback_parallel_end) {
ompt_callbacks.ompt_callback(ompt_callback_parallel_end)(
- OMPT_CUR_TEAM_DATA(master_th), parent_task_data,
- OMPT_INVOKER(call_context), return_address);
+ &ompt_parallel_data, parent_task_data,
+ OMPT_INVOKER(call_context) | ompt_parallel_team,
+ return_address);
}
master_th->th.ompt_thread_info.state = ompt_state_overhead;
}
@@ -1800,6 +1820,23 @@ int __kmp_fork_call(ident_t *loc, int gtid,
team->t.t_level--;
// AC: call special invoker for outer "parallel" of teams construct
invoker(gtid);
+#if OMPT_SUPPORT
+ if (ompt_enabled.enabled) {
+ ompt_task_info_t *task_info = OMPT_CUR_TASK_INFO(master_th);
+ if (ompt_enabled.ompt_callback_implicit_task) {
+ ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
+ ompt_scope_end, NULL, &(task_info->task_data), 0,
+ OMPT_CUR_TASK_INFO(master_th)->thread_num, ompt_task_initial);
+ }
+ if (ompt_enabled.ompt_callback_parallel_end) {
+ ompt_callbacks.ompt_callback(ompt_callback_parallel_end)(
+ &ompt_parallel_data, parent_task_data,
+ OMPT_INVOKER(call_context) | ompt_parallel_league,
+ return_address);
+ }
+ master_th->th.ompt_thread_info.state = ompt_state_overhead;
+ }
+#endif
} else {
argv = args;
for (i = argc - 1; i >= 0; --i)
@@ -1831,7 +1868,8 @@ int __kmp_fork_call(ident_t *loc, int gtid,
if (ompt_enabled.ompt_callback_implicit_task) {
ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
ompt_scope_begin, OMPT_CUR_TEAM_DATA(master_th),
- implicit_task_data, 1, __kmp_tid_from_gtid(gtid), ompt_task_implicit); // TODO: Can this be ompt_task_initial?
+ implicit_task_data, 1, __kmp_tid_from_gtid(gtid),
+ ompt_task_implicit);
OMPT_CUR_TASK_INFO(master_th)
->thread_num = __kmp_tid_from_gtid(gtid);
}
@@ -1860,7 +1898,8 @@ int __kmp_fork_call(ident_t *loc, int gtid,
if (ompt_enabled.ompt_callback_implicit_task) {
ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
ompt_scope_end, NULL, &(task_info->task_data), 1,
- OMPT_CUR_TASK_INFO(master_th)->thread_num, ompt_task_implicit); // TODO: Can this be ompt_task_initial?
+ OMPT_CUR_TASK_INFO(master_th)->thread_num,
+ ompt_task_implicit);
}
ompt_parallel_data = *OMPT_CUR_TEAM_DATA(master_th);
@@ -1868,7 +1907,8 @@ int __kmp_fork_call(ident_t *loc, int gtid,
if (ompt_enabled.ompt_callback_parallel_end) {
ompt_callbacks.ompt_callback(ompt_callback_parallel_end)(
&ompt_parallel_data, parent_task_data,
- OMPT_INVOKER(call_context), return_address);
+ OMPT_INVOKER(call_context) | ompt_parallel_team,
+ return_address);
}
master_th->th.ompt_thread_info.state = ompt_state_overhead;
}
@@ -2225,12 +2265,11 @@ static inline void __kmp_join_restore_state(kmp_info_t *thread,
static inline void __kmp_join_ompt(int gtid, kmp_info_t *thread,
kmp_team_t *team, ompt_data_t *parallel_data,
- fork_context_e fork_context, void *codeptr) {
+ int flags, void *codeptr) {
ompt_task_info_t *task_info = __ompt_get_task_info_object(0);
if (ompt_enabled.ompt_callback_parallel_end) {
ompt_callbacks.ompt_callback(ompt_callback_parallel_end)(
- parallel_data, &(task_info->task_data), OMPT_INVOKER(fork_context),
- codeptr);
+ parallel_data, &(task_info->task_data), flags, codeptr);
}
task_info->frame.enter_frame = ompt_data_none;
@@ -2263,6 +2302,7 @@ void __kmp_join_call(ident_t *loc, int gtid
master_th->th.th_ident = loc;
#if OMPT_SUPPORT
+ void *team_microtask = (void *)team->t.t_pkfn;
if (ompt_enabled.enabled) {
master_th->th.ompt_thread_info.state = ompt_state_overhead;
}
@@ -2352,10 +2392,25 @@ void __kmp_join_call(ident_t *loc, int gtid
if (master_th->th.th_teams_microtask && !exit_teams &&
team->t.t_pkfn != (microtask_t)__kmp_teams_master &&
team->t.t_level == master_th->th.th_teams_level + 1) {
- // AC: We need to leave the team structure intact at the end of parallel
- // inside the teams construct, so that at the next parallel same (hot) team
- // works, only adjust nesting levels
-
+// AC: We need to leave the team structure intact at the end of parallel
+// inside the teams construct, so that at the next parallel same (hot) team
+// works, only adjust nesting levels
+#if OMPT_SUPPORT
+ ompt_data_t ompt_parallel_data = ompt_data_none;
+ if (ompt_enabled.enabled) {
+ ompt_task_info_t *task_info = __ompt_get_task_info_object(0);
+ if (ompt_enabled.ompt_callback_implicit_task) {
+ int ompt_team_size = team->t.t_nproc;
+ ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
+ ompt_scope_end, NULL, &(task_info->task_data), ompt_team_size,
+ OMPT_CUR_TASK_INFO(master_th)->thread_num, ompt_task_implicit);
+ }
+ task_info->frame.exit_frame = ompt_data_none;
+ task_info->task_data = ompt_data_none;
+ ompt_parallel_data = *OMPT_CUR_TEAM_DATA(master_th);
+ __ompt_lw_taskteam_unlink(master_th);
+ }
+#endif
/* Decrement our nested depth level */
team->t.t_level--;
team->t.t_active_level--;
@@ -2394,8 +2449,8 @@ void __kmp_join_call(ident_t *loc, int gtid
#if OMPT_SUPPORT
if (ompt_enabled.enabled) {
- __kmp_join_ompt(gtid, master_th, parent_team, parallel_data, fork_context,
- codeptr);
+ __kmp_join_ompt(gtid, master_th, parent_team, &ompt_parallel_data,
+ OMPT_INVOKER(fork_context) | ompt_parallel_team, codeptr);
}
#endif
@@ -2424,12 +2479,14 @@ void __kmp_join_call(ident_t *loc, int gtid
if (ompt_enabled.enabled) {
ompt_task_info_t *task_info = __ompt_get_task_info_object(0);
if (ompt_enabled.ompt_callback_implicit_task) {
- int ompt_team_size = team->t.t_nproc;
+ int flags = (team_microtask == (void *)__kmp_teams_master)
+ ? ompt_task_initial
+ : ompt_task_implicit;
+ int ompt_team_size = (flags == ompt_task_initial) ? 0 : team->t.t_nproc;
ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
ompt_scope_end, NULL, &(task_info->task_data), ompt_team_size,
- OMPT_CUR_TASK_INFO(master_th)->thread_num, ompt_task_implicit); // TODO: Can this be ompt_task_initial?
+ OMPT_CUR_TASK_INFO(master_th)->thread_num, flags);
}
-
task_info->frame.exit_frame = ompt_data_none;
task_info->task_data = ompt_data_none;
}
@@ -2503,8 +2560,12 @@ void __kmp_join_call(ident_t *loc, int gtid
__kmp_release_bootstrap_lock(&__kmp_forkjoin_lock);
#if OMPT_SUPPORT
+ int flags =
+ OMPT_INVOKER(fork_context) |
+ ((team_microtask == (void *)__kmp_teams_master) ? ompt_parallel_league
+ : ompt_parallel_team);
if (ompt_enabled.enabled) {
- __kmp_join_ompt(gtid, master_th, parent_team, parallel_data, fork_context,
+ __kmp_join_ompt(gtid, master_th, parent_team, parallel_data, flags,
codeptr);
}
#endif
@@ -5618,18 +5679,15 @@ void *__kmp_launch_thread(kmp_info_t *this_thr) {
this_thr->th.ompt_thread_info.state = ompt_state_overhead;
this_thr->th.ompt_thread_info.wait_id = 0;
this_thr->th.ompt_thread_info.idle_frame = OMPT_GET_FRAME_ADDRESS(0);
+ this_thr->th.ompt_thread_info.parallel_flags = 0;
if (ompt_enabled.ompt_callback_thread_begin) {
ompt_callbacks.ompt_callback(ompt_callback_thread_begin)(
ompt_thread_worker, thread_data);
}
- }
-#endif
-
-#if OMPT_SUPPORT
- if (ompt_enabled.enabled) {
this_thr->th.ompt_thread_info.state = ompt_state_idle;
}
#endif
+
/* This is the place where threads wait for work */
while (!TCR_4(__kmp_global.g.g_done)) {
KMP_DEBUG_ASSERT(this_thr == __kmp_threads[gtid]);
@@ -6975,7 +7033,7 @@ int __kmp_invoke_task_func(int gtid) {
ompt_team_size = team->t.t_nproc;
ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
ompt_scope_begin, my_parallel_data, my_task_data, ompt_team_size,
- __kmp_tid_from_gtid(gtid), ompt_task_implicit); // TODO: Can this be ompt_task_initial?
+ __kmp_tid_from_gtid(gtid), ompt_task_implicit);
OMPT_CUR_TASK_INFO(this_thr)->thread_num = __kmp_tid_from_gtid(gtid);
}
#endif
@@ -6999,6 +7057,7 @@ int __kmp_invoke_task_func(int gtid) {
);
#if OMPT_SUPPORT
*exit_frame_p = NULL;
+ this_thr->th.ompt_thread_info.parallel_flags |= ompt_parallel_team;
#endif
#if KMP_STATS_ENABLED
@@ -7077,7 +7136,22 @@ int __kmp_invoke_teams_master(int gtid) {
(void *)__kmp_teams_master);
#endif
__kmp_run_before_invoked_task(gtid, 0, this_thr, team);
+#if OMPT_SUPPORT
+ int tid = __kmp_tid_from_gtid(gtid);
+ ompt_data_t *task_data =
+ &team->t.t_implicit_task_taskdata[tid].ompt_task_info.task_data;
+ ompt_data_t *parallel_data = &team->t.ompt_team_info.parallel_data;
+ if (ompt_enabled.ompt_callback_implicit_task) {
+ ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
+ ompt_scope_begin, parallel_data, task_data, team->t.t_nproc, tid,
+ ompt_task_initial);
+ OMPT_CUR_TASK_INFO(this_thr)->thread_num = tid;
+ }
+#endif
__kmp_teams_master(gtid);
+#if OMPT_SUPPORT
+ this_thr->th.ompt_thread_info.parallel_flags |= ompt_parallel_league;
+#endif
__kmp_run_after_invoked_task(gtid, 0, this_thr, team);
return 1;
}
diff --git a/openmp/runtime/src/kmp_wait_release.h b/openmp/runtime/src/kmp_wait_release.h
index bb6bdf5d8fa..b235be3cf64 100644
--- a/openmp/runtime/src/kmp_wait_release.h
+++ b/openmp/runtime/src/kmp_wait_release.h
@@ -140,8 +140,11 @@ static void __ompt_implicit_task_end(kmp_info_t *this_thr,
#endif
if (!KMP_MASTER_TID(ds_tid)) {
if (ompt_enabled.ompt_callback_implicit_task) {
+ int flags = this_thr->th.ompt_thread_info.parallel_flags;
+ flags = (flags & ompt_parallel_league) ? ompt_task_initial
+ : ompt_task_implicit;
ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
- ompt_scope_end, NULL, tId, 0, ds_tid, ompt_task_implicit);
+ ompt_scope_end, NULL, tId, 0, ds_tid, flags);
}
// return to idle state
this_thr->th.ompt_thread_info.state = ompt_state_idle;
diff --git a/openmp/runtime/src/ompt-internal.h b/openmp/runtime/src/ompt-internal.h
index 5a6beaf88ca..958b5943af3 100644
--- a/openmp/runtime/src/ompt-internal.h
+++ b/openmp/runtime/src/ompt-internal.h
@@ -81,6 +81,7 @@ typedef struct {
ompt_state_t state;
ompt_wait_id_t wait_id;
int ompt_task_yielded;
+ int parallel_flags; // information for the last parallel region invoked
void *idle_frame;
} ompt_thread_info_t;
diff --git a/openmp/runtime/src/ompt-specific.cpp b/openmp/runtime/src/ompt-specific.cpp
index 63153d274ef..7fb81bb7d1a 100644
--- a/openmp/runtime/src/ompt-specific.cpp
+++ b/openmp/runtime/src/ompt-specific.cpp
@@ -269,10 +269,11 @@ void __ompt_lw_taskteam_init(ompt_lw_taskteam_t *lwt, kmp_info_t *thr, int gtid,
}
void __ompt_lw_taskteam_link(ompt_lw_taskteam_t *lwt, kmp_info_t *thr,
- int on_heap) {
+ int on_heap, bool always) {
ompt_lw_taskteam_t *link_lwt = lwt;
- if (thr->th.th_team->t.t_serialized >
- 1) { // we already have a team, so link the new team and swap values
+ if (always ||
+ thr->th.th_team->t.t_serialized >
+ 1) { // we already have a team, so link the new team and swap values
if (on_heap) { // the lw_taskteam cannot stay on stack, allocate it on heap
link_lwt =
(ompt_lw_taskteam_t *)__kmp_allocate(sizeof(ompt_lw_taskteam_t));
diff --git a/openmp/runtime/src/ompt-specific.h b/openmp/runtime/src/ompt-specific.h
index 86fd928d037..47d8a166984 100644
--- a/openmp/runtime/src/ompt-specific.h
+++ b/openmp/runtime/src/ompt-specific.h
@@ -26,7 +26,7 @@ void __ompt_lw_taskteam_init(ompt_lw_taskteam_t *lwt, kmp_info_t *thr,
int gtid, ompt_data_t *ompt_pid, void *codeptr);
void __ompt_lw_taskteam_link(ompt_lw_taskteam_t *lwt, kmp_info_t *thr,
- int on_heap);
+ int on_heap, bool always = false);
void __ompt_lw_taskteam_unlink(kmp_info_t *thr);
OpenPOWER on IntegriCloud