[Openmp-commits] [openmp] r247339 - [OMPT] Fix assertion that arises when waiting for proxy tasks on runtime shutdown

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Thu Sep 10 14:33:50 PDT 2015


Author: jlpeyton
Date: Thu Sep 10 16:33:50 2015
New Revision: 247339

URL: http://llvm.org/viewvc/llvm-project?rev=247339&view=rev
Log:
[OMPT] Fix assertion that arises when waiting for proxy tasks on runtime shutdown

This only triggered when built in debug mode with OMPT enabled:
__kmp_wait_template expected the state of the current thread to be either
ompt_state_idle or ompt_state_wait_barrier{,_implicit,_explicit}.

Patch by Jonas Hahnfeld

Differential Revision: http://reviews.llvm.org/D12754

Modified:
    openmp/trunk/runtime/src/kmp_runtime.c
    openmp/trunk/runtime/src/kmp_wait_release.h

Modified: openmp/trunk/runtime/src/kmp_runtime.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_runtime.c?rev=247339&r1=247338&r2=247339&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_runtime.c (original)
+++ openmp/trunk/runtime/src/kmp_runtime.c Thu Sep 10 16:33:50 2015
@@ -3986,8 +3986,13 @@ __kmp_unregister_root_current_thread( in
    kmp_task_team_t *   task_team = thread->th.th_task_team;
 
    // we need to wait for the proxy tasks before finishing the thread
-   if ( task_team != NULL && task_team->tt.tt_found_proxy_tasks )
+   if ( task_team != NULL && task_team->tt.tt_found_proxy_tasks ) {
+#if OMPT_SUPPORT
+        // the runtime is shutting down so we won't report any events
+        thread->th.ompt_thread_info.state = ompt_state_undefined;
+#endif
         __kmp_task_team_wait(thread, team, NULL );
+   }
 #endif
 
     __kmp_reset_root(gtid, root);

Modified: openmp/trunk/runtime/src/kmp_wait_release.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_wait_release.h?rev=247339&r1=247338&r2=247339&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_wait_release.h (original)
+++ openmp/trunk/runtime/src/kmp_wait_release.h Thu Sep 10 16:33:50 2015
@@ -96,15 +96,17 @@ static inline void __kmp_wait_template(k
     KA_TRACE(20, ("__kmp_wait_sleep: T#%d waiting for flag(%p)\n", th_gtid, flag));
 
 #if OMPT_SUPPORT && OMPT_BLAME
-    if (ompt_status == ompt_status_track_callback) {
-        if (this_thr->th.ompt_thread_info.state == ompt_state_idle){
+    ompt_state_t ompt_state = this_thr->th.ompt_thread_info.state;
+    if (ompt_status == ompt_status_track_callback &&
+        ompt_state != ompt_state_undefined) {
+        if (ompt_state == ompt_state_idle) {
             if (ompt_callbacks.ompt_callback(ompt_event_idle_begin)) {
                 ompt_callbacks.ompt_callback(ompt_event_idle_begin)(th_gtid + 1);
             }
         } else if (ompt_callbacks.ompt_callback(ompt_event_wait_barrier_begin)) {
-            KMP_DEBUG_ASSERT(this_thr->th.ompt_thread_info.state == ompt_state_wait_barrier ||
-                             this_thr->th.ompt_thread_info.state == ompt_state_wait_barrier_implicit ||
-                             this_thr->th.ompt_thread_info.state == ompt_state_wait_barrier_explicit);
+            KMP_DEBUG_ASSERT(ompt_state == ompt_state_wait_barrier ||
+                             ompt_state == ompt_state_wait_barrier_implicit ||
+                             ompt_state == ompt_state_wait_barrier_explicit);
 
             ompt_lw_taskteam_t* team = this_thr->th.th_team->t.ompt_serialized_team_info;
             ompt_parallel_id_t pId;
@@ -235,15 +237,16 @@ static inline void __kmp_wait_template(k
     }
 
 #if OMPT_SUPPORT && OMPT_BLAME
-    if (ompt_status == ompt_status_track_callback) {
-        if (this_thr->th.ompt_thread_info.state == ompt_state_idle){
+    if (ompt_status == ompt_status_track_callback &&
+        ompt_state != ompt_state_undefined) {
+        if (ompt_state == ompt_state_idle) {
             if (ompt_callbacks.ompt_callback(ompt_event_idle_end)) {
                 ompt_callbacks.ompt_callback(ompt_event_idle_end)(th_gtid + 1);
             }
         } else if (ompt_callbacks.ompt_callback(ompt_event_wait_barrier_end)) {
-            KMP_DEBUG_ASSERT(this_thr->th.ompt_thread_info.state == ompt_state_wait_barrier ||
-                             this_thr->th.ompt_thread_info.state == ompt_state_wait_barrier_implicit ||
-                             this_thr->th.ompt_thread_info.state == ompt_state_wait_barrier_explicit);
+            KMP_DEBUG_ASSERT(ompt_state == ompt_state_wait_barrier ||
+                             ompt_state == ompt_state_wait_barrier_implicit ||
+                             ompt_state == ompt_state_wait_barrier_explicit);
 
             ompt_lw_taskteam_t* team = this_thr->th.th_team->t.ompt_serialized_team_info;
             ompt_parallel_id_t pId;




More information about the Openmp-commits mailing list