diff --git a/openmp/libomptarget/DeviceRTL/src/Parallelism.cpp b/openmp/libomptarget/DeviceRTL/src/Parallelism.cpp --- a/openmp/libomptarget/DeviceRTL/src/Parallelism.cpp +++ b/openmp/libomptarget/DeviceRTL/src/Parallelism.cpp @@ -123,6 +123,11 @@ 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);