Skip to main content

AccelRef

Trait AccelRef 

Source
pub trait AccelRef<T, B: AccelBackend>:
    Clone
    + Send
    + Sync
    + 'static {
    // Required methods
    fn len(&self) -> usize;
    fn generation(&self) -> u64;
    fn device_id(&self) -> Option<u32>;
    fn check(&self) -> Result<(), AccelError>;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Trait implemented by every backend’s typed-pointer wrapper.

The generation token check is the contract: each backend’s access() returns Err(AccelError::AccelRefStale) if the device generation has advanced past the one the ref was minted against. Code that walks AccelRefs never has to know which backend is underneath.

Required Methods§

Source

fn len(&self) -> usize

Number of T elements in the buffer.

Source

fn generation(&self) -> u64

Generation token captured at allocation time. Backends mint fresh refs against device.generation() and validate the match on every access().

Source

fn device_id(&self) -> Option<u32>

Originating device id. Used by multi-device routing to reject cross-device misuse (e.g. AllReduce input mismatch).

Source

fn check(&self) -> Result<(), AccelError>

Validate the ref is still usable. Returns Err if the device generation has moved or the device is shutting down.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if len() == 0.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§