[Openmp-commits] [PATCH] D19030: [ITTNOTIFY] Correct barrier imbalance time in case of tasks

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Thu Apr 14 09:12:31 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL266332: [ITTNOTIFY] Correct barrier imbalance time in case of tasks (authored by jlpeyton).

Changed prior to commit:
  http://reviews.llvm.org/D19030?vs=53450&id=53742#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19030

Files:
  openmp/trunk/runtime/src/kmp_barrier.cpp
  openmp/trunk/runtime/src/kmp_tasking.c

Index: openmp/trunk/runtime/src/kmp_tasking.c
===================================================================
--- openmp/trunk/runtime/src/kmp_tasking.c
+++ openmp/trunk/runtime/src/kmp_tasking.c
@@ -1103,6 +1103,7 @@
 __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 @@
          }
 #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 @@
 #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;
Index: openmp/trunk/runtime/src/kmp_barrier.cpp
===================================================================
--- openmp/trunk/runtime/src/kmp_barrier.cpp
+++ openmp/trunk/runtime/src/kmp_barrier.cpp
@@ -1198,8 +1198,11 @@
                     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 @@
                 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);
                 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19030.53742.patch
Type: text/x-patch
Size: 3277 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20160414/a6ba5fe4/attachment.bin>


More information about the Openmp-commits mailing list