Skip to content

Commit c397c4a

Browse files
Brought back additional fence for wait event path
1 parent 9e8735e commit c397c4a

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ ur_result_t createMainCommandList(ur_context_handle_t Context,
677677
* @return UR_RESULT_SUCCESS or an error code on failure
678678
*/
679679
ur_result_t
680-
waitForOngoingExecution(ur_exp_command_buffer_handle_t CommandBuffer) {
680+
waitForLastSubmission(ur_exp_command_buffer_handle_t CommandBuffer) {
681681

682682
if (ur_event_handle_t &CurrentSubmissionEvent =
683683
CommandBuffer->CurrentSubmissionEvent) {
@@ -690,6 +690,30 @@ waitForOngoingExecution(ur_exp_command_buffer_handle_t CommandBuffer) {
690690
return UR_RESULT_SUCCESS;
691691
}
692692

693+
/**
694+
* Waits for any ongoing executions of the command-buffer to finish
695+
* but put fence in case of wait event path.
696+
* @param CommandBuffer The command-buffer to wait for.
697+
* @return UR_RESULT_SUCCESS or an error code on failure
698+
*/
699+
ur_result_t
700+
waitForOngoingExecution(ur_exp_command_buffer_handle_t CommandBuffer) {
701+
702+
if (CommandBuffer->UseImmediateAppendPath) {
703+
if (ur_event_handle_t &CurrentSubmissionEvent =
704+
CommandBuffer->CurrentSubmissionEvent) {
705+
ZE2UR_CALL(zeEventHostSynchronize,
706+
(CurrentSubmissionEvent->ZeEvent, UINT64_MAX));
707+
UR_CALL(urEventReleaseInternal(CurrentSubmissionEvent));
708+
CurrentSubmissionEvent = nullptr;
709+
}
710+
} else if (ze_fence_handle_t &ZeFence = CommandBuffer->ZeActiveFence) {
711+
ZE2UR_CALL(zeFenceHostSynchronize, (ZeFence, UINT64_MAX));
712+
}
713+
714+
return UR_RESULT_SUCCESS;
715+
}
716+
693717
/**
694718
* Checks whether the command-buffer can be constructed using in order
695719
* command-lists.
@@ -1743,7 +1767,7 @@ ur_result_t urEnqueueCommandBufferExp(
17431767

17441768
std::scoped_lock<ur_shared_mutex> Lock(UrQueue->Mutex);
17451769

1746-
UR_CALL(waitForOngoingExecution(CommandBuffer));
1770+
UR_CALL(waitForLastSubmission(CommandBuffer));
17471771

17481772
const bool IsInternal = (Event == nullptr);
17491773
const bool DoProfiling =

0 commit comments

Comments
 (0)