[llvm] [Offload] Add olKernelMaxGroupSize (PR #142950)

Ross Brunton via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 6 04:00:49 PDT 2025


RossBrunton wrote:

Just to summarize and get discussion in one place: As input we have a kernel name/handle, device and local memory size. From that we want to output the maximum group size.

In terms of API design, I can see multiple options:

1.
```c++
typedef void *ol_kernel_handle_t;
[...]
size_t GroupSize;
ol_kernel_handle_t Kernel;
olGetKernel(Program, "foo", &Kernel);
olKernelMaxGroupSize(Kernel, Device, 1024, &GroupSize);
```

2.
```c++
struct ol_kernel_handle_impl {
  GenericKernelTy *PluginKernel;
  ol_program_handle_t Program;
};
typedef ol_kernel_handle_impl *ol_kernel_handle_t;
[...]
size_t GroupSize;
ol_kernel_handle_t Kernel;
olGetKernel(Program, "foo", &Kernel);
olKernelMaxGroupSize(Kernel, 1024, &GroupSize);
```

3.
```c++
struct ol_kernel_handle_impl {
  GenericKernelTy *PluginKernel;
  ol_program_handle_t Program;
  size_t DynMemorySize;
};
typedef ol_kernel_handle_impl *ol_kernel_handle_t;
[...]
size_t GroupSize;
ol_kernel_handle_t Kernel;
olGetKernel(Program, "foo", 1024, &Kernel);
olGetKernelInfo(Kernel, OL_KERNEL_INFO_MAX_GROUP_SIZE, sizeof(GroupSize), &GroupSize);
```

4.
```c++
struct ol_kernel_handle_impl {
  GenericKernelTy *PluginKernel;
  ol_program_handle_t Program;
  size_t DynMemorySize;
};
typedef ol_kernel_handle_impl *ol_kernel_handle_t;
struct ol_kernel_invocation {
  ol_program_handle_t Program;
  const char *Name;
  size_t DynMemorySize;
};
[...]
ol_kernel_invocation Invocation{Program, "foo", 1024};
size_t GroupSize;
ol_kernel_handle_t Kernel;
olGetKernel(&Invocation, &Kernel);
olGetKernelInfo(Kernel, OL_KERNEL_INFO_MAX_GROUP_SIZE, sizeof(GroupSize), &GroupSize);
```

5.
```c++
struct ol_kernel_handle_impl {
  GenericKernelTy *PluginKernel;
  ol_program_handle_t Program;
};
struct ol_kernel_invocation {
  size_t DynMemorySize;
};
[...]
ol_kernel_invocation Invocation{1024};
size_t GroupSize;
ol_kernel_handle_t Kernel;
olGetKernel(Program, "foo", &Kernel);
olGetKernelInfo(Kernel, &Invocation, OL_KERNEL_INFO_MAX_GROUP_SIZE, sizeof(GroupSize), &GroupSize);
```

6.
```c++
struct ol_kernel_invocation {
  ol_program_handle_t Program;
  const char *Name;
  size_t DynMemorySize;
  // Should not be used by API users
  GenericKernelTy *PluginKernel;
};
[...]
ol_kernel_invocation Invocation{Program, "foo", 1024, nullptr};
size_t GroupSize;
olKernelLoad(&Invocation);
olGetKernelInfo(Invocation, OL_KERNEL_INFO_MAX_GROUP_SIZE, sizeof(GroupSize), &GroupSize);
```

Which of these options looks best to you, @callumfare @jhuber6 ? 

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


More information about the llvm-commits mailing list