@@ -6029,32 +6029,30 @@ pi_result _pi_queue::synchronize() {
6029
6029
return PI_SUCCESS;
6030
6030
};
6031
6031
6032
- // Do nothing if the queue is empty
6033
- if (!LastCommandEvent)
6034
- return PI_SUCCESS;
6035
-
6036
- // For in-order queue just wait for the last command.
6037
- // If event is discarded then it can be in reset state or underlying level
6038
- // zero handle can have device scope, so we can't synchronize the last event.
6039
- if (isInOrderQueue () && !LastCommandEvent->IsDiscarded ) {
6040
- ZE_CALL (zeHostSynchronize, (LastCommandEvent->ZeEvent ));
6041
- } else {
6042
- // Otherwise sync all L0 queues/immediate command-lists.
6043
- for (auto &QueueMap : {ComputeQueueGroupsByTID, CopyQueueGroupsByTID}) {
6044
- for (auto &QueueGroup : QueueMap) {
6045
- if (UsingImmCmdLists) {
6046
- for (auto ImmCmdList : QueueGroup.second .ImmCmdLists )
6047
- syncImmCmdList (this , ImmCmdList);
6048
- } else {
6049
- for (auto &ZeQueue : QueueGroup.second .ZeQueues )
6050
- if (ZeQueue)
6051
- ZE_CALL (zeHostSynchronize, (ZeQueue));
6032
+ if (LastCommandEvent) {
6033
+ // For in-order queue just wait for the last command.
6034
+ // If event is discarded then it can be in reset state or underlying level
6035
+ // zero handle can have device scope, so we can't synchronize the last
6036
+ // event.
6037
+ if (isInOrderQueue () && !LastCommandEvent->IsDiscarded ) {
6038
+ ZE_CALL (zeHostSynchronize, (LastCommandEvent->ZeEvent ));
6039
+ } else {
6040
+ // Otherwise sync all L0 queues/immediate command-lists.
6041
+ for (auto &QueueMap : {ComputeQueueGroupsByTID, CopyQueueGroupsByTID}) {
6042
+ for (auto &QueueGroup : QueueMap) {
6043
+ if (UsingImmCmdLists) {
6044
+ for (auto ImmCmdList : QueueGroup.second .ImmCmdLists )
6045
+ syncImmCmdList (this , ImmCmdList);
6046
+ } else {
6047
+ for (auto &ZeQueue : QueueGroup.second .ZeQueues )
6048
+ if (ZeQueue)
6049
+ ZE_CALL (zeHostSynchronize, (ZeQueue));
6050
+ }
6052
6051
}
6053
6052
}
6054
6053
}
6054
+ LastCommandEvent = nullptr ;
6055
6055
}
6056
- LastCommandEvent = nullptr ;
6057
-
6058
6056
// With the entire queue synchronized, the active barriers must be done so we
6059
6057
// can remove them.
6060
6058
if (auto Res = ActiveBarriers.clear ())
0 commit comments