Skip to content

Commit 8686069

Browse files
[SYCL][L0] Avoid leak of active barriers' events (#9275)
Fixes regression introduced by #8601 Signed-off-by: Sergey V Maslov <[email protected]>
1 parent e2b8a04 commit 8686069

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6029,32 +6029,30 @@ pi_result _pi_queue::synchronize() {
60296029
return PI_SUCCESS;
60306030
};
60316031

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+
}
60526051
}
60536052
}
60546053
}
6054+
LastCommandEvent = nullptr;
60556055
}
6056-
LastCommandEvent = nullptr;
6057-
60586056
// With the entire queue synchronized, the active barriers must be done so we
60596057
// can remove them.
60606058
if (auto Res = ActiveBarriers.clear())

0 commit comments

Comments
 (0)