Skip to content

Commit 6b8280d

Browse files
committed
fix different issues
1 parent 5b90ccb commit 6b8280d

File tree

5 files changed

+34
-16
lines changed

5 files changed

+34
-16
lines changed

offload/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ if(NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64)$" AND
185185
endif()
186186
endif()
187187
if("level_zero" IN_LIST LIBOMPTARGET_PLUGINS_TO_BUILD AND
188-
NOT LIBOMPTARGET_DEP_LEVEL_ZERO_FOUND)
189-
list(REMOVE_ITEM LIBOMPTARGET_PLUGINS_TO_BUILD "level_zero")
188+
NOT LIBOMPTARGET_DEP_LEVEL_ZERO_FOUND)
189+
list(REMOVE_ITEM LIBOMPTARGET_PLUGINS_TO_BUILD "level_zero")
190190
endif()
191191
message(STATUS "Building the offload library with support for "
192192
"the \"${LIBOMPTARGET_PLUGINS_TO_BUILD}\" plugins")

offload/cmake/Modules/LibomptargetGetDependencies.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ endif()
9595
find_path(LIBOMPTARGET_DEP_LEVEL_ZERO_INCLUDE_DIRS NAMES level_zero/ze_api.h)
9696

9797
if(NOT LIBOMPTARGET_DEP_LEVEL_ZERO_INCLUDE_DIRS)
98-
set(LIBOMPTARGET_DEP_LEVEL_ZERO_FOUND FALSE)
98+
set(LIBOMPTARGET_DEP_LEVEL_ZERO_FOUND FALSE)
9999
else()
100100
set(LIBOMPTARGET_DEP_LEVEL_ZERO_FOUND TRUE)
101101
find_library(LIBOMPTARGET_DEP_LEVEL_ZERO_LIBRARIES NAMES ze_loader)

offload/plugins-nextgen/level_zero/include/L0Device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ class L0DeviceTy final : public GenericDeviceTy {
403403
auto getMaxGroupSize() const { return ComputeProperties.maxTotalGroupSize; }
404404
auto getGlobalMemorySize() const { return MemoryProperties.totalSize; }
405405
auto getCacheSize() const { return CacheProperties.cacheSize; }
406+
auto getMaxMemAllocSize() const { return DeviceProperties.maxMemAllocSize; }
406407

407408
int32_t getAllocKind() const { return AllocKind; }
408409
DeviceArchTy getDeviceArch() const { return DeviceArch; }

offload/plugins-nextgen/level_zero/include/L0Options.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,26 @@ enum class CommandModeTy { Sync = 0, Async, AsyncOrdered };
2727
class SpecConstantsTy {
2828
std::vector<uint32_t> ConstantIds;
2929
std::vector<const void *> ConstantValues;
30+
BumpPtrAllocator &Allocator;
3031

3132
public:
32-
SpecConstantsTy() = default;
33+
SpecConstantsTy(BumpPtrAllocator &Allocator) : Allocator(Allocator) {}
3334
SpecConstantsTy(const SpecConstantsTy &) = delete;
3435
SpecConstantsTy(SpecConstantsTy &&) = delete;
3536
SpecConstantsTy &operator=(const SpecConstantsTy &) = delete;
3637
SpecConstantsTy &operator=(const SpecConstantsTy &&) = delete;
3738
SpecConstantsTy(const SpecConstantsTy &&Other)
3839
: ConstantIds(std::move(Other.ConstantIds)),
39-
ConstantValues(std::move(Other.ConstantValues)) {}
40+
ConstantValues(std::move(Other.ConstantValues)),
41+
Allocator(Other.Allocator) {}
4042

4143
~SpecConstantsTy() {
42-
for (auto I : ConstantValues) {
43-
const char *ValuePtr = reinterpret_cast<const char *>(I);
44-
delete[] ValuePtr;
45-
}
4644
}
4745

4846
template <typename T> void addConstant(uint32_t Id, T Val) {
49-
const size_t ValSize = sizeof(Val);
50-
char *ValuePtr = new char[ValSize];
51-
*reinterpret_cast<T *>(ValuePtr) = Val;
47+
T *ValuePtr =
48+
reinterpret_cast<T *>(Allocator.Allocate(sizeof(T), alignof(T)));
49+
*ValuePtr = Val;
5250

5351
ConstantIds.push_back(Id);
5452
ConstantValues.push_back(reinterpret_cast<void *>(ValuePtr));
@@ -134,7 +132,10 @@ struct L0OptionsTy {
134132

135133
bool Init = false; // have the options already been processed
136134

137-
L0OptionsTy() {}
135+
// Allocator for long-lived allocations (e.g. spec constants)
136+
BumpPtrAllocator Allocator;
137+
138+
L0OptionsTy() : CommonSpecConstants(Allocator) {}
138139

139140
/// Read environment variables
140141
void processEnvironmentVars();

offload/plugins-nextgen/level_zero/src/L0Device.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,25 @@ Error L0DeviceTy::initDeviceInfoImpl(__tgt_device_info *Info) {
553553
return Plugin::success();
554554
}
555555

556+
static const char *DriverVersionToStrTable[] = {
557+
"1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6",
558+
"1.7", "1.8", "1.9", "1.10", "1.11", "1.12"};
559+
constexpr size_t DriverVersionToStrTableSize =
560+
sizeof(DriverVersionToStrTable) / sizeof(DriverVersionToStrTable[0]);
561+
556562
Expected<InfoTreeNode> L0DeviceTy::obtainInfoImpl() {
557563
InfoTreeNode Info;
558564
Info.add("Device Number", getDeviceId());
559-
Info.add("Device Name", getNameCStr());
565+
Info.add("Device Name", getNameCStr(), "", DeviceInfo::NAME);
566+
Info.add("Device Type", "GPU", "", DeviceInfo::TYPE);
567+
Info.add("Vendor", "Intel", "", DeviceInfo::VENDOR);
568+
Info.add("Vendor ID", getVendorId(), "", DeviceInfo::VENDOR_ID);
569+
auto DriverVersion = getDriverAPIVersion();
570+
if (DriverVersion < DriverVersionToStrTableSize)
571+
Info.add("Driver Version", DriverVersionToStrTable[DriverVersion], "",
572+
DeviceInfo::DRIVER_VERSION);
573+
else
574+
Info.add("Driver Version", "Unknown", "", DeviceInfo::DRIVER_VERSION);
560575
Info.add("Device PCI ID", getPCIId());
561576
Info.add("Device UUID", getUuid().data());
562577
Info.add("Number of total EUs", getNumEUs());
@@ -566,9 +581,10 @@ Expected<InfoTreeNode> L0DeviceTy::obtainInfoImpl() {
566581
Info.add("Number of subslices per slice", getNumSubslicesPerSlice());
567582
Info.add("Number of slices", getNumSlices());
568583
Info.add("Local memory size (bytes)", getMaxSharedLocalMemory());
569-
Info.add("Global memory size (bytes)", getGlobalMemorySize());
584+
Info.add("Global memory size (bytes)", getGlobalMemorySize(), "", DeviceInfo::GLOBAL_MEM_SIZE);
570585
Info.add("Cache size (bytes)", getCacheSize());
571-
Info.add("Max clock frequency (MHz)", getClockRate());
586+
Info.add("Max Memory Allocation Size (bytes)", getMaxMemAllocSize(), "", DeviceInfo::MAX_MEM_ALLOC_SIZE);
587+
Info.add("Max clock frequency (MHz)", getClockRate(), "" , DeviceInfo::MAX_CLOCK_FREQUENCY);
572588
return Info;
573589
}
574590

0 commit comments

Comments
 (0)