@@ -1323,6 +1323,7 @@ ur_queue_handle_t_::executeCommandList(ur_command_list_ptr_t CommandList,
1323
1323
// in the command list is not empty, otherwise we are going to just create
1324
1324
// and remove proxy event right away and dereference deleted object
1325
1325
// afterwards.
1326
+ bool AppendBarrierNeeded = true ;
1326
1327
if (ZeEventsScope == LastCommandInBatchHostVisible &&
1327
1328
!CommandList->second .EventList .empty ()) {
1328
1329
// 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,
1391
1392
ZE2UR_CALL (zeCommandListAppendSignalEvent,
1392
1393
(CommandList->first , HostVisibleEvent->ZeEvent ));
1393
1394
} else {
1395
+ AppendBarrierNeeded = false ;
1394
1396
ZE2UR_CALL (
1395
1397
zeCommandListAppendBarrier,
1396
1398
(CommandList->first , HostVisibleEvent->ZeEvent , 0 , nullptr ));
@@ -1404,6 +1406,10 @@ ur_queue_handle_t_::executeCommandList(ur_command_list_ptr_t CommandList,
1404
1406
this ->signalEventFromCmdListIfLastEventDiscarded (CommandList);
1405
1407
}
1406
1408
// 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
+ }
1407
1413
for (auto &Event : CommandList->second .EventList ) {
1408
1414
if (Event->IsInnerBatchedEvent ) {
1409
1415
ZE2UR_CALL (zeCommandListAppendSignalEvent,
0 commit comments