Skip to content
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

[L0] Fix Event Memory Leak due to no destroy on delete #2476

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

nrspruit
Copy link
Contributor

@nrspruit nrspruit commented Dec 18, 2024

  • Given Internal Event that is not cached we must destroy the ze event
    at handle destroy. This can only occur if the associated queue does
    not have discard events enabled.
  • during context release and when event caching is disabled, the destroy
    sets the event handle to nullptr to avoid double cleanup.

@nrspruit nrspruit requested a review from a team as a code owner December 18, 2024 00:53
@nrspruit nrspruit added the v0.11.x Include in the v0.11.x release label Dec 18, 2024
@github-actions github-actions bot added the level-zero L0 adapter specific issues label Dec 18, 2024
@nrspruit nrspruit marked this pull request as draft December 18, 2024 00:59
@nrspruit nrspruit changed the title [L0] Fix Event Memory Leak due to invalid commit [L0] Fix Event Memory Leak Dec 18, 2024
@nrspruit nrspruit force-pushed the fix_event_memory_leak branch from 54b8a21 to 08ffad9 Compare December 18, 2024 01:56
@nrspruit nrspruit changed the title [L0] Fix Event Memory Leak [L0] Fix Event Memory Leak due to no destroy on delete Dec 18, 2024
@nrspruit nrspruit force-pushed the fix_event_memory_leak branch 2 times, most recently from 9c5e024 to a96c4d0 Compare December 18, 2024 15:14
@nrspruit nrspruit marked this pull request as ready for review December 18, 2024 15:16
@nrspruit nrspruit marked this pull request as draft December 18, 2024 15:22
@nrspruit
Copy link
Contributor Author

I need to check that this change does not interfere with the "discard events" feature. This definitely resolves a memory leak issue with internal events, but I need to ensure I did not miss something with the discard feature that does not allow this cleanup. I will have this in draft until that is confirmed.

- Given Internal Event that is not cached we must destroy the ze event
  at handle destroy. This can only occur if the associated queue does
not have discard events enabled.
- during context release and when event caching is disabled, the destroy
  sets the event handle to nullptr to avoid double cleanup.

Signed-off-by: Neil R. Spruit <[email protected]>
@nrspruit nrspruit force-pushed the fix_event_memory_leak branch from a96c4d0 to 56a3c84 Compare December 18, 2024 19:25
nrspruit added a commit to nrspruit/llvm that referenced this pull request Dec 18, 2024
@nrspruit
Copy link
Contributor Author

I need to check that this change does not interfere with the "discard events" feature. This definitely resolves a memory leak issue with internal events, but I need to ensure I did not miss something with the discard feature that does not allow this cleanup. I will have this in draft until that is confirmed.

Fixed the issue in my latest. The additional Destroy can only occur if the associated queue is NOT using Discard Events. If it is using Discard Events, then the zeEvent is not meant to be destroyed, but instead it is reused in new UR Events.

The latest accounts for this such that the known event handle leak is still fixed, but does not break the discard events use case.

@nrspruit nrspruit marked this pull request as ready for review December 18, 2024 20:01
@nrspruit nrspruit added the ready to merge Added to PR's which are ready to merge label Dec 18, 2024
@nrspruit
Copy link
Contributor Author

Added ready to merge since the CI is passing related to discard events now after my additional check.

@martygrant martygrant merged commit 06a8c51 into oneapi-src:main Dec 19, 2024
73 checks passed
kbenzie pushed a commit that referenced this pull request Dec 19, 2024
[L0] Fix Event Memory Leak due to no destroy on delete
martygrant added a commit to intel/llvm that referenced this pull request Dec 19, 2024
-pre-commit PR for
oneapi-src/unified-runtime#2476

---------

Signed-off-by: Neil R. Spruit <[email protected]>
Co-authored-by: Martin Morrison-Grant <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level-zero L0 adapter specific issues ready to merge Added to PR's which are ready to merge v0.11.x Include in the v0.11.x release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants