Skip to main content

SlotDevice

Trait SlotDevice 

Source
pub trait SlotDevice {
    // Required methods
    fn write_slot(
        &mut self,
        bank: usize,
        dst_slot: u32,
        src: &[u8],
    ) -> Result<(), String>;
    fn copy_slot(
        &mut self,
        bank: usize,
        dst_slot: u32,
        src_slot: u32,
    ) -> Result<(), String>;

    // Provided methods
    fn begin_plan(&mut self, route: CopyRoute) -> Result<(), String> { ... }
    fn flush(&mut self) -> Result<(), String> { ... }
}
Expand description

Where a slot’s bytes actually live.

One implementation per backend. Both methods take a bank index and absolute slot numbers; translating those into an address is the implementation’s business, which is what keeps this crate free of device memory.

Implementations may defer the work and do it in flush – an async copy engine is the normal case – but must not report success for a copy they later discover failed without failing the flush.

Required Methods§

Source

fn write_slot( &mut self, bank: usize, dst_slot: u32, src: &[u8], ) -> Result<(), String>

Writes one expert row from host memory into dst_slot. src is exactly row_bytes[bank] long; the implementation may rely on that.

Source

fn copy_slot( &mut self, bank: usize, dst_slot: u32, src_slot: u32, ) -> Result<(), String>

Copies one slot onto another within the pool, without touching the host. This is what makes a prefill gather cheaper than a re-fetch: the bytes are already on the far side of the link.

Provided Methods§

Source

fn begin_plan(&mut self, route: CopyRoute) -> Result<(), String>

Announces how the copies about to be issued must be carried out. Called once per plan, before the first copy.

The default ignores it, which is right for any backend whose copies are already synchronous. A backend that captures work into a graph must not capture a CopyRoute::WholeLayerPageable plan: that route exists precisely because the layer’s host rows have no device address, so its copy is a synchronous pageable one and a captured graph would replay a transfer whose source is not addressable.

Source

fn flush(&mut self) -> Result<(), String>

Completes any deferred copies. Called once per plan, after the last copy is issued.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§