[Openmp-commits] [PATCH] D29597: Fixed intermittent hang on tests with "target teams if(0)" construct with no parallel inside
Andrey Churbanov via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Mon Feb 6 11:28:35 PST 2017
AndreyChurbanov created this revision.
Our testing found that the change r294214 has one issue with offload corner-case tests those have the code fragment:
#pragma omp target teams if(target:0)
{
}
where intermittent hang observed. Investigation showed that when master thread executes spin loop waiting for SAFE reap state of the worker thread this worker may be sleeping on a fork barrier. The solution for the problem is to check the flag the worker thread sleeps on, and resume the worker if needed so that it can mark itself as SAFE to reap.
Repository:
rL LLVM
https://reviews.llvm.org/D29597
Files:
runtime/src/kmp_runtime.cpp
Index: runtime/src/kmp_runtime.cpp
===================================================================
--- runtime/src/kmp_runtime.cpp
+++ runtime/src/kmp_runtime.cpp
@@ -5265,18 +5265,22 @@
// Wait for threads to reach reapable state
for (f = 1; f < team->t.t_nproc; ++f) {
KMP_DEBUG_ASSERT(team->t.t_threads[f]);
- volatile kmp_uint32 *state = &team->t.t_threads[f]->th.th_reap_state;
+ kmp_info_t *th = team->t.t_threads[f];
+ volatile kmp_uint32 *state = &th->th.th_reap_state;
while (*state != KMP_SAFE_TO_REAP) {
#if KMP_OS_WINDOWS
// On Windows a thread can be killed at any time, check this
DWORD ecode;
- if (__kmp_is_thread_alive(team->t.t_threads[f], &ecode))
- KMP_CPU_PAUSE();
- else
+ if (!__kmp_is_thread_alive(th, &ecode)) {
*state = KMP_SAFE_TO_REAP; // reset the flag for dead thread
-#else
- KMP_CPU_PAUSE();
+ break;
+ }
#endif
+ // first check if thread is sleeping
+ kmp_flag_64 fl(&th->th.th_bar[bs_forkjoin_barrier].bb.b_go, th);
+ if (fl.is_sleeping())
+ fl.resume(__kmp_gtid_from_thread(th));
+ KMP_CPU_PAUSE();
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29597.87268.patch
Type: text/x-patch
Size: 1486 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20170206/979ca5ab/attachment.bin>
More information about the Openmp-commits
mailing list