Skip to content

Commit ab5e53f

Browse files
authored
Merge pull request intel#2481 from Bensuo/fabio/fix_potential_race_condition
Fix potential deadlock in the WaitEvent path of CmdBuffers
2 parents 9c68315 + 017d9cc commit ab5e53f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

source/adapters/level_zero/command_buffer.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -1682,25 +1682,28 @@ ur_result_t enqueueWaitEventPath(ur_exp_command_buffer_handle_t CommandBuffer,
16821682
(ZeCopyCommandQueue, 1, &CommandBuffer->ZeCopyCommandList, nullptr));
16831683
}
16841684

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

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

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

0 commit comments

Comments
 (0)