Skip to content

Commit 45cbc85

Browse files
committed
[SYCL][UR][L0] Fix urEnqueueEventsWait
The path for non-immediate command lists was incorrect. queue->synchronize() was called without closing and executing command lists leading to deadlock. Fix this by replacing synchronize() call with executeCommandList()
1 parent 5750198 commit 45cbc85

File tree

1 file changed

+12
-9
lines changed
  • unified-runtime/source/adapters/level_zero

1 file changed

+12
-9
lines changed

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,27 +123,30 @@ ur_result_t urEnqueueEventsWait(
123123
// Lock automatically releases when this goes out of scope.
124124
std::scoped_lock<ur_shared_mutex> lock(Queue->Mutex);
125125

126+
// Get a new command list to be used on this call
127+
ur_command_list_ptr_t CommandList{};
128+
UR_CALL(Queue->Context->getAvailableCommandList(
129+
Queue, CommandList, false, 0, nullptr, false /*AllowBatching*/,
130+
nullptr /*ForceCmdQueue*/));
131+
132+
UR_CALL(Queue->executeCommandList(CommandList, true, false));
133+
126134
if (OutEvent) {
127135
UR_CALL(createEventAndAssociateQueue(Queue, OutEvent,
128136
UR_COMMAND_EVENTS_WAIT,
129137
Queue->CommandListMap.end(), false,
130138
/* IsInternal */ false));
131-
}
132139

133-
UR_CALL(Queue->synchronize());
134-
135-
if (OutEvent) {
136140
Queue->LastCommandEvent = reinterpret_cast<ur_event_handle_t>(*OutEvent);
137141

138142
if (!(*OutEvent)->CounterBasedEventsEnabled)
139143
ZE2UR_CALL(zeEventHostSignal, ((*OutEvent)->ZeEvent));
140144
(*OutEvent)->Completed = true;
141-
}
142-
}
143145

144-
if (!Queue->UsingImmCmdLists) {
145-
std::unique_lock<ur_shared_mutex> Lock(Queue->Mutex);
146-
resetCommandLists(Queue);
146+
if (!Queue->UsingImmCmdLists) {
147+
resetCommandLists(Queue);
148+
}
149+
}
147150
}
148151

149152
return UR_RESULT_SUCCESS;

0 commit comments

Comments
 (0)