[Openmp-commits] [openmp] [OpenMP][offload] Fix wave32 handling of xteam reductions (PR #233096)

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Sat Oct 17 09:44:57 PDT 2026


================
@@ -101,11 +101,14 @@ static uint32_t gpu_block_reduce(void *reduce_data, ShuffleReductFnTy shflFct,
   if constexpr (checkLiveness) {
     __kmpc_impl_lanemask_t Liveness = mapping::activemask();
     // Check for partial warp with non-contiguous lanes.
-    if (Liveness == lanes::All) {
+    // Consider that Liveness::ALL is a 64-bit value, so compare the actual
+    // number of set bits to handle 32bit waves correctly.
+    uint32_t NumLive = static_cast<uint32_t>(utils::popc(Liveness));
+    if (NumLive == mapping::getWarpSize()) {
----------------
jhuber6 wrote:

I think we do something like this for the PGO checks that track uniform waves. This obviously misses if someone does something like launch 48 threads, leading one wave fully occupied but under 32, but that's just a slowdown and not a correctness issue.
```c
  const uint64_t Full = ~uint64_t(0) >> (64 - mapping::getWarpSize());
```

https://github.com/llvm/llvm-project/pull/233096


More information about the Openmp-commits mailing list