[llvm] [offload] Add olLaunchKernelWithPtrArgs with an argument pointer array (PR #194333)

Piotr Balcer via llvm-commits llvm-commits at lists.llvm.org
Mon May 4 03:03:00 PDT 2026


pbalcer wrote:

> it's unfortunate that this will require the AMD plugin to use the ELF notes, normally those are just supplementary and everything needed for the launch is in the kernel descriptor.

While working on this proposal, I've looked at the HIP implementation of `hipModuleLaunchKernel`, which needs to do the exact same conversion. It appears be doing the exact same metadata lookup when creating the kernel:
https://github.com/ROCm/clr/blob/809d7566699c6777e6eb8b1c3666c0bf05f1d754/rocclr/device/devkernel.cpp#L374-L379. 

`hipModuleLaunchKernel` is what the open source Intel SYCL compiler uses to dispatch AMDGPU kernels, and it is working reliably.

> Shouldn't we push the sizing onto the user if we're being this explicit?

We need two information about each argument to perform this conversion, size and offset within the buffer. Size is already provided in the proposed API, and offset within the buffer is a property of the kernel, and may be target-dependent.

> It's also an unfortunate change for ergonomics, but presumably someone could make a helper function to make it easier for the user now that we need to pass size + pointer for everything.

We could make a variadic macro, so that instead of:
```
  void *ArgPtrs[] = {&A, &B, &C};
  size_t ArgSizes[] = {sizeof(A), sizeof(B), sizeof(C)};

  olLaunchKernelWithPtrArgs(Queue, Device, Kernel, ArgPtrs, ArgSizes, &LaunchArgs);
```
users, that'd like a less verbose API, could write:
```
  OL_LAUNCH_KERNEL(Queue, Device, Kernel, &LaunchArgs, &A, &B, &C);
```

> I can see the appeal, though I don't know how exigent an OpenCL plugin is.

It's on our (Intel's) long-term roadmap. I'd strongly prefer we plan the API with it in mind from the get-go, so that there's no need to change it later, when it's more difficult.

> If we go that route this should completely replace the existing ones and we just deal with breaking every single user of the library (we're still experimental at least).

I agree. I will update this PR to replace the existing interface, instead of adding a new one.

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


More information about the llvm-commits mailing list