[llvm] [Offload][OMPX] Add the runtime support for multi-dim grid and block (PR #118042)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 6 06:07:16 PST 2024


================
@@ -566,10 +567,26 @@ Error GenericKernelTy::launch(GenericDeviceTy &GenericDevice, void **ArgPtrs,
                     Args, Ptrs, *KernelLaunchEnvOrErr);
   }
 
-  uint32_t NumThreads = getNumThreads(GenericDevice, KernelArgs.ThreadLimit);
-  uint64_t NumBlocks =
-      getNumBlocks(GenericDevice, KernelArgs.NumTeams, KernelArgs.Tripcount,
-                   NumThreads, KernelArgs.ThreadLimit[0] > 0);
+  uint32_t NumThreads[3] = {KernelArgs.ThreadLimit[0],
+                            KernelArgs.ThreadLimit[1],
+                            KernelArgs.ThreadLimit[2]};
+  uint32_t NumBlocks[3] = {KernelArgs.NumTeams[0], KernelArgs.NumTeams[1],
+                           KernelArgs.NumTeams[2]};
+  // FIXME: This is a WA to "calibrate" the bad work done in the front end.
+  // Delete this ugly code after the front end emits proper values.
+  auto CorrectMultiDim = [](uint32_t (&Val)[3]) {
----------------
shiltian wrote:

This is from the front end. In regular OpenMP, 0 represents users don't specify any value such that the runtime needs to choose one. The multi-dim kernel launch is purely an extension and it has not been standardized yet. I'll do a follow up patch that emits `[0,1,1]` for regular OpenMP if nothing is specified and `[x,y,z]` for OMPX.

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


More information about the llvm-commits mailing list