From: Henry Kao Date: Fri, 27 Mar 2020 20:29:05 +0000 (-0400) Subject: [OpenMP] Add memory barrier to solve data race X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=236ac68fa5b173e54b181e0a03216dfd8fd4f95e;p=platform%2Fupstream%2Fllvm.git [OpenMP] Add memory barrier to solve data race Data race occurs when acquiring lock for critical section triggering assertion failure. Added barrier to ensure all memory is commited before checking assertion. Reviewed By: Hahnfeld Differential Revision: https://reviews.llvm.org/D76780 --- diff --git a/openmp/runtime/src/kmp_lock.cpp b/openmp/runtime/src/kmp_lock.cpp index 2cc9e08..8e20c6c 100644 --- a/openmp/runtime/src/kmp_lock.cpp +++ b/openmp/runtime/src/kmp_lock.cpp @@ -1239,6 +1239,9 @@ __kmp_acquire_queuing_lock_timed_template(kmp_queuing_lock_t *lck, KMP_MB(); // ToDo: Use __kmp_wait_sleep or similar when blocktime != inf KMP_WAIT(spin_here_p, FALSE, KMP_EQ, lck); + // Synchronize writes to both runtime thread structures + // and writes in user code. + KMP_MB(); #ifdef DEBUG_QUEUING_LOCKS TRACE_LOCK(gtid + 1, "acq spin");