Skip to main content

StreamOrderModel

Struct StreamOrderModel 

Source
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

Source

pub fn new(limits: ModelLimits) -> Self

Create a fresh model with the given pool limits.

Source

pub fn set_release_threshold(&mut self, threshold: usize)

Mirror an updated release threshold from the pool configuration.

Source

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
Source

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
Source

pub fn is_live(&self, ptr: u64) -> bool

Returns true if ptr is a currently-live allocation in this model.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn reset_peaks(&mut self)

Reset the peak (reserved_high / used_high) statistics to the current values.

Source

pub fn reserved(&self) -> usize

Current reserved byte count.

Source

pub fn used(&self) -> usize

Current used byte count.

Source

pub fn reserved_high(&self) -> usize

Peak reserved byte count.

Source

pub fn used_high(&self) -> usize

Peak used byte count.

Source

pub fn active(&self) -> usize

Number of currently-live allocations.

Source

pub fn peak_active(&self) -> usize

Peak number of concurrent live allocations.

Source

pub fn free_block_count(&self) -> usize

Number of reuse-eligible free blocks currently held.

Source

pub fn pending_free_count(&self) -> usize

Number of pending (not-yet-complete) stream-ordered frees.

Trait Implementations§

Source§

impl Debug for StreamOrderModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more