[Openmp-commits] [clang] [llvm] [mlir] [openmp] [OpenMP][offload] Cross-team reductions with variable number of teams (PR #195102)

Johannes Doerfert via Openmp-commits openmp-commits at lists.llvm.org
Thu May 7 17:46:55 PDT 2026


================
@@ -143,11 +159,16 @@ GenericKernelTy::getKernelLaunchEnvironment(
   LocalKLE.DynCGroupMemFb = DynBlockMemConf.Fallback;
   LocalKLE.ReductionBuffer = nullptr;
 
-  if (KernelEnvironment.Configuration.ReductionDataSize &&
-      KernelEnvironment.Configuration.ReductionBufferLength) {
+  if (NeedsReductionBuffer) {
+    // Size the teams-reduction buffer. ReductionBufferLength is the
+    // statically known upper bound on the number of teams. When it is 0
+    // (i.e. num_teams was not a compile-time constant), we size the buffer
+    // to exactly match the number of teams for this launch (NumBlocks0).
+    uint32_t BufferElements = RedCfg.ReductionBufferLength
+                                  ? RedCfg.ReductionBufferLength
+                                  : NumBlocks0;
----------------
jdoerfert wrote:

Again, I don't think RBL is a static bound for #teams.

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


More information about the Openmp-commits mailing list