Skip to content

Commit

Permalink
[L0] Fixed event leak when outevent is given and is completed
Browse files Browse the repository at this point in the history
Signed-off-by: Zhang, Winston <winston.zhang@intel.com>
  • Loading branch information
winstonzhang-intel authored and nrspruit committed Dec 12, 2024
1 parent 6d4eec8 commit ebde7f4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/adapters/level_zero/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ ur_result_t urEnqueueEventsWait(
std::unique_lock<ur_shared_mutex> Lock(Queue->Mutex);
resetCommandLists(Queue);
}
if (OutEvent && (*OutEvent)->Completed) {
UR_CALL(CleanupCompletedEvent((*OutEvent), false, false));
UR_CALL(urEventReleaseInternal((*OutEvent)));
}

return UR_RESULT_SUCCESS;
}
Expand Down Expand Up @@ -955,7 +959,6 @@ ur_result_t urEventCreateWithNativeHandle(
UREvent = new ur_event_handle_t_(ZeEvent, nullptr /* ZeEventPool */,
Context, UR_EXT_COMMAND_TYPE_USER,
Properties->isNativeHandleOwned);

UREvent->RefCountExternal++;

} catch (const std::bad_alloc &) {
Expand Down Expand Up @@ -1111,6 +1114,7 @@ ur_result_t urEventReleaseInternal(ur_event_handle_t Event) {
// enabled or not, so we access properties of the queue and that's why queue
// must released later.
if (DisableEventsCaching || !Event->OwnNativeHandle) {
ZE_CALL_NOCHECK(zeEventDestroy, (Event->ZeEvent));
delete Event;
} else {
Event->Context->addEventToContextCache(Event);
Expand Down

0 comments on commit ebde7f4

Please sign in to comment.