Skip to content

Commit 166028d

Browse files
committed
address review comments
1 parent b4e238f commit 166028d

File tree

5 files changed

+28
-16
lines changed

5 files changed

+28
-16
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,6 @@ class MemAllocatorTy {
200200
std::vector<std::pair<uint64_t, uint64_t>> BucketStats;
201201
/// Need to zero-initialize after L0 allocation
202202
bool ZeroInit = false;
203-
/// Zero-initialized values to be copied to device
204-
std::vector<char> ZeroInitValue;
205203

206204
/// Get bucket ID from the specified allocation size.
207205
uint32_t getBucketId(size_t Size) {
@@ -394,6 +392,10 @@ class MemAllocatorTy {
394392

395393
/// Perform copy operation
396394
int32_t enqueueMemCopy(void *Dst, const void *Src, size_t Size);
395+
396+
/// Perform memory fill operation
397+
int32_t enqueueMemSet(void *Dst, int8_t Value, size_t Size);
398+
397399
}; /// MemAllocatorTy
398400

399401
// simple generic wrapper to reuse objects

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -701,14 +701,12 @@ int32_t L0DeviceTy::enqueueMemCopy(void *Dst, const void *Src, size_t Size,
701701
bool UseCopyEngine) {
702702
ze_command_list_handle_t CmdList = nullptr;
703703
ze_command_queue_handle_t CmdQueue = nullptr;
704-
ze_event_handle_t Event = nullptr;
705704

706705
if (useImmForCopy()) {
707706
CmdList = UseCopyEngine ? getImmCopyCmdList() : getImmCmdList();
708-
Event = getEvent();
709707
CALL_ZE_RET_FAIL(zeCommandListAppendMemoryCopy, CmdList, Dst, Src, Size,
710-
Event, 0, nullptr);
711-
CALL_ZE_RET_FAIL(zeEventHostSynchronize, Event, UINT64_MAX);
708+
nullptr, 0, nullptr);
709+
CALL_ZE_RET_FAIL(zeCommandListHostSynchronize, CmdList, UINT64_MAX);
712710
} else {
713711
if (UseCopyEngine) {
714712
CmdList = getCopyCmdList();
@@ -719,7 +717,7 @@ int32_t L0DeviceTy::enqueueMemCopy(void *Dst, const void *Src, size_t Size,
719717
}
720718

721719
CALL_ZE_RET_FAIL(zeCommandListAppendMemoryCopy, CmdList, Dst, Src, Size,
722-
Event, 0, nullptr);
720+
nullptr, 0, nullptr);
723721
CALL_ZE_RET_FAIL(zeCommandListClose, CmdList);
724722
CALL_ZE_RET_FAIL_MTX(zeCommandQueueExecuteCommandLists, getMutex(),
725723
CmdQueue, 1, &CmdList, nullptr);

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ MemAllocatorTy::MemPoolTy::MemPoolTy(MemAllocatorTy *_Allocator) {
174174
BucketStats.resize(1, {0, 0});
175175
BucketParams.emplace_back(AllocMax, AllocUnit);
176176
ZeroInit = true;
177-
ZeroInitValue.resize(AllocUnit, 0);
178177
DP("Initialized zero-initialized reduction counter pool for "
179178
"device " DPxMOD ": AllocMin = %zu, AllocMax = %zu, PoolSizeMax = %zu\n",
180179
DPxPTR(Allocator->Device), AllocMin, AllocMax, PoolSizeMax);
@@ -266,7 +265,7 @@ void *MemAllocatorTy::MemPoolTy::alloc(size_t Size, size_t &AllocSize) {
266265

267266
if (ZeroInit) {
268267
auto RC =
269-
Allocator->enqueueMemCopy(Base, ZeroInitValue.data(), BlockSize);
268+
Allocator->enqueueMemSet(Base, 0, BlockSize);
270269
if (RC != OFFLOAD_SUCCESS) {
271270
DP("Failed to zero-initialize pool memory\n");
272271
return nullptr;
@@ -549,6 +548,10 @@ Error MemAllocatorTy::dealloc_locked(void *Ptr) {
549548
return Plugin::success();
550549
}
551550

551+
int32_t MemAllocatorTy::enqueueMemSet(void *Dst, int8_t Value, size_t Size) {
552+
return Device->enqueueMemFill(Dst, &Value, sizeof(int8_t), Size);
553+
}
554+
552555
int32_t MemAllocatorTy::enqueueMemCopy(void *Dst, const void *Src,
553556
size_t Size) {
554557
return Device->enqueueMemCopy(Dst, Src, Size);

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,8 @@ Error LevelZeroPluginTy::syncBarrierImpl(omp_interop_val_t *Interop) {
214214
" with ImmCmdList barrier\n",
215215
DPxPTR(Interop));
216216
auto ImmCmdList = L0->ImmCmdList;
217-
auto Event = l0Device.getEvent();
218217

219-
CALL_ZE_RET_ERROR(zeCommandListAppendBarrier, ImmCmdList, Event, 0,
220-
nullptr);
221-
CALL_ZE_RET_ERROR(zeEventHostSynchronize, Event, UINT64_MAX);
222-
l0Device.releaseEvent(Event);
218+
CALL_ZE_RET_ERROR(zeCommandListHostSynchronize, ImmCmdList, UINT64_MAX);
223219
} else {
224220
DP("LevelZeroPluginTy::sync_barrier: Synchronizing " DPxMOD
225221
" with queue synchronize\n",
@@ -254,6 +250,8 @@ Error LevelZeroPluginTy::asyncBarrierImpl(omp_interop_val_t *Interop) {
254250
CALL_ZE_RET_ERROR(zeCommandListAppendBarrier, ImmCmdList, nullptr, 0,
255251
nullptr);
256252
} else {
253+
#if 0
254+
// TODO: re-enable once we have a way to delay the CmdList reset
257255
DP("LevelZeroPluginTy::async_barrier: Appending CmdList barrier to " DPxMOD
258256
"\n",
259257
DPxPTR(Interop));
@@ -264,6 +262,9 @@ Error LevelZeroPluginTy::asyncBarrierImpl(omp_interop_val_t *Interop) {
264262
CALL_ZE_RET_ERROR(zeCommandQueueExecuteCommandLists, CmdQueue, 1, &CmdList,
265263
nullptr);
266264
CALL_ZE_RET_ERROR(zeCommandListReset, CmdList);
265+
#else
266+
return syncBarrierImpl(Interop);
267+
#endif
267268
}
268269

269270
return Plugin::success();

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,11 @@ int32_t L0ProgramTy::buildModules(const std::string_view BuildOptions) {
352352
}
353353

354354
uint64_t Idx = 0;
355-
Parts[0].getAsInteger(10, Idx);
355+
if (Parts[0].getAsInteger(10, Idx)) {
356+
DP("Warning: ignoring auxiliary information (invalid index '%s').\n",
357+
Parts[0].str().c_str());
358+
continue;
359+
}
356360
MaxImageIdx = (std::max)(MaxImageIdx, Idx);
357361
if (AuxInfo.find(Idx) != AuxInfo.end()) {
358362
DP("Warning: duplicate auxiliary information for image %" PRIu64
@@ -362,7 +366,11 @@ int32_t L0ProgramTy::buildModules(const std::string_view BuildOptions) {
362366
}
363367

364368
uint64_t Part1Id;
365-
Parts[1].getAsInteger(10, Part1Id);
369+
if (Parts[1].getAsInteger(10, Part1Id)) {
370+
DP("Warning: ignoring auxiliary information (invalid part id '%s').\n",
371+
Parts[1].str().c_str());
372+
continue;
373+
}
366374

367375
AuxInfo.emplace(
368376
std::piecewise_construct, std::forward_as_tuple(Idx),

0 commit comments

Comments
 (0)