[Openmp-commits] [openmp] 4471094 - [OpenMP][FIX] Data race in the SPMD execution of the new runtime

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Thu Oct 7 18:01:38 PDT 2021


Author: Johannes Doerfert
Date: 2021-10-07T21:01:24-04:00
New Revision: 44710940af5bed3c338c4c397c561bfb83790218

URL: https://github.com/llvm/llvm-project/commit/44710940af5bed3c338c4c397c561bfb83790218
DIFF: https://github.com/llvm/llvm-project/commit/44710940af5bed3c338c4c397c561bfb83790218.diff

LOG: [OpenMP][FIX] Data race in the SPMD execution of the new runtime

We need to synchronize the threads *before* we destroy the RAII objects
that hold the old values and not after to avoid threads executing the
parallel region but seeing an inconsistent state.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D111369

Added: 
    

Modified: 
    openmp/libomptarget/DeviceRTL/src/Parallelism.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/src/Parallelism.cpp b/openmp/libomptarget/DeviceRTL/src/Parallelism.cpp
index afb0704f2642e..91309b8a013f8 100644
--- a/openmp/libomptarget/DeviceRTL/src/Parallelism.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Parallelism.cpp
@@ -103,8 +103,8 @@ void __kmpc_parallel_51(IdentTy *ident, int32_t, int32_t if_expr,
 
       if (TId < NumThreads)
         invokeMicrotask(TId, 0, fn, args, nargs);
+      synchronize::threads();
     }
-    synchronize::threads();
     return;
   }
 


        


More information about the Openmp-commits mailing list