Skip to content

Commit 5d4573f

Browse files
authored
[SYCL][L0] Fix memory leak in USM prefetch (#5461)
L0 plugin increments the ref count of the dependency event twice in USM prefetch. The fix is to remove the unnecessary retain call.
1 parent 7a93a49 commit 5d4573f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7319,6 +7319,11 @@ pi_result piextUSMEnqueuePrefetch(pi_queue Queue, const void *Ptr, size_t Size,
73197319
// Lock automatically releases when this goes out of scope.
73207320
std::lock_guard<std::mutex> lock(Queue->PiQueueMutex);
73217321

7322+
/**
7323+
* @brief Please note that the following code should be run before the
7324+
* subsequent getAvailableCommandList() call so that there is no
7325+
* dead-lock from waiting unsubmitted events in an open batch.
7326+
*/
73227327
_pi_ze_event_list_t TmpWaitList;
73237328
if (auto Res = TmpWaitList.createAndRetainPiZeEventList(NumEventsInWaitList,
73247329
EventWaitList, Queue))
@@ -7339,10 +7344,7 @@ pi_result piextUSMEnqueuePrefetch(pi_queue Queue, const void *Ptr, size_t Size,
73397344
if (Res != PI_SUCCESS)
73407345
return Res;
73417346
ZeEvent = (*Event)->ZeEvent;
7342-
7343-
if (auto Res = (*Event)->WaitList.createAndRetainPiZeEventList(
7344-
NumEventsInWaitList, EventWaitList, Queue))
7345-
return Res;
7347+
(*Event)->WaitList = TmpWaitList;
73467348

73477349
const auto &WaitList = (*Event)->WaitList;
73487350
const auto &ZeCommandList = CommandList->first;

0 commit comments

Comments
 (0)