diff --git a/openmp/libomptarget/include/Debug.h b/openmp/libomptarget/include/Debug.h --- a/openmp/libomptarget/include/Debug.h +++ b/openmp/libomptarget/include/Debug.h @@ -65,20 +65,20 @@ #define USED #endif -// Interface to the InfoLevel variable defined by each library. -extern std::atomic InfoLevel; - // Add __attribute__((used)) to work around a bug in gcc 5/6. -USED static inline uint32_t getInfoLevel() { +USED inline std::atomic &getInfoLevelInternal() { + static std::atomic InfoLevel; static std::once_flag Flag{}; std::call_once(Flag, []() { if (char *EnvStr = getenv("LIBOMPTARGET_INFO")) InfoLevel.store(std::stoi(EnvStr)); }); - return InfoLevel.load(); + return InfoLevel; } +USED inline uint32_t getInfoLevel() { return getInfoLevelInternal().load(); } + // Add __attribute__((used)) to work around a bug in gcc 5/6. USED static inline uint32_t getDebugLevel() { static uint32_t DebugLevel = 0; diff --git a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp --- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp +++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp @@ -1966,6 +1966,3 @@ } return OFFLOAD_SUCCESS; } - -// AMDGPU plugin's internal InfoLevel. -std::atomic InfoLevel; diff --git a/openmp/libomptarget/plugins/cuda/src/rtl.cpp b/openmp/libomptarget/plugins/cuda/src/rtl.cpp --- a/openmp/libomptarget/plugins/cuda/src/rtl.cpp +++ b/openmp/libomptarget/plugins/cuda/src/rtl.cpp @@ -1252,12 +1252,10 @@ } void __tgt_rtl_set_info_flag(uint32_t NewInfoLevel) { + std::atomic &InfoLevel = getInfoLevelInternal(); InfoLevel.store(NewInfoLevel); } #ifdef __cplusplus } #endif - -// Cuda plugin's internal InfoLevel. -std::atomic InfoLevel; diff --git a/openmp/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp b/openmp/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp --- a/openmp/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp +++ b/openmp/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp @@ -335,6 +335,3 @@ #ifdef __cplusplus } #endif - -// Elf-64 plugin's internal InfoLevel. -std::atomic InfoLevel; diff --git a/openmp/libomptarget/plugins/remote/src/rtl.cpp b/openmp/libomptarget/plugins/remote/src/rtl.cpp --- a/openmp/libomptarget/plugins/remote/src/rtl.cpp +++ b/openmp/libomptarget/plugins/remote/src/rtl.cpp @@ -173,6 +173,3 @@ #ifdef __cplusplus } #endif - -// Remote Offloading interal InfoLevel. -std::atomic InfoLevel; diff --git a/openmp/libomptarget/src/interface.cpp b/openmp/libomptarget/src/interface.cpp --- a/openmp/libomptarget/src/interface.cpp +++ b/openmp/libomptarget/src/interface.cpp @@ -459,12 +459,10 @@ } EXTERN void __tgt_set_info_flag(uint32_t NewInfoLevel) { + std::atomic &InfoLevel = getInfoLevelInternal(); InfoLevel.store(NewInfoLevel); for (auto &R : PM->RTLs.AllRTLs) { if (R.set_info_flag) R.set_info_flag(NewInfoLevel); } } - -// Libomptarget's InfoLevel storage. -std::atomic InfoLevel;