Skip to content

Commit 10f4701

Browse files
committed
WIP
1 parent c0d9e0e commit 10f4701

File tree

4 files changed

+9
-31
lines changed

4 files changed

+9
-31
lines changed

unified-runtime/source/adapters/level_zero/v2/command_list_manager.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
//
99
//===----------------------------------------------------------------------===//
1010

11-
#include "command_list_manager.hpp"
1211
#include "../helpers/kernel_helpers.hpp"
1312
#include "../helpers/memory_helpers.hpp"
1413
#include "../ur_interface_loader.hpp"
1514
#include "command_buffer.hpp"
15+
#include "command_list_manager.hpp"
1616
#include "context.hpp"
1717
#include "kernel.hpp"
1818
#include "memory.hpp"
@@ -37,7 +37,6 @@ ur_result_t ur_command_list_manager::appendGenericFillUnlocked(
3737
size, zeCommandList.get(), waitListView));
3838

3939
// Store pattern in event if this is an async operation
40-
// This prevents use-after-return bug when pPattern points to stack memory
4140
const void *patternPtr = pPattern;
4241
if (phEvent && zeSignalEvent) {
4342
phEvent->retainFillPattern(pPattern, patternSize);
@@ -46,8 +45,6 @@ ur_result_t ur_command_list_manager::appendGenericFillUnlocked(
4645

4746
// PatternSize must be a power of two for zeCommandListAppendMemoryFill.
4847
// When it's not, the fill is emulated with zeCommandListAppendMemoryCopy.
49-
// WORKAROUND: Level Zero driver rejects zeCommandListAppendMemoryFill when
50-
// patternSize == size, returning ZE_RESULT_ERROR_INVALID_SIZE (0x78000008).
5148
if (isPowerOf2(patternSize) && patternSize != size) {
5249
ZE2UR_CALL(zeCommandListAppendMemoryFill,
5350
(zeCommandList.get(), pDst, patternPtr, patternSize, size,

unified-runtime/source/adapters/level_zero/v2/event.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,15 @@ uint64_t ur_event_handle_t_::getEventEndTimestamp() {
141141
return profilingData.getEventEndTimestamp();
142142
}
143143

144-
void ur_event_handle_t_::retainFillPattern(const void *pPattern, size_t patternSize) {
144+
void ur_event_handle_t_::retainFillPattern(const void *pPattern,
145+
size_t patternSize) {
145146
if (!fillPattern) {
146147
fillPattern.emplace();
147148
}
148-
149+
149150
auto &storage = fillPattern.value();
150151
storage.size = patternSize;
151-
152+
152153
// Small buffer optimization: use inline buffer for patterns <= 16 bytes
153154
if (patternSize <= FillPatternStorage::INLINE_SIZE) {
154155
std::memcpy(storage.inlineBuffer.data(), pPattern, patternSize);

unified-runtime/source/adapters/level_zero/v2/event.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ struct ur_event_handle_t_ : ur_object {
154154
std::vector<uint8_t> heapBuffer;
155155
size_t size = 0;
156156
bool useHeap = false;
157-
158-
const void* data() const {
157+
158+
const void *data() const {
159159
return useHeap ? heapBuffer.data() : inlineBuffer.data();
160160
}
161161
};

unified-runtime/source/loader/layers/sanitizer/sanitizer_common/sanitizer_utils.hpp

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,8 @@ ur_result_t EnqueueUSMSet(ur_queue_handle_t Queue, void *Ptr, T Value,
7575
const ur_event_handle_t *EventWaitList = nullptr,
7676
ur_event_handle_t *OutEvent = nullptr) {
7777
assert(Size % sizeof(T) == 0);
78-
ur_event_handle_t LocalEvent = nullptr;
79-
ur_event_handle_t *EventStorage = OutEvent ? OutEvent : &LocalEvent;
80-
81-
auto Result = getContext()->urDdiTable.Enqueue.pfnUSMFill(
82-
Queue, Ptr, sizeof(T), &Value, Size, NumEvents, EventWaitList,
83-
EventStorage);
84-
if (Result != UR_RESULT_SUCCESS) {
85-
return Result;
86-
}
87-
88-
if (!OutEvent && LocalEvent) {
89-
auto WaitResult = getContext()->urDdiTable.Event.pfnWait(1, &LocalEvent);
90-
auto ReleaseResult = getContext()->urDdiTable.Event.pfnRelease(LocalEvent);
91-
if (WaitResult != UR_RESULT_SUCCESS) {
92-
return WaitResult;
93-
}
94-
if (ReleaseResult != UR_RESULT_SUCCESS) {
95-
return ReleaseResult;
96-
}
97-
}
98-
99-
return Result;
78+
return getContext()->urDdiTable.Enqueue.pfnUSMFill(
79+
Queue, Ptr, sizeof(T), &Value, Size, NumEvents, EventWaitList, OutEvent);
10080
}
10181

10282
void PrintUrBuildLogIfError(ur_result_t Result, ur_program_handle_t Program,

0 commit comments

Comments
 (0)