[llvm] [offload] Align style of level zero plugin with llvm coding standard (PR #211762)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 24 03:08:19 PDT 2026
https://github.com/blazej-smorawski updated https://github.com/llvm/llvm-project/pull/211762
>From f07a6af2ee4b28e1919e7a666d95ed9efd9aac02 Mon Sep 17 00:00:00 2001
From: blazej-smorawski <blazej.smorawski at intel.com>
Date: Fri, 24 Jul 2026 11:58:54 +0200
Subject: [PATCH 1/2] [offload] Align style of level zero plugin with llvm
coding standard
This patch does a small cleanup of level zero plugin. Mainly I changed names of variables
to use `CamelCase` whenever they relate to our internal structures - not objects coming
directly from level zero API etc., so I left some variables and arguments like `zeDevice`,
but only if they are directly related to level zero APIs or structures.
Added a few `auto *` declarations, but again - only when they refer to our internal
objects and not to structures from level zero which might be pointers underneath,
but we use them as transparent objects.
Also did small cleanup of unused headers, making sure that we include directly
what we need rather than use transitive dependencies.
---
.../level_zero/dynamic_l0/L0DynWrapper.cpp | 6 +--
.../level_zero/include/L0Defs.h | 4 +-
.../level_zero/include/L0Device.h | 34 +++++++--------
.../level_zero/include/L0Event.h | 1 +
.../level_zero/include/L0Interop.h | 2 +
.../level_zero/include/L0Kernel.h | 4 +-
.../level_zero/include/L0Memory.h | 4 +-
.../level_zero/include/L0Options.h | 1 +
.../level_zero/include/L0Plugin.h | 1 -
.../level_zero/include/L0Program.h | 2 +-
.../level_zero/include/L0Queue.h | 2 -
.../level_zero/include/L0Trace.h | 3 +-
.../level_zero/src/L0Context.cpp | 6 +--
.../level_zero/src/L0Device.cpp | 43 +++++++++----------
.../level_zero/src/L0Event.cpp | 1 -
.../level_zero/src/L0Kernel.cpp | 35 ++++++++-------
.../level_zero/src/L0Memory.cpp | 15 +++----
.../level_zero/src/L0Options.cpp | 2 -
.../level_zero/src/L0Program.cpp | 33 +++++++-------
.../level_zero/src/L0Queue.cpp | 9 ++--
20 files changed, 98 insertions(+), 110 deletions(-)
diff --git a/offload/plugins-nextgen/level_zero/dynamic_l0/L0DynWrapper.cpp b/offload/plugins-nextgen/level_zero/dynamic_l0/L0DynWrapper.cpp
index 0e19c6373340a..22ba1106f15c8 100644
--- a/offload/plugins-nextgen/level_zero/dynamic_l0/L0DynWrapper.cpp
+++ b/offload/plugins-nextgen/level_zero/dynamic_l0/L0DynWrapper.cpp
@@ -227,7 +227,7 @@ static bool loadLevelZero() {
// use a new Level Zero API routine.
// zeCommandListHostSynchronize was introduced in loader 1.10.0 (API 1.6.0).
constexpr uint32_t MinVersion{ZE_MAKE_VERSION(1, 10)};
- auto emitCheckVersion = [&]() {
+ auto EmitCheckVersion = [&]() {
ODBG(OLDT_Init) << "Level Zero Loader compatible with version "
<< ZE_MAJOR_VERSION(MinVersion) << "."
<< ZE_MINOR_VERSION(MinVersion) << " is required";
@@ -250,7 +250,7 @@ static bool loadLevelZero() {
ErrMsg = "unknown error";
ODBG(OLDT_Init) << "Unable to load library '" << L0Library
<< "': " << ErrMsg << "!";
- emitCheckVersion();
+ EmitCheckVersion();
return false;
}
@@ -264,7 +264,7 @@ static bool loadLevelZero() {
if (!Fallback) {
ODBG(OLDT_Init) << "Symbol '" << Sym << "' not found in '" << L0Library
<< "' and no fallback is available!";
- emitCheckVersion();
+ EmitCheckVersion();
return false;
}
ODBG(OLDT_Init) << "Symbol '" << Sym << "' not found in '" << L0Library
diff --git a/offload/plugins-nextgen/level_zero/include/L0Defs.h b/offload/plugins-nextgen/level_zero/include/L0Defs.h
index b8d7a924a666f..1c616b93b779f 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Defs.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Defs.h
@@ -13,9 +13,7 @@
#ifndef OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_L0DEFS_H
#define OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_L0DEFS_H
-#include "PluginInterface.h"
-#include "Shared/Requirements.h"
-#include "omptarget.h"
+#include "OffloadError.h"
enum class AllocOptionTy : int32_t {
ALLOC_OPT_NONE = 0,
diff --git a/offload/plugins-nextgen/level_zero/include/L0Device.h b/offload/plugins-nextgen/level_zero/include/L0Device.h
index 4cface60e71a9..3e8129d057095 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Device.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Device.h
@@ -15,8 +15,6 @@
#include "llvm/ADT/SmallVector.h"
-#include "PerThreadTable.h"
-
#include "L0CmdListManager.h"
#include "L0Context.h"
#include "L0Program.h"
@@ -98,7 +96,7 @@ struct DeviceQueueConfigInfoTy {
class L0DeviceTy final : public GenericDeviceTy {
// Level Zero Context for this Device.
- L0ContextTy &l0Context;
+ L0ContextTy &L0Context;
// Level Zero handle for this Device.
ze_device_handle_t zeDevice;
@@ -164,7 +162,7 @@ class L0DeviceTy final : public GenericDeviceTy {
ze_device_handle_t zeDevice, L0ContextTy &DriverInfo,
const std::string_view zeId, int32_t ComputeIndex)
: GenericDeviceTy(Plugin, DeviceId, NumDevices, SPIRVGridValues),
- l0Context(DriverInfo), zeDevice(zeDevice), zeId(zeId),
+ L0Context(DriverInfo), zeDevice(zeDevice), zeId(zeId),
ComputeIndex(ComputeIndex), QueueCache(*this) {
DeviceProperties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
DeviceProperties.pNext = nullptr;
@@ -194,8 +192,8 @@ class L0DeviceTy final : public GenericDeviceTy {
return QueueConfig.SupportsCooperativeKernels;
}
- const L0ContextTy &getL0Context() const { return l0Context; }
- L0ContextTy &getL0Context() { return l0Context; }
+ const L0ContextTy &getL0Context() const { return L0Context; }
+ L0ContextTy &getL0Context() { return L0Context; }
const std::string_view getName() const { return DeviceName; }
const char *getNameCStr() const { return DeviceName.c_str(); }
@@ -388,7 +386,7 @@ class L0DeviceTy final : public GenericDeviceTy {
auto CmdListOrErr = createImmCmdList(InOrder);
if (!CmdListOrErr)
return CmdListOrErr.takeError();
- return new L0CmdListManagerTy(*CmdListOrErr, l0Context);
+ return new L0CmdListManagerTy(*CmdListOrErr, L0Context);
}
Error releaseCmdListManager(L0CmdListManagerTy *CmndListMngr) {
@@ -436,38 +434,38 @@ class L0DeviceTy final : public GenericDeviceTy {
/// Driver related functions.
/// Reurn the driver handle for this device.
- ze_driver_handle_t getZeDriver() const { return l0Context.getZeDriver(); }
+ ze_driver_handle_t getZeDriver() const { return L0Context.getZeDriver(); }
/// Return context for this device.
- ze_context_handle_t getZeContext() const { return l0Context.getZeContext(); }
+ ze_context_handle_t getZeContext() const { return L0Context.getZeContext(); }
/// Return driver API version for this device.
ze_api_version_t getDriverAPIVersion() const {
- return l0Context.getDriverAPIVersion();
+ return L0Context.getDriverAPIVersion();
}
/// Get a low-level L0 event from the driver associated to this device.
Expected<ze_event_handle_t> getEvent() {
- return l0Context.getEventPool().getEvent();
+ return L0Context.getEventPool().getEvent();
}
/// Get a high-level L0EventTy object from the driver associated to this
/// device.
Expected<L0EventTy *> getEventObject() {
- return l0Context.getEventPool().getEventObject();
+ return L0Context.getEventPool().getEventObject();
}
/// Release a L0 event to the pool associated to this device.
Error releaseEvent(ze_event_handle_t Event) {
- return l0Context.getEventPool().releaseEvent(Event);
+ return L0Context.getEventPool().releaseEvent(Event);
}
/// Release an L0EventTy object to the pool associated to this device.
Error releaseEventObject(L0EventTy *EventObj) {
- return l0Context.getEventPool().releaseEventObject(EventObj);
+ return L0Context.getEventPool().releaseEventObject(EventObj);
}
- StagingBufferTy &getStagingBuffer() { return l0Context.getStagingBuffer(); }
+ StagingBufferTy &getStagingBuffer() { return L0Context.getStagingBuffer(); }
- bool supportsLargeMem() const { return l0Context.supportsLargeMem(); }
+ bool supportsLargeMem() const { return L0Context.supportsLargeMem(); }
/// Returns the Queue from an async info object, or creates a new one if
/// the async info does not have a queue yet.
@@ -494,13 +492,13 @@ class L0DeviceTy final : public GenericDeviceTy {
MemAllocatorTy &getMemAllocator(int32_t Kind) {
if (Kind == TARGET_ALLOC_HOST)
- return l0Context.getHostMemAllocator();
+ return L0Context.getHostMemAllocator();
return getDeviceMemAllocator();
}
MemAllocatorTy &getMemAllocator(const void *Ptr) {
if (ZE_MEMORY_TYPE_HOST == getMemAllocType(Ptr))
- return l0Context.getHostMemAllocator();
+ return L0Context.getHostMemAllocator();
return getDeviceMemAllocator();
}
diff --git a/offload/plugins-nextgen/level_zero/include/L0Event.h b/offload/plugins-nextgen/level_zero/include/L0Event.h
index 7f4c74e504256..c5a193c6c0b88 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Event.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Event.h
@@ -19,6 +19,7 @@
#include "L0Defs.h"
#include "L0Trace.h"
+#include "PluginInterface.h"
namespace llvm::omp::target::plugin {
diff --git a/offload/plugins-nextgen/level_zero/include/L0Interop.h b/offload/plugins-nextgen/level_zero/include/L0Interop.h
index 20a7fa32ae8d4..52bd1379de51b 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Interop.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Interop.h
@@ -13,6 +13,8 @@
#ifndef OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_L0INTEROP_H
#define OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_L0INTEROP_H
+#include <level_zero/ze_api.h>
+
namespace llvm::omp::target::plugin::L0Interop {
/// Level Zero interop property.
diff --git a/offload/plugins-nextgen/level_zero/include/L0Kernel.h b/offload/plugins-nextgen/level_zero/include/L0Kernel.h
index d70522a9ab7a9..34d14ceaf6f9f 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Kernel.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Kernel.h
@@ -62,10 +62,10 @@ class L0KernelTy : public GenericKernelTy {
Error buildKernel(L0ProgramTy &Program);
Error readKernelProperties(L0ProgramTy &Program);
- ze_group_size_t createKernelGroups(L0DeviceTy &l0Device, L0LaunchEnvTy &KEnv,
+ ze_group_size_t createKernelGroups(L0DeviceTy &L0Device, L0LaunchEnvTy &KEnv,
uint32_t NumThreads[3],
uint32_t NumBlocks[3]) const;
- Error setIndirectFlags(L0DeviceTy &l0Device, L0LaunchEnvTy &KEnv) const;
+ Error setIndirectFlags(L0DeviceTy &L0Device, L0LaunchEnvTy &KEnv) const;
public:
/// Create a L0 kernel with a name and an execution mode.
diff --git a/offload/plugins-nextgen/level_zero/include/L0Memory.h b/offload/plugins-nextgen/level_zero/include/L0Memory.h
index e666062d005eb..6b80d8b51be34 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Memory.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Memory.h
@@ -15,13 +15,13 @@
#include <cassert>
#include <level_zero/ze_api.h>
-#include <list>
#include <map>
#include <memory>
#include <mutex>
#include "L0Defs.h"
#include "L0Trace.h"
+#include "PluginInterface.h"
namespace llvm::omp::target::plugin {
@@ -457,7 +457,7 @@ class StagingBufferTy {
~StagingBufferTy() = default;
Error clear() {
- for (auto Ptr : Buffers)
+ for (auto* Ptr : Buffers)
CALL_ZE_RET_ERROR(zeMemFree, Context, Ptr);
Context = nullptr;
return Plugin::success();
diff --git a/offload/plugins-nextgen/level_zero/include/L0Options.h b/offload/plugins-nextgen/level_zero/include/L0Options.h
index 9f6bbbd3140f7..a2dd3c8968034 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Options.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Options.h
@@ -15,6 +15,7 @@
#include <level_zero/ze_api.h>
+#include "llvm/Support/Allocator.h"
#include "Shared/EnvironmentVar.h"
#include "L0Defs.h"
diff --git a/offload/plugins-nextgen/level_zero/include/L0Plugin.h b/offload/plugins-nextgen/level_zero/include/L0Plugin.h
index 665da5edb0e59..aeaa35e92c384 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Plugin.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Plugin.h
@@ -13,7 +13,6 @@
#ifndef OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_L0PLUGIN_H
#define OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_L0PLUGIN_H
-#include "L0Defs.h"
#include "L0Device.h"
#include "L0Memory.h"
#include "L0Options.h"
diff --git a/offload/plugins-nextgen/level_zero/include/L0Program.h b/offload/plugins-nextgen/level_zero/include/L0Program.h
index 037464b31fc17..af2d0a05f7e3b 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Program.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Program.h
@@ -83,7 +83,7 @@ class L0ProgramTy : public DeviceImageTy {
Modules(std::move(Modules)), GlobalModule(GlobalModule) {}
~L0ProgramTy() = default;
- L0ProgramTy(const L0ProgramTy &other) = delete;
+ L0ProgramTy(const L0ProgramTy &Other) = delete;
L0ProgramTy(L0ProgramTy &&) = delete;
L0ProgramTy &operator=(const L0ProgramTy &) = delete;
L0ProgramTy &operator=(const L0ProgramTy &&) = delete;
diff --git a/offload/plugins-nextgen/level_zero/include/L0Queue.h b/offload/plugins-nextgen/level_zero/include/L0Queue.h
index 2957ef558c847..4ef2232c8da06 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Queue.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Queue.h
@@ -13,9 +13,7 @@
#ifndef OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_ASYNCQUEUE_H
#define OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_ASYNCQUEUE_H
-#include "L0Defs.h"
#include "L0Event.h"
-#include "L0Trace.h"
#include "PluginInterface.h"
#include <mutex>
diff --git a/offload/plugins-nextgen/level_zero/include/L0Trace.h b/offload/plugins-nextgen/level_zero/include/L0Trace.h
index 6f97b72e4c636..3099100fe9b9d 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Trace.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Trace.h
@@ -15,8 +15,7 @@
#include "OffloadError.h"
#include "Shared/Debug.h"
-#include "omptarget.h"
-#include <string>
+
#include <level_zero/ze_api.h>
using namespace llvm::offload::debug;
diff --git a/offload/plugins-nextgen/level_zero/src/L0Context.cpp b/offload/plugins-nextgen/level_zero/src/L0Context.cpp
index c1556dc5b37f7..57cdc23b02ae7 100644
--- a/offload/plugins-nextgen/level_zero/src/L0Context.cpp
+++ b/offload/plugins-nextgen/level_zero/src/L0Context.cpp
@@ -16,7 +16,7 @@
namespace llvm::omp::target::plugin {
Error L0ContextTy::init() {
- auto cleanupOnError = [&]() {
+ auto CleanupOnError = [&]() {
if (zeContext) {
zeContextDestroy(zeContext);
zeContext = nullptr;
@@ -41,13 +41,13 @@ Error L0ContextTy::init() {
if (auto Err = EventPool.init(zeContext, UseCounterBasedEvents,
/* Flags */ 0)) {
- cleanupOnError();
+ CleanupOnError();
return Err;
}
if (auto Err = HostMemAllocator.initHostPool(*this, Plugin.getOptions())) {
if (auto DeinitErr = EventPool.deinit())
Err = joinErrors(std::move(Err), std::move(DeinitErr));
- cleanupOnError();
+ CleanupOnError();
return Err;
}
diff --git a/offload/plugins-nextgen/level_zero/src/L0Device.cpp b/offload/plugins-nextgen/level_zero/src/L0Device.cpp
index 5b728e5d1cc7e..076dfa080f86e 100644
--- a/offload/plugins-nextgen/level_zero/src/L0Device.cpp
+++ b/offload/plugins-nextgen/level_zero/src/L0Device.cpp
@@ -21,7 +21,6 @@
#include "GlobalHandler.h"
#include "OffloadAPI.h"
#include "llvm/ADT/ScopeExit.h"
-#include "llvm/Object/ELF.h"
#include "llvm/Support/Error.h"
namespace llvm::omp::target::plugin {
@@ -29,8 +28,8 @@ namespace llvm::omp::target::plugin {
// clang-format off
/// Mapping from device arch to GPU runtime's device identifiers.
static struct {
- DeviceArchTy arch;
- PCIIdTy ids[10];
+ DeviceArchTy Arch;
+ PCIIdTy Ids[10];
} DeviceArchMap[] = {{DeviceArchTy::DeviceArch_Gen,
{PCIIdTy::SKL,
PCIIdTy::KBL,
@@ -73,13 +72,13 @@ DeviceArchTy L0DeviceTy::computeArch() const {
}
for (int ArchIndex = 0; ArchIndex < DeviceArchMapSize; ArchIndex++) {
- for (int i = 0;; i++) {
- const auto Id = DeviceArchMap[ArchIndex].ids[i];
+ for (int IdIndex = 0;; IdIndex++) {
+ const auto Id = DeviceArchMap[ArchIndex].Ids[IdIndex];
if (Id == PCIIdTy::None)
break;
- auto maskedId = static_cast<PCIIdTy>(PCIDeviceId & 0xFF00);
- if (maskedId == Id)
- return DeviceArchMap[ArchIndex].arch; // Exact match or prefix match.
+ auto MaskedId = static_cast<PCIIdTy>(PCIDeviceId & 0xFF00);
+ if (MaskedId == Id)
+ return DeviceArchMap[ArchIndex].Arch; // Exact match or prefix match.
}
}
@@ -188,10 +187,10 @@ Error L0DeviceTy::initImpl(GenericPluginTy &Plugin) {
IndirectAccessFlags = Flags;
// Get the UUID.
- std::string uid;
- for (int n = 0; n < ZE_MAX_DEVICE_UUID_SIZE; n++)
- uid += std::to_string(DeviceProperties.uuid.id[n]);
- DeviceUuid = std::move(uid);
+ std::string Uid;
+ for (int UidByte = 0; UidByte < ZE_MAX_DEVICE_UUID_SIZE; UidByte++)
+ Uid += std::to_string(DeviceProperties.uuid.id[UidByte]);
+ DeviceUuid = std::move(Uid);
auto QueueGroupInfoOrErr = scanQueueGroups();
if (!QueueGroupInfoOrErr)
@@ -201,7 +200,7 @@ Error L0DeviceTy::initImpl(GenericPluginTy &Plugin) {
if (auto Err = MemAllocator.initDevicePools(*this, Options))
return Err;
- l0Context.getHostMemAllocator().updateMaxAllocSize(*this);
+ L0Context.getHostMemAllocator().updateMaxAllocSize(*this);
reportDeviceInfo();
return Plugin::success();
}
@@ -568,7 +567,7 @@ Expected<GenericKernelTy &> L0DeviceTy::constructKernel(const char *Name) {
}
uint32_t L0DeviceTy::getMemAllocType(const void *Ptr) const {
- ze_memory_allocation_properties_t properties = {
+ ze_memory_allocation_properties_t Properties = {
ZE_STRUCTURE_TYPE_MEMORY_ALLOCATION_PROPERTIES,
nullptr, // Extension.
ZE_MEMORY_TYPE_UNKNOWN, // Type.
@@ -576,14 +575,14 @@ uint32_t L0DeviceTy::getMemAllocType(const void *Ptr) const {
0, // Page size.
};
- ze_result_t rc;
- CALL_ZE(rc, zeMemGetAllocProperties, getZeContext(), Ptr, &properties,
+ ze_result_t Res;
+ CALL_ZE(Res, zeMemGetAllocProperties, getZeContext(), Ptr, &Properties,
nullptr);
- if (rc == ZE_RESULT_ERROR_INVALID_ARGUMENT)
+ if (Res == ZE_RESULT_ERROR_INVALID_ARGUMENT)
return ZE_MEMORY_TYPE_UNKNOWN;
- else
- return properties.type;
+
+ return Properties.type;
}
interop_spec_t L0DeviceTy::selectInteropPreference(int32_t InteropType,
@@ -599,7 +598,7 @@ interop_spec_t L0DeviceTy::selectInteropPreference(int32_t InteropType,
Expected<OmpInteropTy> L0DeviceTy::createInterop(int32_t InteropContext,
interop_spec_t &InteropSpec) {
- auto Ret = new omp_interop_val_t(
+ auto *Ret = new omp_interop_val_t(
DeviceId, static_cast<kmp_interop_type_t>(InteropContext));
Ret->fr_id = tgt_fr_level_zero;
Ret->vendor_id = omp_vendor_intel;
@@ -624,7 +623,7 @@ Expected<OmpInteropTy> L0DeviceTy::createInterop(int32_t InteropContext,
delete Ret;
});
- auto L0 = static_cast<L0Interop::Property *>(Ret->rtl_property);
+ auto *L0 = static_cast<L0Interop::Property *>(Ret->rtl_property);
bool InOrder = InteropSpec.attrs.inorder;
Ret->attrs.inorder = InOrder;
@@ -648,7 +647,7 @@ Error L0DeviceTy::releaseInterop(OmpInteropTy Interop) {
"Invalid/inconsistent OpenMP interop " DPxMOD "\n",
DPxPTR(Interop));
}
- auto L0 = static_cast<L0Interop::Property *>(Interop->rtl_property);
+ auto *L0 = static_cast<L0Interop::Property *>(Interop->rtl_property);
if (Interop->async_info && Interop->async_info->Queue) {
auto ImmCmdList = L0->ImmCmdList;
CALL_ZE_RET_ERROR(zeCommandListDestroy, ImmCmdList);
diff --git a/offload/plugins-nextgen/level_zero/src/L0Event.cpp b/offload/plugins-nextgen/level_zero/src/L0Event.cpp
index a541b852972d5..e6458f63ea9f8 100644
--- a/offload/plugins-nextgen/level_zero/src/L0Event.cpp
+++ b/offload/plugins-nextgen/level_zero/src/L0Event.cpp
@@ -11,7 +11,6 @@
//===----------------------------------------------------------------------===//
#include "L0Event.h"
-#include "L0Device.h"
#include "L0Trace.h"
namespace llvm::omp::target::plugin {
diff --git a/offload/plugins-nextgen/level_zero/src/L0Kernel.cpp b/offload/plugins-nextgen/level_zero/src/L0Kernel.cpp
index 53209c2269bda..2b5d63cc73fb3 100644
--- a/offload/plugins-nextgen/level_zero/src/L0Kernel.cpp
+++ b/offload/plugins-nextgen/level_zero/src/L0Kernel.cpp
@@ -12,13 +12,12 @@
#include "L0Kernel.h"
#include "L0Device.h"
-#include "L0Plugin.h"
#include "L0Program.h"
namespace llvm::omp::target::plugin {
Error L0KernelTy::readKernelProperties(L0ProgramTy &Program) {
- const auto &l0Device = L0DeviceTy::makeL0Device(Program.getDevice());
+ const auto &L0Device = L0DeviceTy::makeL0Device(Program.getDevice());
auto &KernelPR = getProperties();
ze_kernel_properties_t KP = {};
KP.stype = ZE_STRUCTURE_TYPE_KERNEL_PROPERTIES;
@@ -26,7 +25,7 @@ Error L0KernelTy::readKernelProperties(L0ProgramTy &Program) {
ze_kernel_preferred_group_size_properties_t KPrefGRPSize = {};
KPrefGRPSize.stype = ZE_STRUCTURE_TYPE_KERNEL_PREFERRED_GROUP_SIZE_PROPERTIES;
KPrefGRPSize.pNext = nullptr;
- if (l0Device.getDriverAPIVersion() >= ZE_API_VERSION_1_2)
+ if (L0Device.getDriverAPIVersion() >= ZE_API_VERSION_1_2)
KP.pNext = &KPrefGRPSize;
CALL_ZE_RET_ERROR(zeKernelGetProperties, zeKernel, &KP);
@@ -37,13 +36,13 @@ Error L0KernelTy::readKernelProperties(L0ProgramTy &Program) {
if (KP.pNext)
KernelPR.Width = KPrefGRPSize.preferredMultiple;
- if (!l0Device.isDeviceArch(DeviceArchTy::DeviceArch_Gen)) {
+ if (!L0Device.isDeviceArch(DeviceArchTy::DeviceArch_Gen)) {
KernelPR.Width = (std::max)(KernelPR.Width, 2 * KernelPR.SIMDWidth);
}
KernelPR.MaxThreadGroupSize = KP.maxSubgroupSize * KP.maxNumSubgroups;
// Query and cache argument sizes if extension is available.
- auto &Context = l0Device.getL0Context();
+ auto &Context = L0Device.getL0Context();
if (KernelPR.NumKernelArgs > 0 && Context.zexKernelGetArgumentSize) {
KernelPR.ArgSizes = std::make_unique<uint32_t[]>(KernelPR.NumKernelArgs);
for (uint32_t I = 0; I < KernelPR.NumKernelArgs; I++) {
@@ -83,7 +82,7 @@ Error L0KernelTy::initImpl(GenericDeviceTy &GenericDevice,
return Plugin::success();
}
-ze_group_size_t L0KernelTy::createKernelGroups(L0DeviceTy &l0Device,
+ze_group_size_t L0KernelTy::createKernelGroups(L0DeviceTy &L0Device,
L0LaunchEnvTy &KEnv,
uint32_t NumThreads[3],
uint32_t NumBlocks[3]) const {
@@ -99,7 +98,7 @@ ze_group_size_t L0KernelTy::createKernelGroups(L0DeviceTy &l0Device,
KEnv.GroupSizes.groupSizeY = std::min<uint32_t>(MaxGroupSize, NumThreads[1]);
KEnv.GroupSizes.groupSizeZ = std::min<uint32_t>(MaxGroupSize, NumThreads[2]);
- auto DeviceId = l0Device.getDeviceId();
+ auto DeviceId = L0Device.getDeviceId();
INFO(OMP_INFOTYPE_PLUGIN_KERNEL, DeviceId,
"Team sizes = {%" PRIu32 ", %" PRIu32 ", %" PRIu32 "}\n",
KEnv.GroupSizes.groupSizeX, KEnv.GroupSizes.groupSizeY,
@@ -112,16 +111,16 @@ ze_group_size_t L0KernelTy::createKernelGroups(L0DeviceTy &l0Device,
return KEnv.GroupSizes;
}
-Error L0KernelTy::setIndirectFlags(L0DeviceTy &l0Device,
+Error L0KernelTy::setIndirectFlags(L0DeviceTy &L0Device,
L0LaunchEnvTy &KEnv) const {
// Set Kernel Indirect flags.
ze_kernel_indirect_access_flags_t Flags = 0;
- Flags |= l0Device.getMemAllocator(TARGET_ALLOC_HOST).getIndirectFlags();
- Flags |= l0Device.getMemAllocator(TARGET_ALLOC_DEVICE).getIndirectFlags();
+ Flags |= L0Device.getMemAllocator(TARGET_ALLOC_HOST).getIndirectFlags();
+ Flags |= L0Device.getMemAllocator(TARGET_ALLOC_DEVICE).getIndirectFlags();
if (KEnv.KernelPR.IndirectAccessFlags != Flags) {
// Combine with common access flags.
- const auto FinalFlags = l0Device.getIndirectFlags() | Flags;
+ const auto FinalFlags = L0Device.getIndirectFlags() | Flags;
CALL_ZE_RET_ERROR(zeKernelSetIndirectAccess, zeKernel, FinalFlags);
ODBG(OLDT_Kernel) << "Setting indirect access flags "
<< reinterpret_cast<void *>(FinalFlags);
@@ -140,24 +139,24 @@ Error L0KernelTy::launchImpl(GenericDeviceTy &GenericDevice,
return Plugin::error(ErrorCode::UNSUPPORTED,
"dynamic shared memory is unsupported in L0 plugin");
- auto &l0Device = L0DeviceTy::makeL0Device(GenericDevice);
+ auto &L0Device = L0DeviceTy::makeL0Device(GenericDevice);
__tgt_async_info *AsyncInfo = AsyncInfoWrapper;
assert(AsyncInfo && "AsyncInfo must be provided for L0 kernel launch");
auto zeKernel = getZeKernel();
- auto DeviceId = l0Device.getDeviceId();
+ auto DeviceId = L0Device.getDeviceId();
INFO(OMP_INFOTYPE_PLUGIN_KERNEL, DeviceId, "Launching kernel " DPxMOD "...\n",
DPxPTR(zeKernel));
- auto *IdStr = l0Device.getZeIdCStr();
+ auto *IdStr = L0Device.getZeIdCStr();
bool IsCooperative = KernelArgs.Flags.Cooperative;
- if (IsCooperative && !l0Device.supportsCooperativeKernels()) {
+ if (IsCooperative && !L0Device.supportsCooperativeKernels()) {
return Plugin::error(
ErrorCode::UNSUPPORTED,
"cooperative kernel launch is not supported by the device");
}
- auto QueueOrErr = l0Device.getOrCreateQueue(AsyncInfo);
+ auto QueueOrErr = L0Device.getOrCreateQueue(AsyncInfo);
if (!QueueOrErr)
return QueueOrErr.takeError();
auto *Queue = *QueueOrErr;
@@ -168,7 +167,7 @@ Error L0KernelTy::launchImpl(GenericDeviceTy &GenericDevice,
// Protect from kernel preparation to submission as kernels are shared.
KEnv.Lock.lock();
- createKernelGroups(l0Device, KEnv, NumThreads, NumBlocks);
+ createKernelGroups(L0Device, KEnv, NumThreads, NumBlocks);
// Validate cooperative kernel launch constraints
if (IsCooperative) {
@@ -203,7 +202,7 @@ Error L0KernelTy::launchImpl(GenericDeviceTy &GenericDevice,
"expected by the kernel (%u)",
LaunchParams.NumArgs, KernelPR.NumKernelArgs);
- if (auto Err = setIndirectFlags(l0Device, KEnv))
+ if (auto Err = setIndirectFlags(L0Device, KEnv))
return Err;
// The next call should unlock the KernelLock internally.
diff --git a/offload/plugins-nextgen/level_zero/src/L0Memory.cpp b/offload/plugins-nextgen/level_zero/src/L0Memory.cpp
index 7aa25ea529d08..c8098d37b2ef2 100644
--- a/offload/plugins-nextgen/level_zero/src/L0Memory.cpp
+++ b/offload/plugins-nextgen/level_zero/src/L0Memory.cpp
@@ -12,7 +12,6 @@
#include "L0Memory.h"
#include "L0Device.h"
-#include "L0Plugin.h"
namespace llvm::omp::target::plugin {
@@ -654,24 +653,24 @@ Expected<void *> MemAllocatorTy::allocFromL0(size_t Size, size_t Align,
HostDesc.pNext = &RelaxedDesc;
}
- auto ZeDevice = Device ? Device->getZeDevice() : nullptr;
- auto ZeContext = L0Context->getZeContext();
+ auto zeDevice = Device ? Device->getZeDevice() : nullptr;
+ auto zeContext = L0Context->getZeContext();
bool MakeResident = false;
switch (Kind) {
case TARGET_ALLOC_DEVICE:
MakeResident = true;
- CALL_ZE_RET_ERROR(zeMemAllocDevice, ZeContext, &DeviceDesc, Size, Align,
- ZeDevice, &Mem);
+ CALL_ZE_RET_ERROR(zeMemAllocDevice, zeContext, &DeviceDesc, Size, Align,
+ zeDevice, &Mem);
ODBG(OLDT_Alloc) << "Allocated " << Size << " bytes of device memory "
<< Mem;
break;
case TARGET_ALLOC_HOST:
- CALL_ZE_RET_ERROR(zeMemAllocHost, ZeContext, &HostDesc, Size, Align, &Mem);
+ CALL_ZE_RET_ERROR(zeMemAllocHost, zeContext, &HostDesc, Size, Align, &Mem);
ODBG(OLDT_Alloc) << "Allocated " << Size << " bytes of host memory " << Mem;
break;
case TARGET_ALLOC_SHARED:
- CALL_ZE_RET_ERROR(zeMemAllocShared, ZeContext, &DeviceDesc, &HostDesc, Size,
- Align, ZeDevice, &Mem);
+ CALL_ZE_RET_ERROR(zeMemAllocShared, zeContext, &DeviceDesc, &HostDesc, Size,
+ Align, zeDevice, &Mem);
ODBG(OLDT_Alloc) << "Allocated " << Size << " bytes of shared memory "
<< Mem;
break;
diff --git a/offload/plugins-nextgen/level_zero/src/L0Options.cpp b/offload/plugins-nextgen/level_zero/src/L0Options.cpp
index e7294db1b8195..63b29c0f759fd 100644
--- a/offload/plugins-nextgen/level_zero/src/L0Options.cpp
+++ b/offload/plugins-nextgen/level_zero/src/L0Options.cpp
@@ -12,9 +12,7 @@
#include "omptarget.h"
-#include "L0Defs.h"
#include "L0Options.h"
-#include "L0Trace.h"
namespace llvm::omp::target::plugin {
diff --git a/offload/plugins-nextgen/level_zero/src/L0Program.cpp b/offload/plugins-nextgen/level_zero/src/L0Program.cpp
index 2df6f5da34e98..6b1ca68322bb1 100644
--- a/offload/plugins-nextgen/level_zero/src/L0Program.cpp
+++ b/offload/plugins-nextgen/level_zero/src/L0Program.cpp
@@ -10,7 +10,6 @@
//
//===----------------------------------------------------------------------===//
-#include <fstream>
#ifdef _WIN32
#include <fcntl.h>
#include <io.h>
@@ -63,9 +62,9 @@ Error L0ProgramTy::deinit() {
Error L0ProgramBuilderTy::addModule(size_t Size, const uint8_t *Image,
const std::string_view CommonBuildOptions,
ze_module_format_t Format) {
- auto &l0Device = getL0Device();
+ auto &L0Device = getL0Device();
const ze_module_constants_t SpecConstants =
- l0Device.getPlugin()
+ L0Device.getPlugin()
.getOptions()
.CommonSpecConstants.getModuleConstants();
@@ -87,7 +86,7 @@ Error L0ProgramBuilderTy::addModule(size_t Size, const uint8_t *Image,
ModuleDesc.pBuildFlags = BuildOptions.c_str();
ModuleDesc.pConstants = &SpecConstants;
ze_result_t RC;
- CALL_ZE(RC, zeModuleCreate, l0Device.getZeContext(), l0Device.getZeDevice(),
+ CALL_ZE(RC, zeModuleCreate, L0Device.getZeContext(), L0Device.getZeDevice(),
&ModuleDesc, &Module, &BuildLog);
if (BuildLog)
zeModuleBuildLogDestroy(BuildLog);
@@ -119,12 +118,12 @@ Error L0ProgramBuilderTy::addModule(size_t Size, const uint8_t *Image,
if (Modules.empty())
GlobalModule = Module;
Modules.push_back(Module);
- l0Device.addGlobalModule(Module);
+ L0Device.addGlobalModule(Module);
return Plugin::success();
}
Error L0ProgramBuilderTy::linkModules() {
- auto &l0Device = getL0Device();
+ auto &L0Device = getL0Device();
if (!RequiresModuleLink) {
ODBG(OLDT_Module) << "Module link is not required";
return Plugin::success();
@@ -136,8 +135,8 @@ Error L0ProgramBuilderTy::linkModules() {
ze_module_build_log_handle_t LinkLog = nullptr;
CALL_ZE_RET_ERROR(zeModuleDynamicLink,
- static_cast<uint32_t>(l0Device.getNumGlobalModules()),
- l0Device.getGlobalModulesArray(), &LinkLog);
+ static_cast<uint32_t>(L0Device.getNumGlobalModules()),
+ L0Device.getGlobalModulesArray(), &LinkLog);
return Plugin::success();
}
@@ -178,7 +177,7 @@ bool isValidOneOmpImage(StringRef Image, uint64_t &MajorVer,
return false;
}
bool Res = false;
- auto processObjF = [&](const auto ELFObjF) {
+ auto ProcessObjF = [&](const auto ELFObjF) {
if (!ELFObjF) {
ODBG(OLDT_Module) << "Warning: Unexpected ELF type!";
return false;
@@ -223,10 +222,10 @@ bool isValidOneOmpImage(StringRef Image, uint64_t &MajorVer,
return SeenOffloadSection;
};
if (const auto *O = dyn_cast<ELF64LEObjectFile>((*ExpectedNewE).get())) {
- Res = processObjF(O);
+ Res = ProcessObjF(O);
} else if (const auto *O =
dyn_cast<ELF32LEObjectFile>((*ExpectedNewE).get())) {
- Res = processObjF(O);
+ Res = ProcessObjF(O);
} else {
assert(false && "Unexpected ELF format");
}
@@ -234,7 +233,7 @@ bool isValidOneOmpImage(StringRef Image, uint64_t &MajorVer,
}
Error L0ProgramBuilderTy::buildModules(const std::string_view BuildOptions) {
- auto &l0Device = getL0Device();
+ auto &L0Device = getL0Device();
auto Image = getMemoryBuffer();
// Check if image is an inner OffloadBinary (nested format)
@@ -279,7 +278,7 @@ Error L0ProgramBuilderTy::buildModules(const std::string_view BuildOptions) {
Options += " " + CompileOpts.str();
if (!LinkOpts.empty())
Options += " " + LinkOpts.str();
- replaceDriverOptsWithBackendOpts(l0Device, Options);
+ replaceDriverOptsWithBackendOpts(L0Device, Options);
ODBG(OLDT_Module) << "Using compile options: " << CompileOpts
<< ", link options: " << LinkOpts;
}
@@ -340,7 +339,7 @@ Error L0ProgramBuilderTy::buildModules(const std::string_view BuildOptions) {
auto ExpectedNewE = ELFObjectFileBase::createELFObjectFile(Image);
assert(ExpectedNewE &&
"isValidOneOmpImage() returns true for invalid ELF image");
- auto processELF = [&](auto *EObj) {
+ auto ProcessELF = [&](auto *EObj) {
assert(EObj && "isValidOneOmpImage() returns true for invalid ELF image.");
const auto &E = EObj->getELFFile();
// Collect auxiliary information.
@@ -468,9 +467,9 @@ Error L0ProgramBuilderTy::buildModules(const std::string_view BuildOptions) {
};
if (auto *O = dyn_cast<ELF64LEObjectFile>((*ExpectedNewE).get())) {
- processELF(O);
+ ProcessELF(O);
} else if (auto *O = dyn_cast<ELF32LEObjectFile>((*ExpectedNewE).get())) {
- processELF(O);
+ ProcessELF(O);
} else {
assert(false && "Unexpected ELF format");
}
@@ -504,7 +503,7 @@ Error L0ProgramBuilderTy::buildModules(const std::string_view BuildOptions) {
std::string Options(BuildOptions);
{
Options += " " + It->second.CompileOpts + " " + It->second.LinkOpts;
- replaceDriverOptsWithBackendOpts(l0Device, Options);
+ replaceDriverOptsWithBackendOpts(L0Device, Options);
}
for (size_t I = 0; I < NumParts; I++) {
diff --git a/offload/plugins-nextgen/level_zero/src/L0Queue.cpp b/offload/plugins-nextgen/level_zero/src/L0Queue.cpp
index 767c84ff80fe7..5c0ec4ad0d6c0 100644
--- a/offload/plugins-nextgen/level_zero/src/L0Queue.cpp
+++ b/offload/plugins-nextgen/level_zero/src/L0Queue.cpp
@@ -15,7 +15,6 @@
#include "L0Kernel.h"
#include "L0Plugin.h"
#include "llvm/ADT/ScopeExit.h"
-#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
@@ -76,7 +75,7 @@ Error L0QueueTy::memoryFill(void *Ptr, const void *Pattern, size_t PatternSize,
return memoryFillImpl(Ptr, Pattern, PatternSize, Size);
}
- auto PatternBytes = static_cast<const unsigned char *>(Pattern);
+ auto *PatternBytes = static_cast<const unsigned char *>(Pattern);
// Check if all bytes are equal.
if (std::memcmp(PatternBytes, PatternBytes + 1, PatternSize - 1) == 0) {
// Substitution of 1 as PatternSize is equivalent,
@@ -181,15 +180,15 @@ void L0AsyncQueueTy::resetImpl() {
}
void L0AsyncQueueTy::processCopyQueues() {
- auto processQueue = [](auto &Queue) {
+ auto ProcessQueue = [](auto &Queue) {
for (auto &[Src, Dst, Size] : Queue)
std::copy_n(static_cast<const char *>(Src), Size,
static_cast<char *>(Dst));
Queue.clear();
};
- processQueue(USM2MList);
- processQueue(H2MList);
+ ProcessQueue(USM2MList);
+ ProcessQueue(H2MList);
}
Error L0AsyncQueueTy::synchronizeImpl() {
>From f6b6ddff6f6ffde8cf6f972746f52be795b76641 Mon Sep 17 00:00:00 2001
From: blazej-smorawski <blazej.smorawski at intel.com>
Date: Fri, 24 Jul 2026 12:06:34 +0200
Subject: [PATCH 2/2] [offload] Fix format after style alignment
---
offload/plugins-nextgen/level_zero/include/L0Memory.h | 2 +-
offload/plugins-nextgen/level_zero/include/L0Options.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/offload/plugins-nextgen/level_zero/include/L0Memory.h b/offload/plugins-nextgen/level_zero/include/L0Memory.h
index 6b80d8b51be34..8f2f3422b770e 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Memory.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Memory.h
@@ -457,7 +457,7 @@ class StagingBufferTy {
~StagingBufferTy() = default;
Error clear() {
- for (auto* Ptr : Buffers)
+ for (auto *Ptr : Buffers)
CALL_ZE_RET_ERROR(zeMemFree, Context, Ptr);
Context = nullptr;
return Plugin::success();
diff --git a/offload/plugins-nextgen/level_zero/include/L0Options.h b/offload/plugins-nextgen/level_zero/include/L0Options.h
index a2dd3c8968034..00f4689e8cef4 100644
--- a/offload/plugins-nextgen/level_zero/include/L0Options.h
+++ b/offload/plugins-nextgen/level_zero/include/L0Options.h
@@ -15,8 +15,8 @@
#include <level_zero/ze_api.h>
-#include "llvm/Support/Allocator.h"
#include "Shared/EnvironmentVar.h"
+#include "llvm/Support/Allocator.h"
#include "L0Defs.h"
More information about the llvm-commits
mailing list