Skip to content

Commit 8bb25ad

Browse files
committed
fixes
1 parent 40ad342 commit 8bb25ad

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ class MemAllocatorTy {
330330
/// to support target pointer with offset, and positive "ActiveSize" is
331331
/// specified in such cases for correct debug logging.
332332
Expected<void *> allocL0(size_t Size, size_t Align, int32_t Kind,
333-
size_t ActiveSize = 0);
333+
size_t ActiveSize = 0, bool Logging = true);
334334

335335
/// Allocate memory with the specified information from a memory pool
336336
Expected<void *> alloc(size_t Size, size_t Align, int32_t Kind,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ std::pair<uint32_t, uint32_t> L0DeviceTy::findCopyOrdinal(bool LinkCopy) {
156156
}
157157

158158
void L0DeviceTy::reportDeviceInfo() const {
159-
DP("Device %" PRIu32 "\n", DeviceId);
159+
DP("Device %" PRIu32 " information\n", DeviceId);
160160
DP("-- Name : %s\n", getNameCStr());
161161
DP("-- PCI ID : 0x%" PRIx32 "\n", getPCIId());
162162
DP("-- UUID : %s\n", getUuid().data());
@@ -216,6 +216,8 @@ Error L0DeviceTy::initImpl(GenericPluginTy &Plugin) {
216216
if (auto Err = MemAllocator.initDevicePools(*this, Options))
217217
return Err;
218218
l0Context.getHostMemAllocator().updateMaxAllocSize(*this);
219+
if (getDebugLevel() > 0)
220+
reportDeviceInfo();
219221
return Plugin::success();
220222
}
221223

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ Error MemAllocatorTy::MemPoolTy::init(int32_t Kind, MemAllocatorTy *AllocatorIn,
8383

8484
// Check page size used for this allocation kind to decide minimum
8585
// allocation size when allocating from L0.
86-
auto MemOrErr = Allocator->allocL0(8, 0, AllocKind);
86+
auto MemOrErr =
87+
Allocator->allocL0(/* Size=*/8, /*Align=*/0, AllocKind, /*ActiveSize=*/0,
88+
/*Logging=*/false);
8789
if (!MemOrErr)
8890
return MemOrErr.takeError();
8991
void *Mem = *MemOrErr;
@@ -610,7 +612,8 @@ Error MemAllocatorTy::enqueueMemCopy(void *Dst, const void *Src, size_t Size) {
610612
}
611613

612614
Expected<void *> MemAllocatorTy::allocL0(size_t Size, size_t Align,
613-
int32_t Kind, size_t ActiveSize) {
615+
int32_t Kind, size_t ActiveSize,
616+
bool Logging) {
614617
void *Mem = nullptr;
615618
ze_device_mem_alloc_desc_t DeviceDesc{ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC,
616619
nullptr, 0, 0};
@@ -649,8 +652,11 @@ Expected<void *> MemAllocatorTy::allocL0(size_t Size, size_t Align,
649652
assert(0 && "Invalid target data allocation kind");
650653
}
651654

652-
size_t LoggedSize = ActiveSize ? ActiveSize : Size;
653-
log(LoggedSize, LoggedSize, Kind);
655+
if (Logging) {
656+
size_t LoggedSize = ActiveSize ? ActiveSize : Size;
657+
log(LoggedSize, LoggedSize, Kind);
658+
}
659+
654660
if (makeResident) {
655661
assert(Device &&
656662
"Device is not set for memory allocation. Is this a Device Pool?");

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,9 @@ GenericDeviceTy *LevelZeroPluginTy::createDevice(GenericPluginTy &Plugin,
144144
(SubId < 0 ? "" : "." + std::to_string(SubId)) +
145145
(CCSId < 0 ? "" : "." + std::to_string(CCSId));
146146

147-
auto *NewDevice = new L0DeviceTy(
148-
static_cast<LevelZeroPluginTy &>(Plugin), DeviceId, NumDevices, zeDevice,
149-
*zeDriver, std::move(IdStr), CCSId < 0 ? 0 : CCSId /* ComputeIndex */);
150-
if (NewDevice && getDebugLevel() > 0) {
151-
DP("Device %" PRIi32 " information\n", DeviceId);
152-
NewDevice->reportDeviceInfo();
153-
}
154-
return NewDevice;
147+
return new L0DeviceTy(static_cast<LevelZeroPluginTy &>(Plugin), DeviceId,
148+
NumDevices, zeDevice, *zeDriver, std::move(IdStr),
149+
CCSId < 0 ? 0 : CCSId /* ComputeIndex */);
155150
}
156151

157152
GenericGlobalHandlerTy *LevelZeroPluginTy::createGlobalHandler() {

0 commit comments

Comments
 (0)