[Openmp-commits] [PATCH] D141960: [Libomptarget][NFC] Rename device environment variable

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Jan 17 12:11:00 PST 2023

jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, tianshilei1992, jdoerfert, ye-luo.
Herald added subscribers: kosarev, kerbowa, jvesely.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.

This variable is used by the runtime. Before kernel launch we set it to
indicate several configuration options from the host. This patch renames
it to be more in-line with the rest of the named exported from the
runtime. This is better because this is the only symbol visible to the
host from the runtime, so it should have a reserved name.

  rG LLVM Github Monorepo



Index: openmp/libomptarget/plugins/cuda/src/rtl.cpp
--- openmp/libomptarget/plugins/cuda/src/rtl.cpp
+++ openmp/libomptarget/plugins/cuda/src/rtl.cpp
@@ -932,7 +932,7 @@
       if (const char *EnvStr = getenv("LIBOMPTARGET_DEVICE_RTL_DEBUG"))
         DeviceEnv.DebugKind = std::stoi(EnvStr);
-      const char *DeviceEnvName = "omptarget_device_environment";
+      const char *DeviceEnvName = "__omp_rtl_device_environment";
       CUdeviceptr DeviceEnvPtr;
       size_t CUSize;
Index: openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
--- openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -1708,7 +1708,7 @@
   // If the symbol is in .data (aomp, rocm) it can be written directly.
   // If it is in .bss, we must wait for it to be allocated space on the
   // gpu (trunk) and initialize after loading.
-  const char *sym() { return "omptarget_device_environment"; }
+  const char *sym() { return "__omp_rtl_device_environment"; }
   DeviceEnvironmentTy HostDeviceEnv;
   SymbolInfo SI;
@@ -2102,7 +2102,7 @@
   // per-image initialization work. Specifically:
   // - Initialize an DeviceEnvironmentTy instance embedded in the
-  //   image at the symbol "omptarget_device_environment"
+  //   image at the symbol "__omp_rtl_device_environment"
   //   Fields DebugKind, DeviceNum, NumDevices. Used by the deviceRTL.
   // - Allocate a large array per-gpu (could be moved to init_device)
Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
+++ openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
@@ -263,7 +263,7 @@
   DeviceEnvironment.DynamicMemSize = OMPX_SharedMemorySize;
   // Create the metainfo of the device environment global.
-  GlobalTy DevEnvGlobal("omptarget_device_environment",
+  GlobalTy DevEnvGlobal("__omp_rtl_device_environment",
                         sizeof(DeviceEnvironmentTy), &DeviceEnvironment);
   // Write device environment values to the device.
Index: openmp/libomptarget/DeviceRTL/src/Configuration.cpp
--- openmp/libomptarget/DeviceRTL/src/Configuration.cpp
+++ openmp/libomptarget/DeviceRTL/src/Configuration.cpp
@@ -28,23 +28,23 @@
 // TODO: We want to change the name as soon as the old runtime is gone.
 // This variable should be visibile to the plugin so we override the default
 // hidden visibility.
-DeviceEnvironmentTy CONSTANT(omptarget_device_environment)
+DeviceEnvironmentTy CONSTANT(__omp_rtl_device_environment)
     __attribute__((used, retain, weak, visibility("protected")));
 uint32_t config::getDebugKind() {
-  return __omp_rtl_debug_kind & omptarget_device_environment.DebugKind;
+  return __omp_rtl_debug_kind & __omp_rtl_device_environment.DebugKind;
 uint32_t config::getNumDevices() {
-  return omptarget_device_environment.NumDevices;
+  return __omp_rtl_device_environment.NumDevices;
 uint32_t config::getDeviceNum() {
-  return omptarget_device_environment.DeviceNum;
+  return __omp_rtl_device_environment.DeviceNum;
 uint64_t config::getDynamicMemorySize() {
-  return omptarget_device_environment.DynamicMemSize;
+  return __omp_rtl_device_environment.DynamicMemSize;
 bool config::isDebugMode(config::DebugKind Kind) {

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141960.489913.patch
Type: text/x-patch
Size: 3601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230117/28f21264/attachment.bin>

More information about the Openmp-commits mailing list