pub struct StreamPool { /* private fields */ }Expand description
Pool of owned non-blocking CUDA streams.
Implementations§
Source§impl StreamPool
impl StreamPool
Sourcepub fn new(device: Arc<CudaDevice>, max_streams: usize) -> Self
pub fn new(device: Arc<CudaDevice>, max_streams: usize) -> Self
Construct a pool bound to device, capped at max_streams.
Sourcepub fn with_defaults(device: Arc<CudaDevice>) -> Self
pub fn with_defaults(device: Arc<CudaDevice>) -> Self
Construct with the default cap DEFAULT_MAX_STREAMS.
Sourcepub fn acquire(&self) -> Result<StreamId, StreamPoolError>
pub fn acquire(&self) -> Result<StreamId, StreamPoolError>
Acquire a non-default stream id, growing the pool up to
max_streams. Each successful call returns a distinct
StreamId backed by an owned non-blocking
cudarc::driver::CudaStream forked from the device’s default
stream.
§Errors
StreamPoolError::Capacityif the pool already holdsmax_streamsnon-default streams.StreamPoolError::ForkFailedif the underlyingCudaStream::forkcall failed.
Streams are never returned to a free-list; they remain valid
for the runtime’s lifetime so previously returned StreamId
handles keep resolving.
Sourcepub fn resolve(&self, id: StreamId) -> Option<Arc<CudaStream>>
pub fn resolve(&self, id: StreamId) -> Option<Arc<CudaStream>>
Borrow the live CudaStream for id. Returns None if id
has never been issued by this pool. The default-stream slot
resolves to the device’s default stream.
Sourcepub fn non_default_len(&self) -> usize
pub fn non_default_len(&self) -> usize
Number of non-default streams currently in the pool.
Sourcepub fn device(&self) -> &Arc<CudaDevice>
pub fn device(&self) -> &Arc<CudaDevice>
Borrow the device handle. Test helpers use this to launch kernels into the same device the pool was constructed on.
Sourcepub fn max_streams(&self) -> usize
pub fn max_streams(&self) -> usize
Maximum streams the pool will create on demand.
Sourcepub fn pool_bytes_per_stream(&self) -> u64
pub fn pool_bytes_per_stream(&self) -> u64
Planned per-stream pool budget, in bytes, from
XLOG_WCOJ_POOL_MB_PER_STREAM or the 256 MiB default.