Skip to content

Commit 5b021a2

Browse files
authored
[SYCL] [L0] Fix for event leakage when using immediate commandlists. (#7546)
This change properly gathers events that have been set and need to be recycled.
1 parent 5a140b3 commit 5b021a2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,13 +1036,15 @@ _pi_queue::resetCommandList(pi_command_list_ptr_t CommandList,
10361036
EventList.clear();
10371037
} else {
10381038
// For immediate commandlist reset only those events that have signalled.
1039-
for (auto it = EventList.begin(); it != EventList.end(); it++) {
1039+
for (auto it = EventList.begin(); it != EventList.end();) {
10401040
std::scoped_lock<pi_shared_mutex> EventLock((*it)->Mutex);
10411041
ze_result_t ZeResult =
10421042
ZE_CALL_NOCHECK(zeEventQueryStatus, ((*it)->ZeEvent));
10431043
if (ZeResult == ZE_RESULT_SUCCESS) {
1044-
std::move(it, it, std::back_inserter(EventListToCleanup));
1045-
EventList.erase(it, it);
1044+
EventListToCleanup.push_back(std::move((*it)));
1045+
it = EventList.erase(it);
1046+
} else {
1047+
it++;
10461048
}
10471049
}
10481050
}

0 commit comments

Comments
 (0)