[llvm] [OFFLOAD][L0] Remove leftover global constructor (#182611) (PR #182665)
Alex Duran via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 21 02:20:40 PST 2026
https://github.com/adurang updated https://github.com/llvm/llvm-project/pull/182665
>From 3b9e95a604a4d32de5012f5a3a47a4428408a86d Mon Sep 17 00:00:00 2001
From: Alex Duran <alejandro.duran at intel.com>
Date: Sat, 21 Feb 2026 10:59:56 +0100
Subject: [PATCH 1/2] [OFFLOAD][L0] Remove global constructor (#182611)
---
offload/plugins-nextgen/level_zero/include/L0Plugin.h | 9 +++++----
offload/plugins-nextgen/level_zero/src/L0Kernel.cpp | 6 +++---
offload/plugins-nextgen/level_zero/src/L0Plugin.cpp | 4 ----
offload/plugins-nextgen/level_zero/src/L0Program.cpp | 7 +++++--
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/offload/plugins-nextgen/level_zero/include/L0Plugin.h b/offload/plugins-nextgen/level_zero/include/L0Plugin.h
index 27e9fedec0303..58c8252e0ccf8 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Plugin.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Plugin.h
@@ -43,8 +43,8 @@ class LevelZeroPluginTy final : public GenericPluginTy {
// Table containing per-thread information for each Context using TLS.
L0ContextTLSTableTy ContextTLSTable;
- /// L0 plugin global options.
- static L0OptionsTy Options;
+ /// L0 plugin options.
+ L0OptionsTy Options;
/// Common pool of AsyncQueue.
AsyncQueuePoolTy AsyncQueuePool;
@@ -56,7 +56,8 @@ class LevelZeroPluginTy final : public GenericPluginTy {
Expected<int32_t> findDevices();
public:
- LevelZeroPluginTy() : GenericPluginTy(getTripleArch()) {}
+ LevelZeroPluginTy()
+ : GenericPluginTy(getTripleArch()) {}
virtual ~LevelZeroPluginTy() = default;
L0DeviceTLSTy &getDeviceTLS(int32_t DeviceId) {
@@ -66,7 +67,7 @@ class LevelZeroPluginTy final : public GenericPluginTy {
return ContextTLSTable.get(Context);
}
- static const L0OptionsTy &getOptions() { return Options; }
+ const L0OptionsTy &getOptions() { return Options; }
const L0DeviceTy &getDeviceFromId(int32_t DeviceId) const {
return static_cast<const L0DeviceTy &>(getDevice(DeviceId));
diff --git a/offload/plugins-nextgen/level_zero/src/L0Kernel.cpp b/offload/plugins-nextgen/level_zero/src/L0Kernel.cpp
index 5659d0c46724b..b608e6ffe7931 100644
--- a/offload/plugins-nextgen/level_zero/src/L0Kernel.cpp
+++ b/offload/plugins-nextgen/level_zero/src/L0Kernel.cpp
@@ -101,7 +101,7 @@ void L0KernelTy::decideKernelGroupArguments(L0DeviceTy &Device,
bool MaxGroupSizeForced = false;
bool MaxGroupCountForced = false;
uint32_t MaxGroupSize = Device.getMaxGroupSize();
- const auto &Option = LevelZeroPluginTy::getOptions();
+ const auto &Option = Device.getPlugin().getOptions();
const auto OptSubscRate = Option.SubscriptionRate;
auto &GroupCounts = KEnv.GroupCounts;
@@ -192,7 +192,7 @@ Error L0KernelTy::getGroupsShape(L0DeviceTy &Device, int32_t NumTeams,
bool IsXeHPG = Device.isDeviceArch(DeviceArchTy::DeviceArch_XeHPG);
KEnv.HalfNumThreads =
- LevelZeroPluginTy::getOptions().ZeDebugEnabled && IsXeHPG;
+ Device.getPlugin().getOptions().ZeDebugEnabled && IsXeHPG;
uint32_t KernelWidth = KernelPR.Width;
uint32_t SIMDWidth = KernelPR.SIMDWidth;
INFO(OMP_INFOTYPE_PLUGIN_KERNEL, DeviceId,
@@ -427,7 +427,7 @@ Error L0KernelTy::launchImpl(GenericDeviceTy &GenericDevice,
auto &Plugin = l0Device.getPlugin();
auto *IdStr = l0Device.getZeIdCStr();
- auto &Options = LevelZeroPluginTy::getOptions();
+ auto &Options = Plugin.getOptions();
bool IsAsync = AsyncInfo && l0Device.asyncEnabled();
if (IsAsync && !AsyncInfo->Queue) {
AsyncInfo->Queue = reinterpret_cast<void *>(Plugin.getAsyncQueue());
diff --git a/offload/plugins-nextgen/level_zero/src/L0Plugin.cpp b/offload/plugins-nextgen/level_zero/src/L0Plugin.cpp
index 49fee797ead91..285fe797b5d7d 100644
--- a/offload/plugins-nextgen/level_zero/src/L0Plugin.cpp
+++ b/offload/plugins-nextgen/level_zero/src/L0Plugin.cpp
@@ -23,10 +23,6 @@ namespace llvm::omp::target::plugin {
using namespace llvm::omp::target;
using namespace error;
-#pragma clang diagnostic ignored "-Wglobal-constructors"
-// Common data across all possible plugin instantiations.
-L0OptionsTy LevelZeroPluginTy::Options;
-
Expected<int32_t> LevelZeroPluginTy::findDevices() {
CALL_ZE_RET_ERROR(zeInit, ZE_INIT_FLAG_GPU_ONLY);
uint32_t NumDrivers = 0;
diff --git a/offload/plugins-nextgen/level_zero/src/L0Program.cpp b/offload/plugins-nextgen/level_zero/src/L0Program.cpp
index 4fd7af098fa1f..9c914f0eb7cab 100644
--- a/offload/plugins-nextgen/level_zero/src/L0Program.cpp
+++ b/offload/plugins-nextgen/level_zero/src/L0Program.cpp
@@ -60,9 +60,12 @@ Error L0ProgramTy::deinit() {
Error L0ProgramBuilderTy::addModule(size_t Size, const uint8_t *Image,
const std::string_view CommonBuildOptions,
ze_module_format_t Format) {
- const ze_module_constants_t SpecConstants =
- LevelZeroPluginTy::getOptions().CommonSpecConstants.getModuleConstants();
auto &l0Device = getL0Device();
+ const ze_module_constants_t SpecConstants =
+ l0Device.getPlugin()
+ .getOptions()
+ .CommonSpecConstants.getModuleConstants();
+
std::string BuildOptions(CommonBuildOptions);
bool IsLibModule =
>From d0d905ec8adebffd4e4d487186184ae2f962ca2b Mon Sep 17 00:00:00 2001
From: Alex Duran <alejandro.duran at intel.com>
Date: Sat, 21 Feb 2026 11:20:28 +0100
Subject: [PATCH 2/2] fix format
---
offload/plugins-nextgen/level_zero/include/L0Plugin.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/offload/plugins-nextgen/level_zero/include/L0Plugin.h b/offload/plugins-nextgen/level_zero/include/L0Plugin.h
index 58c8252e0ccf8..cd964a0d46890 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Plugin.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Plugin.h
@@ -56,8 +56,7 @@ class LevelZeroPluginTy final : public GenericPluginTy {
Expected<int32_t> findDevices();
public:
- LevelZeroPluginTy()
- : GenericPluginTy(getTripleArch()) {}
+ LevelZeroPluginTy() : GenericPluginTy(getTripleArch()) {}
virtual ~LevelZeroPluginTy() = default;
L0DeviceTLSTy &getDeviceTLS(int32_t DeviceId) {
More information about the llvm-commits
mailing list