@@ -1696,15 +1696,9 @@ ur_result_t ur_queue_handle_t_::synchronize() {
1696
1696
// If event is discarded then it can be in reset state or underlying level
1697
1697
// zero handle can have device scope, so we can't synchronize the last
1698
1698
// event.
1699
+ auto savedLastCommandEvent = LastCommandEvent;
1699
1700
if (isInOrderQueue () && !LastCommandEvent->IsDiscarded ) {
1700
- if (UrL0QueueSyncNonBlocking) {
1701
- auto SyncZeEvent = LastCommandEvent->ZeEvent ;
1702
- this ->Mutex .unlock ();
1703
- ZE2UR_CALL (zeHostSynchronize, (SyncZeEvent));
1704
- this ->Mutex .lock ();
1705
- } else {
1706
- ZE2UR_CALL (zeHostSynchronize, (LastCommandEvent->ZeEvent ));
1707
- }
1701
+ ZE2UR_CALL (zeHostSynchronize, (LastCommandEvent->ZeEvent ));
1708
1702
1709
1703
// clean up all events known to have been completed as well,
1710
1704
// so they can be reused later
@@ -1744,7 +1738,12 @@ ur_result_t ur_queue_handle_t_::synchronize() {
1744
1738
}
1745
1739
}
1746
1740
}
1747
- LastCommandEvent = nullptr ;
1741
+ // If the current version of the LastCommandEvent == savedLastCommandEvent,
1742
+ // then LastCommandEvent = nullptr; Otherwise, if LastCommandEvent !=
1743
+ // savedLastCommandEvent, then LastCommandEvent is unchanged.
1744
+ if (LastCommandEvent == savedLastCommandEvent) {
1745
+ LastCommandEvent = nullptr ;
1746
+ }
1748
1747
}
1749
1748
1750
1749
// Since all timestamp recordings should have finished with the
0 commit comments