Description
It has been observed in the PI CUDA backend that pi_context
objects, pi_queue
objects and pi_event
objects can be leaked by the runtime.
In the PI CUDA backend, pi_context
and pi_queue
objects are retained by pi_event
objects. The runtime creates many new pi_event
objects without releasing them.
llvm/sycl/source/detail/scheduler/commands.cpp
Line 1779 in 3f21371
llvm/sycl/source/detail/memory_manager.cpp
Line 480 in 3f21371
These functions return new pi_event
objects as an output parameter. These new objects are never released. This is likely to affect all piEnqueue...
functions.
The only call to piEventRelease
in the runtime source outside of the PI CUDA backend is in the destructor of the event_impl
class.
llvm/sycl/source/detail/event_impl.cpp
Line 49 in 092367b
event_impl
's destructor never calls piEventRelease
in any of our tests. The lifetime of event_impl
objects are managed through std::shared_ptr
, so it is possible that a circular reference has occurred, or that a stray copy of the shared_ptr
is preventing the event object from being released.
To ensure PI API can be used correctly across all backends, all pi_event
objects should be explicitly released when they are no longer needed. This will require some investigation into pi_event
use through the runtime to determine if all events created are appropriately released.