diff --git a/openmp/libomptarget/DeviceRTL/include/Mapping.h b/openmp/libomptarget/DeviceRTL/include/Mapping.h --- a/openmp/libomptarget/DeviceRTL/include/Mapping.h +++ b/openmp/libomptarget/DeviceRTL/include/Mapping.h @@ -35,6 +35,7 @@ /// Return true if the executing thread is the main thread in generic mode. bool isMainThreadInGenericMode(); +bool isMainThreadInGenericMode(bool IsSPMD); /// Return true if the executing thread has the lowest Id of the active threads /// in the warp. diff --git a/openmp/libomptarget/DeviceRTL/src/Kernel.cpp b/openmp/libomptarget/DeviceRTL/src/Kernel.cpp --- a/openmp/libomptarget/DeviceRTL/src/Kernel.cpp +++ b/openmp/libomptarget/DeviceRTL/src/Kernel.cpp @@ -81,7 +81,7 @@ return -1; } - if (mapping::isMainThreadInGenericMode()) + if (mapping::isMainThreadInGenericMode(IsSPMD)) return -1; if (UseGenericStateMachine) diff --git a/openmp/libomptarget/DeviceRTL/src/Mapping.cpp b/openmp/libomptarget/DeviceRTL/src/Mapping.cpp --- a/openmp/libomptarget/DeviceRTL/src/Mapping.cpp +++ b/openmp/libomptarget/DeviceRTL/src/Mapping.cpp @@ -165,8 +165,8 @@ } // namespace impl } // namespace _OMP -bool mapping::isMainThreadInGenericMode() { - if (mapping::isSPMDMode() || icv::Level) +bool mapping::isMainThreadInGenericMode(bool IsSPMD) { + if (IsSPMD || icv::Level) return false; // Check if this is the last warp in the block. @@ -175,6 +175,10 @@ return mapping::getThreadIdInBlock() == MainTId; } +bool mapping::isMainThreadInGenericMode() { + return mapping::isMainThreadInGenericMode(mapping::isSPMDMode()); +} + bool mapping::isLeaderInWarp() { __kmpc_impl_lanemask_t Active = mapping::activemask(); __kmpc_impl_lanemask_t LaneMaskLT = mapping::lanemaskLT(); diff --git a/openmp/libomptarget/DeviceRTL/src/Reduction.cpp b/openmp/libomptarget/DeviceRTL/src/Reduction.cpp --- a/openmp/libomptarget/DeviceRTL/src/Reduction.cpp +++ b/openmp/libomptarget/DeviceRTL/src/Reduction.cpp @@ -72,7 +72,7 @@ InterWarpCopyFnTy cpyFct, bool isSPMDExecutionMode, bool) { uint32_t BlockThreadId = mapping::getThreadIdInBlock(); - if (mapping::isMainThreadInGenericMode()) + if (mapping::isMainThreadInGenericMode(/* IsSPMD */ false)) BlockThreadId = 0; uint32_t NumThreads = omp_get_num_threads(); if (NumThreads == 1)