[Openmp-commits] [PATCH] D28377: Fix a race in shutdown when tasking is used

Jonas Hahnfeld via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Jan 31 23:40:34 PST 2017


Hahnfeld accepted this revision.
Hahnfeld added a comment.
This revision is now accepted and ready to land.

To write down how I think this works:

1. No worker thread can set `th_reap_state = KMP_NOT_SAFE_TO_REAP` after the master thread has passed the barrier.
2. So master thread waits for all worker threads to finish before reaping.
3. If all threads have finished, none of them will try to steal so all can be safely reaped.

If that's the case then LGTM!



================
Comment at: runtime/src/kmp_runtime.cpp:5267
+            KMP_DEBUG_ASSERT(team->t.t_threads[f]);
+            if (__kmp_tasking_mode != tskm_immediate_exec) {
+                volatile kmp_uint32 *state = &team->t.t_threads[f]->th.th_reap_state;
----------------
I think you can swap the loop and this if statement which does not depend on the loop iteration? (see also line 5284)


================
Comment at: runtime/src/kmp_runtime.cpp:5276
+                    else
+                    *state = KMP_SAFE_TO_REAP; // reset the flag for dead thread
+#else
----------------
Please reindent this to make it clear


Repository:
  rL LLVM

https://reviews.llvm.org/D28377





More information about the Openmp-commits mailing list