Skip to main content

SimdOps

Trait SimdOps 

Source
pub trait SimdOps: ScalarTrait + Sealed {
Show 35 methods // Required methods fn sum(data: &[Self]) -> Self; fn abs_sum(data: &[Self]) -> Self; fn abs_max(data: &[Self]) -> Self; fn min(data: &[Self]) -> Self; fn max(data: &[Self]) -> Self; fn scale(data: &mut [Self], scalar: Self); fn argmin(data: &[Self]) -> Option<(usize, Self)>; fn argmax(data: &[Self]) -> Option<(usize, Self)>; fn dot(a: &[Self], b: &[Self]) -> Result<Self, SimdError>; fn axpy(alpha: Self, x: &[Self], out: &mut [Self]) -> Result<(), SimdError>; fn axpy_mul( alpha: Self, a: &[Self], b: &[Self], out: &mut [Self], ) -> Result<(), SimdError>; fn axpy_rows( alphas: &[Self], x: &[Self], out: &mut [Self], row_stride: usize, rows: usize, cols: usize, ) -> Result<(), SimdError>; fn axpy_rows_batch( alphas: &[Self], x_panel: &[Self], out: &mut [Self], row_stride: usize, rows: usize, depth: usize, cols: usize, ) -> Result<(), SimdError>; fn elementwise_mul( a: &[Self], b: &[Self], out: &mut [Self], ) -> Result<(), SimdError>; fn elementwise_add( a: &[Self], b: &[Self], out: &mut [Self], ) -> Result<(), SimdError>; fn elementwise_sub( a: &[Self], b: &[Self], out: &mut [Self], ) -> Result<(), SimdError>; fn elementwise_div( a: &[Self], b: &[Self], out: &mut [Self], ) -> Result<(), SimdError>; fn masked_sum(data: &[Self], mask: &[bool]) -> Self; fn masked_dot( a: &[Self], b: &[Self], mask: &[bool], ) -> Result<Self, SimdError>; fn masked_add( a: &[Self], b: &[Self], mask: &[bool], out: &mut [Self], ) -> Result<(), SimdError>; fn spmv_csr( data: ValidatedData<CsrData<'_, Self>>, x: &[Self], y: &mut [Self], ); fn spmv_bcoo<const BM: usize, const BN: usize>( data: ValidatedData<BlockedCooData<'_, Self, BM, BN>>, x: &[Self], y: &mut [Self], ); fn spmv_dense_masked( data: DenseWithMaskData<'_, Self>, x: &[Self], y: &mut [Self], ); fn spmv_sellp<const C: usize>( data: ValidatedData<SellPData<'_, Self, C>>, x: &[Self], y: &mut [Self], ); fn tiled_gemm( a: &[Self], b: &[Self], c: &mut [Self], m: usize, n: usize, k: usize, ) -> Result<(), SimdError>; fn gemv( a: &[Self], x: &[Self], y: &mut [Self], nrows: usize, ncols: usize, ) -> Result<(), SimdError>; fn gemv_transpose( a: &[Self], x: &[Self], y: &mut [Self], nrows: usize, ncols: usize, ) -> Result<(), SimdError>; fn gemv_strided( a: &[Self], x: &[Self], y: &mut [Self], nrows: usize, ncols: usize, lda: usize, ) -> Result<(), SimdError>; fn gemv_transpose_strided( a: &[Self], x: &[Self], y: &mut [Self], nrows: usize, ncols: usize, lda: usize, ) -> Result<(), SimdError>; fn interleaved_complex_mul_assign<const CONJ_B: bool>( a: &mut [Self], b: &[Self], ) -> Result<(), SimdError> where Self: Neg<Output = Self>; fn interleaved_complex_dot<const CONJ_B: bool>( a: &[Self], b: &[Self], ) -> Result<(Self, Self), SimdError> where Self: Neg<Output = Self>; fn reduce_popcount(data: &[Self]) -> usize; fn reduce_popcount_and(a: &[Self], b: &[Self]) -> Result<usize, SimdError>; fn reduce_popcount_or(a: &[Self], b: &[Self]) -> Result<usize, SimdError>; fn reduce_popcount_xor(a: &[Self], b: &[Self]) -> Result<usize, SimdError>;
}
Expand description

Sealed extension trait implementing dynamic runtime SIMD dispatch for any T: Scalar.

Required Methods§

Source

fn sum(data: &[Self]) -> Self

Reduces the slice to its sum.

Source

fn abs_sum(data: &[Self]) -> Self

Reduces the slice to Σ |x| (L1-norm accumulator); T::ZERO for empty.

Source

fn abs_max(data: &[Self]) -> Self

Reduces the slice to max |x| (∞-norm accumulator); T::ZERO for empty.

Source

fn min(data: &[Self]) -> Self

Reduces the slice to its minimum element.

Returns T::MAX_VALUE for empty slices (the identity element for min).

Source

fn max(data: &[Self]) -> Self

Reduces the slice to its maximum element.

Returns T::MIN_VALUE for empty slices (the identity element for max).

Source

fn scale(data: &mut [Self], scalar: Self)

Multiplies every element by scalar in-place.

Source

fn argmin(data: &[Self]) -> Option<(usize, Self)>

Returns Some((index, value)) of the minimum element, or None for empty.

Source

fn argmax(data: &[Self]) -> Option<(usize, Self)>

Returns Some((index, value)) of the maximum element, or None for empty.

Source

fn dot(a: &[Self], b: &[Self]) -> Result<Self, SimdError>

Computes the dot product of two slices.

Source

fn axpy(alpha: Self, x: &[Self], out: &mut [Self]) -> Result<(), SimdError>

Fused row update out[i] += alpha * x[i] (AXPY) with no temporaries.

Source

fn axpy_mul( alpha: Self, a: &[Self], b: &[Self], out: &mut [Self], ) -> Result<(), SimdError>

Fused ternary update out[i] += alpha * a[i] * b[i] with no temporary.

Source

fn axpy_rows( alphas: &[Self], x: &[Self], out: &mut [Self], row_stride: usize, rows: usize, cols: usize, ) -> Result<(), SimdError>

Fused multi-row update out[row, i] += alphas[row] * x[i].

Source

fn axpy_rows_batch( alphas: &[Self], x_panel: &[Self], out: &mut [Self], row_stride: usize, rows: usize, depth: usize, cols: usize, ) -> Result<(), SimdError>

Fused batched multi-row update: out[row, i] += sum_k alphas[k, row] * x_panel[k, i].

Source

fn elementwise_mul( a: &[Self], b: &[Self], out: &mut [Self], ) -> Result<(), SimdError>

Computes the elementwise product and writes to out.

Source

fn elementwise_add( a: &[Self], b: &[Self], out: &mut [Self], ) -> Result<(), SimdError>

Computes the elementwise sum a[i] + b[i] and writes to out.

Source

fn elementwise_sub( a: &[Self], b: &[Self], out: &mut [Self], ) -> Result<(), SimdError>

Computes the elementwise difference a[i] - b[i] and writes to out.

Source

fn elementwise_div( a: &[Self], b: &[Self], out: &mut [Self], ) -> Result<(), SimdError>

Computes the elementwise quotient a[i] / b[i] and writes to out.

Source

fn masked_sum(data: &[Self], mask: &[bool]) -> Self

Computes the sum of elements matching a boolean mask.

Source

fn masked_dot(a: &[Self], b: &[Self], mask: &[bool]) -> Result<Self, SimdError>

Computes the dot product of elements matching a boolean mask.

Source

fn masked_add( a: &[Self], b: &[Self], mask: &[bool], out: &mut [Self], ) -> Result<(), SimdError>

Computes the elementwise sum of elements matching a boolean mask.

Source

fn spmv_csr(data: ValidatedData<CsrData<'_, Self>>, x: &[Self], y: &mut [Self])

Computes sparse SpMV using CSR.

Source

fn spmv_bcoo<const BM: usize, const BN: usize>( data: ValidatedData<BlockedCooData<'_, Self, BM, BN>>, x: &[Self], y: &mut [Self], )

Computes sparse SpMV using const-generic Blocked-COO tiles.

Source

fn spmv_dense_masked( data: DenseWithMaskData<'_, Self>, x: &[Self], y: &mut [Self], )

Computes sparse SpMV using Dense-with-Mask.

Source

fn spmv_sellp<const C: usize>( data: ValidatedData<SellPData<'_, Self, C>>, x: &[Self], y: &mut [Self], )

Computes sparse SpMV using const-generic Sliced ELLPACK (SELL-p).

Source

fn tiled_gemm( a: &[Self], b: &[Self], c: &mut [Self], m: usize, n: usize, k: usize, ) -> Result<(), SimdError>

Computes register-blocked tiled GEMM: c += A * B.

Source

fn gemv( a: &[Self], x: &[Self], y: &mut [Self], nrows: usize, ncols: usize, ) -> Result<(), SimdError>

Computes register-blocked GEMV: y += A * x (A row-major nrows × ncols).

Source

fn gemv_transpose( a: &[Self], x: &[Self], y: &mut [Self], nrows: usize, ncols: usize, ) -> Result<(), SimdError>

Computes register-blocked transposed GEMV: y += Aᵀ * x (A row-major nrows × ncols, x length nrows, y length ncols).

Source

fn gemv_strided( a: &[Self], x: &[Self], y: &mut [Self], nrows: usize, ncols: usize, lda: usize, ) -> Result<(), SimdError>

Computes register-blocked sub-matrix GEMV: y += A * x with row stride lda ≥ ncols (lda = ncols is the packed Self::gemv).

Source

fn gemv_transpose_strided( a: &[Self], x: &[Self], y: &mut [Self], nrows: usize, ncols: usize, lda: usize, ) -> Result<(), SimdError>

Computes register-blocked transposed sub-matrix GEMV: y += Aᵀ * x with row stride lda ≥ ncols (lda = ncols is the packed Self::gemv_transpose).

Source

fn interleaved_complex_mul_assign<const CONJ_B: bool>( a: &mut [Self], b: &[Self], ) -> Result<(), SimdError>
where Self: Neg<Output = Self>,

Multiplies interleaved complex lanes in-place: a[k] *= b[k] (a[k] *= conj(b[k]) when CONJ_B).

Source

fn interleaved_complex_dot<const CONJ_B: bool>( a: &[Self], b: &[Self], ) -> Result<(Self, Self), SimdError>
where Self: Neg<Output = Self>,

Computes the interleaved complex dot product (re, im) of sum(a[k] * b[k]) (sum(a[k] * conj(b[k])) when CONJ_B).

Source

fn reduce_popcount(data: &[Self]) -> usize

Computes the horizontal sum of population counts of all elements.

Source

fn reduce_popcount_and(a: &[Self], b: &[Self]) -> Result<usize, SimdError>

Computes the horizontal sum of population counts of a[i] & b[i].

Source

fn reduce_popcount_or(a: &[Self], b: &[Self]) -> Result<usize, SimdError>

Computes the horizontal sum of population counts of a[i] | b[i].

Source

fn reduce_popcount_xor(a: &[Self], b: &[Self]) -> Result<usize, SimdError>

Computes the horizontal sum of population counts of a[i] ^ b[i] (Hamming distance).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<T> SimdOps for T
where T: ScalarTrait + Sealed, Scalar: SimdKernel<T>, Avx2: SimdKernel<T>, Avx512: SimdKernel<T>,

Available on x86 or x86-64 only.

x86/x86_64 specialized generic implementation of SimdOps.