summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/src
diff options
context:
space:
mode:
authorJonathan Peyton <jonathan.l.peyton@intel.com>2018-08-24 18:03:27 +0000
committerJonathan Peyton <jonathan.l.peyton@intel.com>2018-08-24 18:03:27 +0000
commitb1b221c82cc25adbe181d5c5886ad5423fede17d (patch)
treee8e377cc9140ab03461d919c258dfd8ed66068f3 /openmp/runtime/src
parent02f1d1315f0a8240046ace6054e51082f9681133 (diff)
downloadbcm5719-llvm-b1b221c82cc25adbe181d5c5886ad5423fede17d.tar.gz
bcm5719-llvm-b1b221c82cc25adbe181d5c5886ad5423fede17d.zip
[OpenMP] Fix incorrect barrier imbalance reporting in ITTNOTIFY
Exclude nested explicit tasks from timing, only outer level explicit task counted and its time added to barrier arrive time for the thread. Differential Revision: https://reviews.llvm.org/D50584 llvm-svn: 340628
Diffstat (limited to 'openmp/runtime/src')
-rw-r--r--openmp/runtime/src/kmp_barrier.cpp2
-rw-r--r--openmp/runtime/src/kmp_tasking.cpp46
2 files changed, 26 insertions, 22 deletions
diff --git a/openmp/runtime/src/kmp_barrier.cpp b/openmp/runtime/src/kmp_barrier.cpp
index e817549fa8d..51c6e3e7e27 100644
--- a/openmp/runtime/src/kmp_barrier.cpp
+++ b/openmp/runtime/src/kmp_barrier.cpp
@@ -1458,8 +1458,8 @@ int __kmp_barrier(enum barrier_type bt, int gtid, int is_split,
if (__kmp_tasking_mode != tskm_immediate_exec) {
#if OMP_45_ENABLED
if (this_thr->th.th_task_team != NULL) {
- void *itt_sync_obj = NULL;
#if USE_ITT_NOTIFY
+ void *itt_sync_obj = NULL;
if (__itt_sync_create_ptr || KMP_ITT_DEBUG) {
itt_sync_obj = __kmp_itt_barrier_object(gtid, bt, 1);
__kmp_itt_barrier_starting(gtid, itt_sync_obj);
diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp
index 5a4df0c1ea4..d9220c5a2dc 100644
--- a/openmp/runtime/src/kmp_tasking.cpp
+++ b/openmp/runtime/src/kmp_tasking.cpp
@@ -1266,6 +1266,7 @@ kmp_task_t *__kmpc_omp_task_alloc(ident_t *loc_ref, kmp_int32 gtid,
static void __kmp_invoke_task(kmp_int32 gtid, kmp_task_t *task,
kmp_taskdata_t *current_task) {
kmp_taskdata_t *taskdata = KMP_TASK_TO_TASKDATA(task);
+ kmp_info_t *thread;
#if OMP_40_ENABLED
int discard = 0 /* false */;
#endif
@@ -1293,20 +1294,10 @@ static void __kmp_invoke_task(kmp_int32 gtid, kmp_task_t *task,
}
#endif
-#if USE_ITT_BUILD && USE_ITT_NOTIFY
- kmp_uint64 cur_time;
- if (__kmp_forkjoin_frames_mode == 3) {
- // Get the current time stamp to measure task execution time to correct
- // barrier imbalance time
- cur_time = __itt_get_timestamp();
- }
-#endif
-
#if OMPT_SUPPORT
// For untied tasks, the first task executed only calls __kmpc_omp_task and
// does not execute code.
ompt_thread_info_t oldInfo;
- kmp_info_t *thread;
if (UNLIKELY(ompt_enabled.enabled)) {
// Store the threads states and restore them after the task
thread = __kmp_threads[gtid];
@@ -1334,8 +1325,8 @@ static void __kmp_invoke_task(kmp_int32 gtid, kmp_task_t *task,
// TODO: check if this sequence can be hoisted above __kmp_task_start
// if cancellation has been enabled for this run ...
if (__kmp_omp_cancellation) {
- kmp_info_t *this_thr = __kmp_threads[gtid];
- kmp_team_t *this_team = this_thr->th.th_team;
+ thread = __kmp_threads[gtid];
+ kmp_team_t *this_team = thread->th.th_team;
kmp_taskgroup_t *taskgroup = taskdata->td_taskgroup;
if ((taskgroup && taskgroup->cancel_request) ||
(this_team->t.t_cancel_request == cancel_parallel)) {
@@ -1395,6 +1386,21 @@ static void __kmp_invoke_task(kmp_int32 gtid, kmp_task_t *task,
__ompt_task_start(task, current_task, gtid);
#endif
+#if USE_ITT_BUILD && USE_ITT_NOTIFY
+ kmp_uint64 cur_time;
+ kmp_int32 kmp_itt_count_task =
+ __kmp_forkjoin_frames_mode == 3 && !taskdata->td_flags.task_serial &&
+ current_task->td_flags.tasktype == TASK_IMPLICIT;
+ if (kmp_itt_count_task) {
+ thread = __kmp_threads[gtid];
+ // Time outer level explicit task on barrier for adjusting imbalance time
+ if (thread->th.th_bar_arrive_time)
+ cur_time = __itt_get_timestamp();
+ else
+ kmp_itt_count_task = 0; // thread is not on a barrier - skip timing
+ }
+#endif
+
#ifdef KMP_GOMP_COMPAT
if (taskdata->td_flags.native) {
((void (*)(void *))(*(task->routine)))(task->shareds);
@@ -1405,6 +1411,13 @@ static void __kmp_invoke_task(kmp_int32 gtid, kmp_task_t *task,
}
KMP_POP_PARTITIONED_TIMER();
+#if USE_ITT_BUILD && USE_ITT_NOTIFY
+ if (kmp_itt_count_task) {
+ // Barrier imbalance - adjust arrive time with the task duration
+ thread->th.th_bar_arrive_time += (__itt_get_timestamp() - cur_time);
+ }
+#endif
+
#if OMP_40_ENABLED
}
#endif // OMP_40_ENABLED
@@ -1429,15 +1442,6 @@ static void __kmp_invoke_task(kmp_int32 gtid, kmp_task_t *task,
}
#endif
-#if USE_ITT_BUILD && USE_ITT_NOTIFY
- // Barrier imbalance - correct arrive time after the task finished
- if (__kmp_forkjoin_frames_mode == 3) {
- kmp_info_t *this_thr = __kmp_threads[gtid];
- if (this_thr->th.th_bar_arrive_time) {
- this_thr->th.th_bar_arrive_time += (__itt_get_timestamp() - cur_time);
- }
- }
-#endif
KA_TRACE(
30,
("__kmp_invoke_task(exit): T#%d completed task %p, resuming task %p\n",
OpenPOWER on IntegriCloud