Skip to main content

Module resource

Module resource 

Source
Expand description

Core DeviceMemoryResource trait and supporting types.

Mirrors RMM’s device_memory_resource shape so a future optional RMM backend can satisfy the same trait without requiring callers to change. Stream-ordered: every alloc/dealloc names a stream; cross- stream reuse requires explicit event-based synchronization.

Structs§

AllocTag
Caller-supplied tag for allocation log lines. Short-lived strings are interned by the logging resource; long-lived borrows are not retained.
BlockId
Compact identity of a DeviceBlock suitable for snapshotting into structures whose lifetime should not be tied to the source slice’s borrow. The fields needed to validate (ptr, generation) against the resource’s live map and to resolve alloc_stream for cross-stream waits / dealloc ordering.
DeviceBlock
One outstanding device-memory allocation. Owned by the caller until returned to its originating resource via DeviceMemoryResource::deallocate.
Generation
Monotonic counter for distinguishing reuse of the same byte address across drop / reallocate cycles. Logging and debug-guard resources use this to detect use-after-free.
StreamId
Identifier for a CUDA stream owned by the runtime’s stream pool. Wraps the raw cudarc stream handle the resource will use for cuMemAllocAsync / cuMemFreeAsync ordering. Construction goes through the runtime; do not fabricate.

Enums§

Access
Access kind for a single block use. Drives the cross-stream dependency edges the resource queues during DeviceMemoryResource::prepare_block_use and the events it records during DeviceMemoryResource::finish_block_use.
BlockState
State of an outstanding DeviceBlock from the runtime’s perspective. Adaptors flip blocks between these states; bug-detection resources reject operations on blocks in an unexpected state.
ResourceError
Errors returned by resource implementations. Distinct variants for the cases stress tests need to pin (out-of-budget vs CUDA driver failure vs use-after-free etc.).

Traits§

DeviceMemoryResource
Stream-ordered device memory resource. Implementations:

Type Aliases§

ResourceResult