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 @@ -167,8 +167,8 @@ /// below to avoid repeating assumptions or including irrelevant ones. ///{ -bool mapping::isMainThreadInGenericMode() { - if (mapping::isSPMDMode()) +bool mapping::isMainThreadInGenericMode(bool IsSPMD) { + if (IsSPMD) return false; // Check if this is the last warp in the block. @@ -177,6 +177,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 @@ -195,7 +195,7 @@ uint32_t NumTeams = mapping::getNumberOfBlocks(); uint32_t NumThreads = mapping::getBlockSize(); if (mapping::isGenericMode()) { - if (!mapping::isMainThreadInGenericMode()) + if (!mapping::isMainThreadInGenericMode(/* IsSPMD */ false)) return 0; ThreadId = 0; NumThreads = /* main thread only */ 1;