[llvm] [offload][omp] Move reading _kernel_environment to libomptarget (PR #222606)
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 05:36:38 PDT 2026
================
@@ -461,6 +466,67 @@ static int loadImagesOntoDevice(DeviceTy &Device) {
if (Device.RTL->get_function(Binary, Entry.SymbolName,
&DeviceEntry.Address) != OFFLOAD_SUCCESS)
REPORT() << "Failed to load kernel " << Entry.SymbolName;
+
+ // Read this kernel's launch-geometry properties once, from its
+ // "<name>_kernel_environment" device global, and cache them on
+ // the device for use at launch time.
+ std::string EnvName =
+ std::string(Entry.SymbolName) + "_kernel_environment";
+ KernelEnvironmentTy KernelEnv{};
+ void *KernelEnvPtr = nullptr;
+ bool ReadOk =
+ Device.RTL->get_global(Binary, sizeof(KernelEnv), EnvName.c_str(),
+ &KernelEnvPtr) == OFFLOAD_SUCCESS &&
+ Device.RTL->data_retrieve(DeviceId, &KernelEnv, KernelEnvPtr,
+ sizeof(KernelEnv)) == OFFLOAD_SUCCESS;
+ if (!ReadOk) {
----------------
jhuber6 wrote:
I actually wonder if we should keep this fallback, it was initially intended to drive the non-OpenMP cases but if it's in `libomptarget` we could just consider this an ABI violation. I'd probably prefer that unless someone can think of a case where OpenMP wouldn't generate this for one of the kernels it creates / registers.
https://github.com/llvm/llvm-project/pull/222606
More information about the llvm-commits
mailing list