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

Robert Imschweiler via Openmp-commits openmp-commits at lists.llvm.org
Tue Oct 20 01:08:59 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()) {
----------------
ro-i 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());
> ```

yeah, that's way smarter - thanks for that

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


More information about the Openmp-commits mailing list