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.
|
Plugin.call<PiApiKind::piEnqueueEventsWait>(MQueue->getHandleRef(), 0, nullptr, &Event); |
|
Plugin.call<PiApiKind::piEnqueueMemBufferMap>( |
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.
|
getPlugin().call<PiApiKind::piEventRelease>(MEvent); |
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.
It has been observed in the PI CUDA backend that
pi_contextobjects,pi_queueobjects andpi_eventobjects can be leaked by the runtime.In the PI CUDA backend,
pi_contextandpi_queueobjects are retained bypi_eventobjects. The runtime creates many newpi_eventobjects 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_eventobjects as an output parameter. These new objects are never released. This is likely to affect allpiEnqueue...functions.The only call to
piEventReleasein the runtime source outside of the PI CUDA backend is in the destructor of theevent_implclass.llvm/sycl/source/detail/event_impl.cpp
Line 49 in 092367b
event_impl's destructor never callspiEventReleasein any of our tests. The lifetime ofevent_implobjects are managed throughstd::shared_ptr, so it is possible that a circular reference has occurred, or that a stray copy of theshared_ptris preventing the event object from being released.To ensure PI API can be used correctly across all backends, all
pi_eventobjects should be explicitly released when they are no longer needed. This will require some investigation intopi_eventuse through the runtime to determine if all events created are appropriately released.