[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:55:46 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:
Yeah I'd prefer that be specific policy depending on the backend, or something. Most likely it just depends on which runtime it links, the GPU one or the CPU one.
https://github.com/llvm/llvm-project/pull/222606
More information about the llvm-commits
mailing list