Skip to main content

BatchedSpMV

Struct BatchedSpMV 

Source
pub struct BatchedSpMV<T: GpuFloat> { /* private fields */ }
Expand description

Batched sparse matrix-vector multiplication.

Computes y_i = alpha * A_i * x_i + beta * y_i for a batch of sparse matrices A_i, dense vectors x_i, and output vectors y_i.

The baseline implementation iterates sequentially on the host. For GPU execution, use generate_batched_spmv_ptx to create a single fused kernel that processes all matrices via offset arrays.

Implementations§

Source§

impl<T: GpuFloat + Add<Output = T> + Mul<Output = T> + AddAssign> BatchedSpMV<T>

Source

pub fn from_device(matrices: &[CsrMatrix<T>]) -> SparseResult<Self>

Create a BatchedSpMV by downloading matrix data from device memory.

§Errors

Returns SparseError::InvalidArgument if matrices is empty. Returns SparseError::Cuda on download failure.

Source

pub fn from_host( row_ptrs: Vec<Vec<i32>>, col_indices: Vec<Vec<i32>>, values: Vec<Vec<T>>, rows: Vec<usize>, cols: Vec<usize>, ) -> SparseResult<Self>

Create a BatchedSpMV from host-side CSR arrays.

§Errors

Returns SparseError::InvalidArgument on dimension mismatch.

Source

pub fn batch_size(&self) -> usize

Returns the number of matrices in the batch.

Source

pub fn execute( &self, xs: &[Vec<T>], ys: &mut [Vec<T>], alpha: T, beta: T, ) -> SparseResult<()>

Execute the batched SpMV on the host (sequential baseline).

For each matrix A_i: y_i[r] = alpha * sum(A_i[r,c] * x_i[c]) + beta * y_i[r]

§Arguments
  • xs – Slice of input vectors, one per matrix.
  • ys – Slice of output vectors, one per matrix (modified in place).
  • alpha – Scalar multiplier for A * x.
  • beta – Scalar multiplier for existing y.
§Errors

Returns SparseError::DimensionMismatch if slice lengths do not match the batch size, or if individual vector dimensions are wrong.

Trait Implementations§

Source§

impl<T: Debug + GpuFloat> Debug for BatchedSpMV<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for BatchedSpMV<T>

§

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

§

impl<T> Send for BatchedSpMV<T>

§

impl<T> Sync for BatchedSpMV<T>

§

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

§

impl<T> UnsafeUnpin for BatchedSpMV<T>

§

impl<T> UnwindSafe for BatchedSpMV<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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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