diff --git a/source/adapters/level_zero/event.cpp b/source/adapters/level_zero/event.cpp index c1e93483b8..eae16f0c57 100644 --- a/source/adapters/level_zero/event.cpp +++ b/source/adapters/level_zero/event.cpp @@ -145,6 +145,10 @@ ur_result_t urEnqueueEventsWait( std::unique_lock Lock(Queue->Mutex); resetCommandLists(Queue); } + if (OutEvent && (*OutEvent)->Completed) { + UR_CALL(CleanupCompletedEvent((*OutEvent), false, false)); + UR_CALL(urEventReleaseInternal((*OutEvent))); + } return UR_RESULT_SUCCESS; } @@ -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 &) {