Skip to main content

HostSlotMemory

Struct HostSlotMemory 

Source
pub struct HostSlotMemory { /* private fields */ }
Expand description

A pool whose “device” is host memory.

A real implementation, not a stand-in: on a CPU-only build the expert pool is host memory and the link is a memcpy, so this is the backend that build uses. It is also what makes every rule above testable on a machine with no GPU, which is the whole reason the device lives behind a trait.

Implementations§

Source§

impl HostSlotMemory

Source

pub fn new(geometry: &SlotGeometry) -> Self

Source

pub fn slot(&self, bank: usize, slot: u32) -> &[u8]

The bytes one slot holds in one bank. This is what makes the pool checkable: a test can assert the slot contains the expert the plan promised, not merely that a copy was counted.

Trait Implementations§

Source§

impl SlotDevice for HostSlotMemory

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.
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. Read more
Source§

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

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

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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.