@@ -1323,6 +1323,7 @@ ur_queue_handle_t_::executeCommandList(ur_command_list_ptr_t CommandList,
13231323 // in the command list is not empty, otherwise we are going to just create
13241324 // and remove proxy event right away and dereference deleted object
13251325 // afterwards.
1326+ bool AppendBarrierNeeded = true ;
13261327 if (ZeEventsScope == LastCommandInBatchHostVisible &&
13271328 !CommandList->second .EventList .empty ()) {
13281329 // If there are only internal events in the command list then we don't
@@ -1391,6 +1392,7 @@ ur_queue_handle_t_::executeCommandList(ur_command_list_ptr_t CommandList,
13911392 ZE2UR_CALL (zeCommandListAppendSignalEvent,
13921393 (CommandList->first , HostVisibleEvent->ZeEvent ));
13931394 } else {
1395+ AppendBarrierNeeded = false ;
13941396 ZE2UR_CALL (
13951397 zeCommandListAppendBarrier,
13961398 (CommandList->first , HostVisibleEvent->ZeEvent , 0 , nullptr ));
@@ -1404,6 +1406,10 @@ ur_queue_handle_t_::executeCommandList(ur_command_list_ptr_t CommandList,
14041406 this ->signalEventFromCmdListIfLastEventDiscarded (CommandList);
14051407 }
14061408 // Append Signalling of the inner events at the end of the batch
1409+ if (CommandList->second .EventList .size () > 0 && AppendBarrierNeeded) {
1410+ ZE2UR_CALL (zeCommandListAppendBarrier,
1411+ (CommandList->first , nullptr , 0 , nullptr ));
1412+ }
14071413 for (auto &Event : CommandList->second .EventList ) {
14081414 if (Event->IsInnerBatchedEvent ) {
14091415 ZE2UR_CALL (zeCommandListAppendSignalEvent,
0 commit comments