Skip to content

Commit

Permalink
[SYCL] Queue has to be released later than event (#7225)
Browse files Browse the repository at this point in the history
  • Loading branch information
againull committed Oct 28, 2022
1 parent cac4727 commit c49eeda
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6026,20 +6026,25 @@ static pi_result piEventReleaseInternal(pi_event Event) {
PI_CALL(piEventReleaseInternal(Event->HostVisibleEvent));
}

// We intentionally incremented the reference counter when an event is
// created so that we can avoid pi_queue is released before the associated
// pi_event is released. Here we have to decrement it so pi_queue
// can be released successfully.
if (Event->Queue) {
PI_CALL(piQueueReleaseInternal(Event->Queue));
}

// Save pointer to the queue before deleting/resetting event.
// When we add an event to the cache we need to check whether profiling is
// enabled or not, so we access properties of the queue and that's why queue
// must released later.
auto Queue = Event->Queue;
if (DisableEventsCaching || !Event->OwnZeEvent) {
delete Event;
} else {
Event->Context->addEventToCache(Event);
}

// We intentionally incremented the reference counter when an event is
// created so that we can avoid pi_queue is released before the associated
// pi_event is released. Here we have to decrement it so pi_queue
// can be released successfully.
if (Queue) {
PI_CALL(piQueueReleaseInternal(Queue));
}

return PI_SUCCESS;
}

Expand Down

0 comments on commit c49eeda

Please sign in to comment.