[Openmp-commits] [openmp] 566ecc2 - [Libomptarget][NFC] Rename device environment variable

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


Author: Joseph Huber
Date: 2023-01-17T14:28:04-06:00
New Revision: 566ecc223165905ad1e012dc9b847694fb1f8fdb

URL: https://github.com/llvm/llvm-project/commit/566ecc223165905ad1e012dc9b847694fb1f8fdb
DIFF: https://github.com/llvm/llvm-project/commit/566ecc223165905ad1e012dc9b847694fb1f8fdb.diff

LOG: [Libomptarget][NFC] Rename device environment variable

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

Added: 
    

Modified: 
    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

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/src/Configuration.cpp b/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
index 17613b027fd54..ceccef625ed29 100644
--- a/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
@@ -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) {

diff  --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
index 96800fe518c40..5d160ad4d27fa 100644
--- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
+++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
@@ -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.

diff  --git a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
index e8bce775e9581..809c661baea3c 100644
--- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -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)

diff  --git a/openmp/libomptarget/plugins/cuda/src/rtl.cpp b/openmp/libomptarget/plugins/cuda/src/rtl.cpp
index 3bb060f29c9d7..67d1b2a2acfd1 100644
--- a/openmp/libomptarget/plugins/cuda/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/cuda/src/rtl.cpp
@@ -932,7 +932,7 @@ class DeviceRTLTy {
       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;
 


        


More information about the Openmp-commits mailing list