pub struct StreamOrderModel { /* private fields */ }Expand description
The stream-ordered allocation engine.
All accounting is in virtual bytes; no host or device memory is actually reserved. The engine is deterministic: identical operation sequences produce identical pointers and statistics.
Implementations§
Source§impl StreamOrderModel
impl StreamOrderModel
Sourcepub fn new(limits: ModelLimits) -> Self
pub fn new(limits: ModelLimits) -> Self
Create a fresh model with the given pool limits.
Sourcepub fn set_release_threshold(&mut self, threshold: usize)
pub fn set_release_threshold(&mut self, threshold: usize)
Mirror an updated release threshold from the pool configuration.
Sourcepub fn alloc(
&mut self,
size: usize,
stream: StreamOrderId,
) -> CudaResult<ModelAllocation>
pub fn alloc( &mut self, size: usize, stream: StreamOrderId, ) -> CudaResult<ModelAllocation>
Allocate size bytes ordered on stream.
Returns a ModelAllocation describing the (possibly reused) block and
the sequence number at which it becomes valid on the stream.
§Errors
CudaError::InvalidValueifsize == 0.CudaError::OutOfMemoryif satisfying the request would pushreservedpastmax_pool_size.
Sourcepub fn free(&mut self, ptr: u64, stream: StreamOrderId) -> CudaResult<()>
pub fn free(&mut self, ptr: u64, stream: StreamOrderId) -> CudaResult<()>
Record a stream-ordered free of ptr on stream.
The block is not returned to the free list until stream reaches the
free point; until then it remains counted in reserved but no longer in
used.
§Errors
CudaError::InvalidValueifptris not a live allocation (covers double-free and free of a foreign pointer).
Sourcepub fn is_live(&self, ptr: u64) -> bool
pub fn is_live(&self, ptr: u64) -> bool
Returns true if ptr is a currently-live allocation in this model.
Sourcepub fn synchronize(&mut self, stream: StreamOrderId)
pub fn synchronize(&mut self, stream: StreamOrderId)
Advance a stream to its head: every operation submitted so far is now
complete (model of cuStreamSynchronize). Completed frees are
reclaimed into the free list.
Sourcepub fn is_ready_same_stream(&self, alloc: &ModelAllocation) -> bool
pub fn is_ready_same_stream(&self, alloc: &ModelAllocation) -> bool
Returns true if the allocation alloc is valid for use on its own
ordering stream (i.e. the stream has executed past the allocation
point). This is the same-stream visibility rule.
Sourcepub fn is_ready_cross_stream(
&self,
alloc: &ModelAllocation,
consumer: StreamOrderId,
wait_seq: u64,
) -> bool
pub fn is_ready_cross_stream( &self, alloc: &ModelAllocation, consumer: StreamOrderId, wait_seq: u64, ) -> bool
Returns true if alloc (made on stream A) is safe to use on
consumer (stream B) given that B has been ordered after sequence
wait_seq on A (the sequence captured by an event B waited on).
Cross-stream use is only safe when the event was recorded after the
allocation became ready (wait_seq > ready_seq) and consumer != A
degenerates to the same-stream rule when they are equal.
Sourcepub fn record_event(&mut self, stream: StreamOrderId) -> u64
pub fn record_event(&mut self, stream: StreamOrderId) -> u64
Record an event on stream, returning the sequence number it captures.
A later cuStreamWaitEvent on another stream is ordered after every
operation submitted on stream before this point — modelled by handing
back the stream’s current submit position.
Sourcepub fn trim_to(&mut self, min_bytes_to_keep: usize)
pub fn trim_to(&mut self, min_bytes_to_keep: usize)
Explicit trim (model of cuMemPoolTrimTo): keep at least
min_bytes_to_keep reserved, releasing free-list blocks above that.
Sourcepub fn reset_peaks(&mut self)
pub fn reset_peaks(&mut self)
Reset the peak (reserved_high / used_high) statistics to the current
values.
Sourcepub fn reserved_high(&self) -> usize
pub fn reserved_high(&self) -> usize
Peak reserved byte count.
Sourcepub fn peak_active(&self) -> usize
pub fn peak_active(&self) -> usize
Peak number of concurrent live allocations.
Sourcepub fn free_block_count(&self) -> usize
pub fn free_block_count(&self) -> usize
Number of reuse-eligible free blocks currently held.
Sourcepub fn pending_free_count(&self) -> usize
pub fn pending_free_count(&self) -> usize
Number of pending (not-yet-complete) stream-ordered frees.