Skip to content

Commit a90b798

Browse files
committed
Move event resets from SignalCommandList to ComputeCommandList
Moves the call to event reset for the WaitEvent and AllResetEvent to the ComputeCommandList. This fixes a potential race condition where, if the SignalCommandList executes before the ComputeCommandList, the WaitEvent could be reset before the ComputeCommandList can wait on it and, consequently, create a deadlock.
1 parent eca90a9 commit a90b798

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

source/adapters/level_zero/command_buffer.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,25 +1683,28 @@ ur_result_t enqueueWaitEventPath(ur_exp_command_buffer_handle_t CommandBuffer,
16831683
(ZeCopyCommandQueue, 1, &CommandBuffer->ZeCopyCommandList, nullptr));
16841684
}
16851685

1686+
ZE2UR_CALL(zeCommandListAppendBarrier,
1687+
(SignalCommandList->first, nullptr, 1,
1688+
&(CommandBuffer->ExecutionFinishedEvent->ZeEvent)));
1689+
16861690
// Reset the wait-event for the UR command-buffer that is signaled when its
16871691
// submission dependencies have been satisfied.
16881692
ZE2UR_CALL(zeCommandListAppendEventReset,
16891693
(SignalCommandList->first, CommandBuffer->WaitEvent->ZeEvent));
1694+
16901695
// Reset the all-reset-event for the UR command-buffer that is signaled when
16911696
// all events of the main command-list have been reset.
16921697
ZE2UR_CALL(zeCommandListAppendEventReset,
16931698
(SignalCommandList->first, CommandBuffer->AllResetEvent->ZeEvent));
16941699

16951700
if (DoProfiling) {
16961701
UR_CALL(appendProfilingQueries(CommandBuffer, SignalCommandList->first,
1697-
*Event,
1698-
CommandBuffer->ExecutionFinishedEvent));
1699-
} else {
1700-
ZE2UR_CALL(zeCommandListAppendBarrier,
1701-
(SignalCommandList->first, (*Event)->ZeEvent, 1,
1702-
&(CommandBuffer->ExecutionFinishedEvent->ZeEvent)));
1702+
nullptr, nullptr));
17031703
}
17041704

1705+
ZE2UR_CALL(zeCommandListAppendBarrier,
1706+
(SignalCommandList->first, (*Event)->ZeEvent, 0, nullptr));
1707+
17051708
UR_CALL(Queue->executeCommandList(SignalCommandList, false /*IsBlocking*/,
17061709
false /*OKToBatchCommand*/));
17071710

0 commit comments

Comments
 (0)