Skip to content

Commit

Permalink
Merge pull request #1257 from pbalcer/fix-native-handle-waits
Browse files Browse the repository at this point in the history
[L0] fix waiting on non-owned native handle events
  • Loading branch information
kbenzie authored Jan 19, 2024
2 parents 43c2ad2 + 3ef6d11 commit 92f44da
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions source/adapters/level_zero/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,13 +625,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventWait(
///< events to wait for completion
) {
for (uint32_t I = 0; I < NumEvents; I++) {
if (EventWaitList[I]->UrQueue->ZeEventsScope == OnDemandHostVisibleProxy) {
auto e = EventWaitList[I];
if (e->UrQueue && e->UrQueue->ZeEventsScope == OnDemandHostVisibleProxy) {
// Make sure to add all host-visible "proxy" event signals if needed.
// This ensures that all signalling commands are submitted below and
// thus proxy events can be waited without a deadlock.
//
ur_event_handle_t_ *Event =
ur_cast<ur_event_handle_t_ *>(EventWaitList[I]);
ur_event_handle_t_ *Event = ur_cast<ur_event_handle_t_ *>(e);
if (!Event->hasExternalRefs())
die("urEventsWait must not be called for an internal event");

Expand Down Expand Up @@ -782,6 +782,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventCreateWithNativeHandle(
Context, UR_EXT_COMMAND_TYPE_USER,
Properties->isNativeHandleOwned);

UREvent->RefCountExternal++;

} catch (const std::bad_alloc &) {
return UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
} catch (...) {
Expand Down

0 comments on commit 92f44da

Please sign in to comment.