[Openmp-commits] [PATCH] D76780: [OpenMP] Added memory barrier to solve data race
Henry Kao via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Wed Mar 25 09:43:35 PDT 2020
hkao13 created this revision.
Herald added subscribers: openmp-commits, guansong.
Herald added a reviewer: jdoerfert.
Herald added a project: OpenMP.
hkao13 updated this revision to Diff 252601.
hkao13 added a comment.
Added memory barrier to solve potential data race when acquiring lock for critical section.
Potential data race occurs when acquiring lock for a critical section which triggers the assertion failure (KMP_DEBUG_ASSERT(this_thr->th.th_next_waiting == 0)). This could be due to the weaker memory consistency model in ARM. Putting debug traces in the data race prone region (after thread is done spinning and acquiring the lock) makes the issue not reproducible. I add a memory barrier to ensure all threads see consistent view of shared memory (the gtid for the next thread waiting) before the failing assertion.
Data race occurs when acquiring lock for critical section
triggering assertion failure. Added barrier to ensure
all memory is commited before checking assertion.
rG LLVM Github Monorepo
@@ -1246,6 +1246,9 @@
if (this_thr->th.th_next_waiting != 0)
__kmp_dump_queuing_lock(this_thr, gtid, lck, *head_id_p, *tail_id_p);
+ // Make sure all updates to thread structures are complete before
+ // assertion check.
KMP_DEBUG_ASSERT(this_thr->th.th_next_waiting == 0);
KA_TRACE(1000, ("__kmp_acquire_queuing_lock: lck:%p, T#%d exiting: after "
"waiting on queue\n",
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 638 bytes
Desc: not available
More information about the Openmp-commits