@@ -1753,6 +1753,8 @@ ur_result_t urCommandBufferEnqueueExp(
1753
1753
EventWaitList, OutEvent, ZeCommandListHelper,
1754
1754
DoProfiling));
1755
1755
}
1756
+ // Mark that synchronization will be required for later updates
1757
+ CommandBuffer->NeedsUpdateSynchronization = true ;
1756
1758
1757
1759
return UR_RESULT_SUCCESS;
1758
1760
}
@@ -2117,6 +2119,13 @@ ur_result_t updateKernelCommand(
2117
2119
*/
2118
2120
ur_result_t
2119
2121
waitForOngoingExecution (ur_exp_command_buffer_handle_t CommandBuffer) {
2122
+ // Calling function has taken a lock for the command buffer so we can safely
2123
+ // check and modify this value here.
2124
+ // If command buffer was recently synchronized we can return early.
2125
+ if (!CommandBuffer->NeedsUpdateSynchronization ) {
2126
+ return UR_RESULT_SUCCESS;
2127
+ }
2128
+
2120
2129
if (CommandBuffer->UseImmediateAppendPath ) {
2121
2130
if (ur_event_handle_t &CurrentSubmissionEvent =
2122
2131
CommandBuffer->CurrentSubmissionEvent ) {
@@ -2128,7 +2137,8 @@ waitForOngoingExecution(ur_exp_command_buffer_handle_t CommandBuffer) {
2128
2137
} else if (ze_fence_handle_t &ZeFence = CommandBuffer->ZeActiveFence ) {
2129
2138
ZE2UR_CALL (zeFenceHostSynchronize, (ZeFence, UINT64_MAX));
2130
2139
}
2131
-
2140
+ // Mark that command buffer was recently synchronized
2141
+ CommandBuffer->NeedsUpdateSynchronization = false ;
2132
2142
return UR_RESULT_SUCCESS;
2133
2143
}
2134
2144
0 commit comments