[Openmp-commits] [openmp] 025f549 - [OpenMP][DeviceRTL] Fixed an issue that causes hang in SU3

Shilei Tian via Openmp-commits openmp-commits at lists.llvm.org
Sat Oct 30 11:44:34 PDT 2021


Author: Shilei Tian
Date: 2021-10-30T14:44:29-04:00
New Revision: 025f5492401489269ab980910f4fda98f5b06bd1

URL: https://github.com/llvm/llvm-project/commit/025f5492401489269ab980910f4fda98f5b06bd1
DIFF: https://github.com/llvm/llvm-project/commit/025f5492401489269ab980910f4fda98f5b06bd1.diff

LOG: [OpenMP][DeviceRTL] Fixed an issue that causes hang in SU3

The synchronization at the end of parallel region cannot make sure all threads
exit the scope. As a result, the assertions right after it might be hit, and
further the `state::assumeInitialState(IsSPMD)` in `__kmpc_target_deinit` may
not hold as well. We either add a synchronization right after the parallel region,
or remove the assertions and assuptions. Here we choose the first one as those
assertions and assumptions can help optimizations.

Reviewed By: jdoerfert

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

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 8dcda213b5fba..ae7df3f95b7ae 100644
--- a/openmp/libomptarget/DeviceRTL/src/Parallelism.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Parallelism.cpp
@@ -123,6 +123,11 @@ void __kmpc_parallel_51(IdentTy *ident, int32_t, int32_t if_expr,
       synchronize::threadsAligned();
     }
 
+    // Synchronize all threads to make sure every thread exits the scope above;
+    // otherwise the following assertions and the assumption in
+    // __kmpc_target_deinit may not hold.
+    synchronize::threadsAligned();
+
     ASSERT(state::ParallelTeamSize == 1u);
     ASSERT(icv::ActiveLevel == 0u);
     ASSERT(icv::Level == 0u);


        


More information about the Openmp-commits mailing list