[Mlir-commits] [clang] [llvm] [mlir] [OpenMP] Reserve the main thread's warp for generic mode kernels (PR #218790)

Larry Meadows llvmlistbot at llvm.org
Thu Aug 27 22:13:47 PDT 2026


================
@@ -8582,6 +8596,17 @@ OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createTargetInit(
     }
   }
 
+  // Generic mode runs the main thread on a warp of its own, past thread_limit.
+  bool NeedsMainThreadWarp =
----------------
lfmeadow wrote:

You are right, and no, bare mode should not get it. The condition was written as
"not one of the SPMD flavours", which quietly swept up `OMP_TGT_EXEC_MODE_BARE`
(0) and `OMP_TGT_EXEC_MODE_GENERIC_SPMD`. Neither wants the extra warp: a bare
kernel never runs kernel init, so it has no main thread to make room for, and a
generic-SPMD kernel runs every thread as a worker, so the device runtime hands
back the whole block.

Fixed to test `Attrs.ExecFlags == omp::OMP_TGT_EXEC_MODE_GENERIC`, which is the
same predicate the plugin uses to decide whether to add the warp back at launch
(`GenericKernelTy::isGenericMode()`), so the two sides now agree by construction.
Pushed, along with the MLIR expectations that the wider default wavefront in the
second commit had left stale.

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


More information about the Mlir-commits mailing list