[Libomptarget][NFC] Rename device environment variable
authorJoseph Huber <jhuber6@vols.utk.edu>
Tue, 17 Jan 2023 20:09:12 +0000 (14:09 -0600)
committerJoseph Huber <jhuber6@vols.utk.edu>
Tue, 17 Jan 2023 20:28:04 +0000 (14:28 -0600)
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.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D141960

openmp/libomptarget/DeviceRTL/src/Configuration.cpp
openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
openmp/libomptarget/plugins/cuda/src/rtl.cpp

index 17613b0..ceccef6 100644 (file)
@@ -25,26 +25,25 @@ extern uint32_t __omp_rtl_debug_kind;
 extern uint32_t __omp_rtl_assume_no_thread_state;
 extern uint32_t __omp_rtl_assume_no_nested_parallelism;
 
-// 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) {
index 96800fe..5d160ad 100644 (file)
@@ -263,7 +263,7 @@ Error GenericDeviceTy::setupDeviceEnvironment(GenericPluginTy &Plugin,
   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 e8bce77..809c661 100644 (file)
@@ -1708,7 +1708,7 @@ struct DeviceEnvironment {
   // 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 @@ __tgt_target_table *__tgt_rtl_load_binary_locked(int32_t DeviceId,
   // 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 3bb060f..67d1b2a 100644 (file)
@@ -932,7 +932,7 @@ public:
       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;