Skip to content

[SYCL] Remove circular dependency between piEventRelease and cleanup() #6073

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

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 0 additions & 3 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5544,9 +5544,6 @@ static pi_result EventRelease(pi_event Event, pi_queue LockedQueue) {
}

if (--(Event->RefCount) == 0) {
if (!Event->CleanedUp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will call the "cleanup" of an event that wasn't explicitly waited with piEventsWait?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently nothing will call cleanup in this case no matter with or without proposed change.
Per our current implementation if event is not waited then it's refcount is not zero, so we won't go through check on line 5546 in this case.

And per current implementation cleanup is supposed to be called for event which was waited. It looks like it was done intentionally to not release/reset resources like associated kernel/commandlist if event was not waited.
We can change this behavior obviously and cleanup everything even if associated work is not finished. But I am not sure if it is going to be correct,

As for me proposed change is needed anyway, this call to cleanup() under RefCount == 0 check is incorrect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change this behavior obviously and cleanup everything even if associated work is not finished.

That we cannot do, otherwise we might destroy some L0 resources that are still being used and result in a segfault or even worse. But we must cleanup everything after waiting for everything is completed. If we aren't cleaning up, this means we have memory leaks, right?

As for me proposed change is needed anyway, this call to cleanup() under RefCount == 0 check is incorrect.

I don't disagree to that, but want to understand better why this was needed before.

Event->cleanup(LockedQueue);

if (Event->CommandType == PI_COMMAND_TYPE_MEM_BUFFER_UNMAP &&
Event->CommandData) {
// Free the memory allocated in the piEnqueueMemBufferMap.
Expand Down