Skip to content

[SYCL] Queue has to be released later than event #7225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -6028,20 +6028,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