From 5b021a228c98ccab1de123b6053a8d93d255f273 Mon Sep 17 00:00:00 2001 From: rdeodhar Date: Fri, 2 Dec 2022 13:09:29 -0700 Subject: [PATCH] [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. --- sycl/plugins/level_zero/pi_level_zero.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index 462251edb9263..66cfba73e7e4e 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -1036,13 +1036,15 @@ _pi_queue::resetCommandList(pi_command_list_ptr_t CommandList, EventList.clear(); } else { // For immediate commandlist reset only those events that have signalled. - for (auto it = EventList.begin(); it != EventList.end(); it++) { + for (auto it = EventList.begin(); it != EventList.end();) { std::scoped_lock EventLock((*it)->Mutex); ze_result_t ZeResult = ZE_CALL_NOCHECK(zeEventQueryStatus, ((*it)->ZeEvent)); if (ZeResult == ZE_RESULT_SUCCESS) { - std::move(it, it, std::back_inserter(EventListToCleanup)); - EventList.erase(it, it); + EventListToCleanup.push_back(std::move((*it))); + it = EventList.erase(it); + } else { + it++; } } }