Skip to content

[SYCL] Fix memory leak for interop events created from native handle #6180

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 7 commits into from
May 24, 2022

Conversation

aelovikov-intel
Copy link
Contributor

No description provided.

@aelovikov-intel
Copy link
Contributor Author

I expect pre-commit testing to fail at least because of intel/llvm-test-suite#1032

I'm planning to wait for results and possibly make more changes in in the test suite based on the testing results.

Comment on lines 5672 to 5676
// a task exists. Indeed, the user might have created ZeEvent in non-signaled
// state and never used it to run anything. As such, even in the scenario with
// ownership transfer, it's user's responsibility to ensure that lifetime of
// the sycl::even they are creating covers the point where anything signals
// it.
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that we should not expect to see a "signal" of this event, or "wait" on it without user's explicit ask for that (e.g. using this event as a dependency of another event). But we don't also require the user to signal event. Instead, disregarding of whether it was signaled or not, we should delete PI event when SYCL event goes out of its scope (but only destroy L0 native event if the ownership was transferred to SYCL RT). I think at least the comment needs to be refined.

@aelovikov-intel aelovikov-intel marked this pull request as ready for review May 23, 2022 23:37
@aelovikov-intel aelovikov-intel requested review from a team as code owners May 23, 2022 23:37
@@ -5664,6 +5664,20 @@ pi_result piextEventCreateWithNativeHandle(pi_native_handle NativeHandle,
// need to create a host-visible proxy for it.
(*Event)->HostVisibleEvent = *Event;

// Regular events managed by SYCL RT are created with RefCnt == 2 so that
// their lifetime is extended beyond that of of the associated pi_event as we
Copy link
Contributor

Choose a reason for hiding this comment

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

beyond that of of the associated pi_event

The lifetime of L0 event and PI event (pi_event) are equal for them. We don't destroy PI event while L0 event is still running, and we do destroy both when event is completed and released.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you suggest the change in wording that would be accurate here?

aelovikov-intel and others added 2 commits May 24, 2022 11:31
Co-authored-by: smaslov-intel <sergey.v.maslov@intel.com>
smaslov-intel
smaslov-intel previously approved these changes May 24, 2022
@againull againull merged commit 3c1d342 into intel:sycl May 24, 2022
steffenlarsen added a commit to steffenlarsen/llvm that referenced this pull request May 30, 2022
intel#6180 moved the retain logic for
events to the make_event interop API. However, this means that the old
OpenCL interop constructor for event does not retain the native event.
These changes add the retain logic directly to the old OpenCL interop
constructor for OpenCL.

Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
steffenlarsen added a commit that referenced this pull request May 31, 2022
#6180 moved the retain logic for
events to the make_event interop API. However, this means that the old
OpenCL interop constructor for event does not retain the native event.
These changes add the retain logic directly to the old OpenCL interop
constructor for OpenCL.

Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
@aelovikov-intel aelovikov-intel deleted the event-leak branch August 25, 2022 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants