Skip to content

pi_event objects are not destroyed by the runtime #1520

Closed
@nyalloc

Description

@nyalloc

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.

Metadata

Metadata

Labels

bugSomething isn't workingcudaCUDA back-endruntimeRuntime library related issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions