[Openmp-commits] [openmp] r340628 - [OpenMP] Fix incorrect barrier imbalance reporting in ITTNOTIFY
Jonathan Peyton via Openmp-commits
openmp-commits at lists.llvm.org
Fri Aug 24 11:03:27 PDT 2018
Author: jlpeyton
Date: Fri Aug 24 11:03:27 2018
New Revision: 340628
URL: http://llvm.org/viewvc/llvm-project?rev=340628&view=rev
Log:
[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
Modified:
openmp/trunk/runtime/src/kmp_barrier.cpp
openmp/trunk/runtime/src/kmp_tasking.cpp
Modified: openmp/trunk/runtime/src/kmp_barrier.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_barrier.cpp?rev=340628&r1=340627&r2=340628&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_barrier.cpp (original)
+++ openmp/trunk/runtime/src/kmp_barrier.cpp Fri Aug 24 11:03:27 2018
@@ -1458,8 +1458,8 @@ int __kmp_barrier(enum barrier_type bt,
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);
Modified: openmp/trunk/runtime/src/kmp_tasking.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_tasking.cpp?rev=340628&r1=340627&r2=340628&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_tasking.cpp (original)
+++ openmp/trunk/runtime/src/kmp_tasking.cpp Fri Aug 24 11:03:27 2018
@@ -1266,6 +1266,7 @@ kmp_task_t *__kmpc_omp_task_alloc(ident_
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
}
#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
// 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
__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
}
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
}
#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",
More information about the Openmp-commits
mailing list