[Openmp-commits] [PATCH] D77603: [OpenMP] Sync writes to child thread's data before reduction

Bryan Chan via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Apr 6 15:49:20 PDT 2020


bryanpkc created this revision.
bryanpkc added reviewers: Hahnfeld, jlpeyton, jdoerfert.
Herald added subscribers: openmp-commits, guansong, yaxunl.
Herald added a project: OpenMP.

On systems with weak memory consistency, this patch fixes an intermittent crash
in the reduction function called by __kmp_hyper_barrier_gather, which suffers
from a race on a child thread's data.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77603

Files:
  openmp/runtime/src/kmp_barrier.cpp


Index: openmp/runtime/src/kmp_barrier.cpp
===================================================================
--- openmp/runtime/src/kmp_barrier.cpp
+++ openmp/runtime/src/kmp_barrier.cpp
@@ -589,6 +589,7 @@
       // Wait for child to arrive
       kmp_flag_64 c_flag(&child_bar->b_arrived, new_state);
       c_flag.wait(this_thr, FALSE USE_ITT_BUILD_ARG(itt_sync_obj));
+      KMP_MB(); // Synchronize writes to child_thr.
       ANNOTATE_BARRIER_END(child_thr);
 #if USE_ITT_BUILD && USE_ITT_NOTIFY
       // Barrier imbalance - write min of the thread time and a child time to


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77603.255523.patch
Type: text/x-patch
Size: 582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20200406/20a664e0/attachment.bin>


More information about the Openmp-commits mailing list