Skip to content

Fix sycl::queue leak in usm_ndarray get_queue()/get_device() - #3042

Open
vlad-perevezentsev wants to merge 2 commits into
masterfrom
fix_queue_leak
Open

Fix sycl::queue leak in usm_ndarray get_queue()/get_device()#3042
vlad-perevezentsev wants to merge 2 commits into
masterfrom
fix_queue_leak

Conversation

@vlad-perevezentsev

Copy link
Copy Markdown
Contributor

This PR fixes a memory leak in the C++ accessors usm_ndarray::get_queue() and get_device() in dpnp/include/dpnp4pybind11.hpp

UsmNDArray_GetQueueRef_ (dpnp's usm_ndarray.get_queue_ref()) returns an owning copy of the queue (it calls DPCTLQueue_Copy i.e. new sycl::queue)
Both accessors dereferenced this pointer and copied the queue out but never freed the heap copy, leaking one sycl::queue per call. Under queue churn this keeps queue_impl alive and prevents reuse of the associated Level Zero command lists / event pools.

The fix takes ownership of the returned copy with std::unique_ptr<sycl::queue>.
dpctl needs no change because its Memory_GetQueueRef returns a borrowed ref, whereas dpnp's UsmNDArray_GetQueueRef is documented to return a copy so it must be deleted.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

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.

1 participant