summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Peyton <jonathan.l.peyton@intel.com>2016-04-14 16:06:49 +0000
committerJonathan Peyton <jonathan.l.peyton@intel.com>2016-04-14 16:06:49 +0000
commit99ef4d04335c4b871df59c12d4ab91a546a0ec97 (patch)
treef6abb3162994af2a4cbd06e19de8ea49faae927d
parent66eb58a756a6cb4cb3f74f8d9e0eb3f56ad7fdfb (diff)
downloadbcm5719-llvm-99ef4d04335c4b871df59c12d4ab91a546a0ec97.tar.gz
bcm5719-llvm-99ef4d04335c4b871df59c12d4ab91a546a0ec97.zip
[ITTNOTIFY] Correct barrier imbalance time in case of tasks
ittnotify fix for barrier imbalance time in case tasks exist. In the current implementation, task execution time is included into aggregated time on a barrier. This fix calculates task execution time and corrects the arrive time by subtracting the task execution time. Since __kmp_invoke_task() can not only be called on a barrier, the field th.th_bar_arrive_time is used to check if the function was called at the barrier (th.th_bar_arrive_time != 0). So for this check, th_bar_arrive_time is set to zero right after the value is used on the barrier. Differential Revision: http://reviews.llvm.org/D19030 llvm-svn: 266332
-rw-r--r--openmp/runtime/src/kmp_barrier.cpp6
-rw-r--r--openmp/runtime/src/kmp_tasking.c17
2 files changed, 23 insertions, 0 deletions
diff --git a/openmp/runtime/src/kmp_barrier.cpp b/openmp/runtime/src/kmp_barrier.cpp
index e449a30c73a..6fef085f6b6 100644
--- a/openmp/runtime/src/kmp_barrier.cpp
+++ b/openmp/runtime/src/kmp_barrier.cpp
@@ -1198,8 +1198,11 @@ __kmp_barrier(enum barrier_type bt, int gtid, int is_split, size_t reduce_size,
if( __itt_metadata_add_ptr ) {
// Initialize with master's wait time
kmp_uint64 delta = cur_time - this_thr->th.th_bar_arrive_time;
+ // Set arrive time to zero to be able to check it in __kmp_invoke_task(); the same is done inside the loop below
+ this_thr->th.th_bar_arrive_time = 0;
for (i=1; i<nproc; ++i) {
delta += ( cur_time - other_threads[i]->th.th_bar_arrive_time );
+ other_threads[i]->th.th_bar_arrive_time = 0;
}
__kmp_itt_metadata_imbalance(gtid, this_thr->th.th_frame_time, cur_time, delta, (kmp_uint64)( reduce != NULL));
}
@@ -1489,8 +1492,11 @@ __kmp_join_barrier(int gtid)
if( __itt_metadata_add_ptr ) {
// Initialize with master's wait time
kmp_uint64 delta = cur_time - this_thr->th.th_bar_arrive_time;
+ // Set arrive time to zero to be able to check it in __kmp_invoke_task(); the same is done inside the loop below
+ this_thr->th.th_bar_arrive_time = 0;
for (i=1; i<nproc; ++i) {
delta += ( cur_time - other_threads[i]->th.th_bar_arrive_time );
+ other_threads[i]->th.th_bar_arrive_time = 0;
}
__kmp_itt_metadata_imbalance(gtid, this_thr->th.th_frame_time, cur_time, delta, 0);
}
diff --git a/openmp/runtime/src/kmp_tasking.c b/openmp/runtime/src/kmp_tasking.c
index 1122c49f3f3..044b7ff442c 100644
--- a/openmp/runtime/src/kmp_tasking.c
+++ b/openmp/runtime/src/kmp_tasking.c
@@ -1103,6 +1103,7 @@ 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_uint64 cur_time;
#if OMP_40_ENABLED
int discard = 0 /* false */;
#endif
@@ -1126,6 +1127,13 @@ __kmp_invoke_task( kmp_int32 gtid, kmp_task_t *task, kmp_taskdata_t * current_ta
}
#endif
+#if USE_ITT_BUILD && USE_ITT_NOTIFY
+ 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 OMP_41_ENABLED
// Proxy tasks are not handled by the runtime
if ( taskdata->td_flags.proxy != TASK_PROXY )
@@ -1219,6 +1227,15 @@ __kmp_invoke_task( kmp_int32 gtid, kmp_task_t *task, kmp_taskdata_t * current_ta
#endif
__kmp_task_finish( gtid, task, current_task );
+#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",
gtid, taskdata, current_task) );
return;
OpenPOWER on IntegriCloud