Skip to content

[SYCL][L0] Fix memory leak in USM prefetch #5461

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 20 commits into from
Feb 3, 2022
Merged

Conversation

bso-intel
Copy link
Contributor

L0 plugin increments the ref count of the dependency event twice in USM prefetch.
The fix is to remove the unnecessary retain call.

@bso-intel bso-intel requested a review from a team as a code owner February 2, 2022 05:30
if (auto Res = TmpWaitList.createAndRetainPiZeEventList(NumEventsInWaitList,
EventWaitList, Queue))
return Res;

// Get a new command list to be used on this call
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already call createAndRetainPiZeEventList for the EventWaitList at line 7313 below.
This code unnecessarily increment the reference count twice, which leads to memory leak.

Copy link
Contributor

Choose a reason for hiding this comment

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

In all other cases we create TmpWaitList before creating the real Event (and I don't remember why now). Please investigate/document and make your change in line with the rest of the code (presumably remove the other call to createAndRetainPiZeEventList, not this one)

againull
againull previously approved these changes Feb 2, 2022
if (auto Res = TmpWaitList.createAndRetainPiZeEventList(NumEventsInWaitList,
EventWaitList, Queue))
return Res;

// Get a new command list to be used on this call
Copy link
Contributor

Choose a reason for hiding this comment

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

In all other cases we create TmpWaitList before creating the real Event (and I don't remember why now). Please investigate/document and make your change in line with the rest of the code (presumably remove the other call to createAndRetainPiZeEventList, not this one)

@bso-intel
Copy link
Contributor Author

bso-intel commented Feb 2, 2022

@smaslov-intel ,
Actually, it is better to keep line 7313 than this removed code.
Later when we need to cleanup the events in WaitList.collectEventsForReleaseAndDestroyPiZeEventList(EventsToBeReleased), we need the length of the ref-count-incremented events to call piEventRelease() properly.
This length of the ref-count-incremented events was set in TmpWaitList.createAndRetainPiZeEventList() on the TmpWaitList.
By keeping line 7313, we keep this length on the EventWaitList properly.

@smaslov-intel
Copy link
Contributor

See #3081 for why createAndRetainPiZeEventList is needed before command-list is allocated.

Signed-off-by: Byoungro So <byoungro.so@intel.com>
@bso-intel
Copy link
Contributor Author

Thanks @smaslov-intel.
I fixed as you requested.

@bso-intel
Copy link
Contributor Author

Hold the review. It seems it is mixed up with some other changes.

@smaslov-intel
Copy link
Contributor

Hold the review. It seems it is mixed up with some other changes.

Yes, please update. And please also add comment to createAndRetainPiZeEventList that it must be run before a subsequent getAvailableCommandList so that there is no dead-lock from waiting unsubmitted events in an open batch.

Signed-off-by: Byoungro So <byoungro.so@intel.com>
@bso-intel
Copy link
Contributor Author

Ok. Now it shows the correct changeset.
I added the comment, too.

@bader bader merged commit 5d4573f into intel:sycl Feb 3, 2022
@bso-intel bso-intel deleted the prefetch-leak branch February 3, 2022 07:40
alexbatashev added a commit to alexbatashev/llvm that referenced this pull request Feb 5, 2022
* upstream/sycl: (3571 commits)
  [ESIMD] Doxygen update part III - core APIs. (intel#5472)
  [SYCL][DOC] Move proposed FPGA extensions (intel#5453)
  [SYCL] Add -fsycl-fp32-prec-sqrt flag (intel#5309)
  [SYCL] Emit program build logs for warning levels >= 2 (intel#5319)
  [SYCL] Add clang support for code_location in KernelInfo (intel#5335)
  [SYCL][Doc] Move FPGA extensions (intel#5470)
  [ESIMD] Fix public simd and simd_view APIs. (intel#5465)
  [SYCL] Deprecate sycl::atomics in SYCL 2020 mode (intel#5440)
  [SYCL] Add unit test for PR 5414 (intel#5450)
  [XPTI] Allow arbitrary data types in metadata (intel#4998)
  [SYCL][DOC] Move discard queue events to supported (intel#5452)
  [Driver][SYCL] Initial support for allowing fat static -lname processing (intel#5413)
  [SYCL] Fix dead pointer usage if leaf buffer overflows (intel#5417)
  [SYCL][L0] Fix memory leak in USM prefetch (intel#5461)
  [SYCL][Doc] Add new free function queries proposal (intel#5106)
  [SYCL][ESIMD] Update vc-intrinsics deps to the top of the trunk (intel#5460)
  [SYCL][DOC] Move old spec constant extension spec (intel#5456)
  [SYCL][DOC] Move deprecated extensions (intel#5458)
  [SYCL][DOC] Fix links to old SubGroupMask doc (intel#5459)
  [ESIMD] Doxygen update part II - memory APIs. (intel#5443)
  ...
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.

4 participants