[llvm] [openmp] [OpenMP][offload] Fix single-thread SPMD cross-team reductions (PR #228216)
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 1 12:47:43 PDT 2026
================
@@ -235,14 +235,19 @@ int32_t __kmpc_gpu_xteam_reduce_nowait(IdentTy *Loc, void *reduce_data,
uint32_t ThreadId;
uint32_t NumThreads;
- if (mapping::isSPMDMode()) {
+ // In SPMD mode, we're dealing with full warps unless the kernel was SPMD-ized
+ // without parallel regions: then, only the main thread is alive (see
+ // OpenMPOpt).
+ bool AllThreads =
+ mapping::isSPMDMode() && utils::popc(mapping::activemask()) > 1;
----------------
jhuber6 wrote:
This is a little confusing, I feel like if we're handling a very specific single threaded case in SPMD mode then maybe we could just check if the number of threads is 1?
https://github.com/llvm/llvm-project/pull/228216
More information about the llvm-commits
mailing list