From 427e62b7d30702e5b2ab08b8a688f171c19db27d Mon Sep 17 00:00:00 2001 From: blazej-smorawski Date: Fri, 20 Sep 2024 08:07:29 -0700 Subject: [PATCH] Fix native events handling --- source/adapters/level_zero/event.cpp | 7 ++++++- source/adapters/level_zero/event.hpp | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/source/adapters/level_zero/event.cpp b/source/adapters/level_zero/event.cpp index 7c040ccde3..866b68f0de 100644 --- a/source/adapters/level_zero/event.cpp +++ b/source/adapters/level_zero/event.cpp @@ -199,7 +199,8 @@ ur_queue_handle_legacy_t_::enqueueEventsWaitWithBarrier( ///< [in] handle of the !Queue->isProfilingEnabled()) { // If we are using driver in order lists, then append wait on events // is unnecessary and we can signal the event created. - if (EventWaitList.Length && !CmdList->second.IsInOrderList) { + + if (EventWaitList.Length && (!CmdList->second.IsInOrderList || EventWaitList.hasNativeEvents)) { ZE2UR_CALL(zeCommandListAppendWaitOnEvents, (CmdList->first, EventWaitList.Length, EventWaitList.ZeEventList)); @@ -1325,6 +1326,7 @@ ur_result_t _ur_ze_event_list_t::createAndRetainUrZeEventList( this->Length = 0; this->ZeEventList = nullptr; this->UrEventList = nullptr; + this->hasNativeEvents = false; if (CurQueue->isInOrderQueue() && CurQueue->LastCommandEvent != nullptr) { if (CurQueue->UsingImmCmdLists) { @@ -1567,6 +1569,9 @@ ur_result_t _ur_ze_event_list_t::createAndRetainUrZeEventList( QueueLock.reset(); CurQueue->Mutex.lock(); } + if (this->UrEventList[TmpListLength]->ZeEventPool == nullptr) { + this->hasNativeEvents = true; + } TmpListLength += 1; } } diff --git a/source/adapters/level_zero/event.hpp b/source/adapters/level_zero/event.hpp index e99df2a272..1cff460e7c 100644 --- a/source/adapters/level_zero/event.hpp +++ b/source/adapters/level_zero/event.hpp @@ -78,6 +78,8 @@ struct _ur_ze_event_list_t { // of elements in the above arrays that are valid. uint32_t Length = {0}; + bool hasNativeEvents = false; + // Initialize this using the array of events in EventList, and retain // all the ur_event_handle_t in the created data structure. // CurQueue is the ur_queue_handle_t that the command with this event wait