Skip to main content

GemmWorkspace

Struct GemmWorkspace 

Source
pub struct GemmWorkspace<T: TropicalScalar> { /* private fields */ }
Expand description

Reusable CPU packing storage, shared by sequential calls through an exclusive borrow.

Each parallel output task gets its own pair of buffers. Storage grows to the largest panels and task count used so far; call Self::clear to release it. This reuses packing allocations, not result matrices or Rayon task metadata. The scalar parameter permits reuse across semirings with the same scalar type.

use tropical_gemm::{GemmWorkspace, TropicalGemm, TropicalMaxPlus};
let mut workspace = GemmWorkspace::<f32>::new();
let mut c = vec![TropicalMaxPlus(0.0); 4];
for _ in 0..3 {
    TropicalGemm::new(2, 2, 2).execute_with_workspace(
        &[1.0; 4], 2, &[2.0; 4], 2, &mut c, 2, &mut workspace,
    );
}
assert!(c.iter().all(|v| v.0 == 3.0));

Implementations§

Source§

impl<T: TropicalScalar> GemmWorkspace<T>

Source

pub fn new() -> Self

Source

pub fn capacity_bytes(&self) -> usize

Bytes reserved by scalar packing buffers (excluding task metadata).

Source

pub fn clear(&mut self)

Release all packing buffers. The next call will allocate them again.

Trait Implementations§

Source§

impl<T: Debug + TropicalScalar> Debug for GemmWorkspace<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: TropicalScalar> Default for GemmWorkspace<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for GemmWorkspace<T>

§

impl<T> RefUnwindSafe for GemmWorkspace<T>
where T: RefUnwindSafe,

§

impl<T> Send for GemmWorkspace<T>

§

impl<T> Sync for GemmWorkspace<T>

§

impl<T> Unpin for GemmWorkspace<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for GemmWorkspace<T>

§

impl<T> UnwindSafe for GemmWorkspace<T>
where T: UnwindSafe,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.