@@ -677,7 +677,7 @@ ur_result_t createMainCommandList(ur_context_handle_t Context,
677
677
* @return UR_RESULT_SUCCESS or an error code on failure
678
678
*/
679
679
ur_result_t
680
- waitForOngoingExecution (ur_exp_command_buffer_handle_t CommandBuffer) {
680
+ waitForLastSubmission (ur_exp_command_buffer_handle_t CommandBuffer) {
681
681
682
682
if (ur_event_handle_t &CurrentSubmissionEvent =
683
683
CommandBuffer->CurrentSubmissionEvent ) {
@@ -690,6 +690,30 @@ waitForOngoingExecution(ur_exp_command_buffer_handle_t CommandBuffer) {
690
690
return UR_RESULT_SUCCESS;
691
691
}
692
692
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
+
693
717
/* *
694
718
* Checks whether the command-buffer can be constructed using in order
695
719
* command-lists.
@@ -1743,7 +1767,7 @@ ur_result_t urEnqueueCommandBufferExp(
1743
1767
1744
1768
std::scoped_lock<ur_shared_mutex> Lock (UrQueue->Mutex );
1745
1769
1746
- UR_CALL (waitForOngoingExecution (CommandBuffer));
1770
+ UR_CALL (waitForLastSubmission (CommandBuffer));
1747
1771
1748
1772
const bool IsInternal = (Event == nullptr );
1749
1773
const bool DoProfiling =
0 commit comments