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

Robert Imschweiler llvmlistbot at llvm.org
Wed Aug 26 06:52:54 PDT 2026


================
@@ -199,6 +200,17 @@ static const omp::GV &getGridValue(const Triple &T, Function *Kernel) {
         Kernel->getFnAttribute("target-features").getValueAsString();
     if (Features.count("+wavefrontsize64"))
       return omp::getAMDGPUGridValues<64>();
+    if (Features.count("+wavefrontsize32"))
+      return omp::getAMDGPUGridValues<32>();
+
+    // Clang sets no wavefront size on OpenMP device kernels, so ask the CPU.
+    StringRef CPU = Kernel->getFnAttribute("target-cpu").getValueAsString();
+    AMDGPU::GPUKind Kind = AMDGPU::parseArchAMDGCN(CPU);
+    if (Kind == AMDGPU::GK_NONE)
+      Kind = AMDGPU::getGPUKindFromSubArch(T.getSubArch());
+    if (Kind != AMDGPU::GK_NONE &&
+        !AMDGPU::getFeatureBitset(Kind).test(AMDGPU::FEAT_SUPPORTS_WAVE32))
+      return omp::getAMDGPUGridValues<64>();
     return omp::getAMDGPUGridValues<32>();
----------------
ro-i wrote:

shouldn't this return <64> to avoid running into the same underflow for unkown GPU kind?

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


More information about the Mlir-commits mailing list