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§
Sourcefn abs_sum(data: &[Self]) -> Self
fn abs_sum(data: &[Self]) -> Self
Reduces the slice to Σ |x| (L1-norm accumulator); T::ZERO for empty.
Sourcefn abs_max(data: &[Self]) -> Self
fn abs_max(data: &[Self]) -> Self
Reduces the slice to max |x| (∞-norm accumulator); T::ZERO for empty.
Sourcefn min(data: &[Self]) -> Self
fn min(data: &[Self]) -> Self
Reduces the slice to its minimum element.
Returns T::MAX_VALUE for empty slices (the identity element for min).
Sourcefn max(data: &[Self]) -> Self
fn max(data: &[Self]) -> Self
Reduces the slice to its maximum element.
Returns T::MIN_VALUE for empty slices (the identity element for max).
Sourcefn argmin(data: &[Self]) -> Option<(usize, Self)>
fn argmin(data: &[Self]) -> Option<(usize, Self)>
Returns Some((index, value)) of the minimum element, or None for empty.
Sourcefn argmax(data: &[Self]) -> Option<(usize, Self)>
fn argmax(data: &[Self]) -> Option<(usize, Self)>
Returns Some((index, value)) of the maximum element, or None for empty.
Sourcefn dot(a: &[Self], b: &[Self]) -> Result<Self, SimdError>
fn dot(a: &[Self], b: &[Self]) -> Result<Self, SimdError>
Computes the dot product of two slices.
Sourcefn axpy(alpha: Self, x: &[Self], out: &mut [Self]) -> Result<(), SimdError>
fn axpy(alpha: Self, x: &[Self], out: &mut [Self]) -> Result<(), SimdError>
Fused row update out[i] += alpha * x[i] (AXPY) with no temporaries.
Sourcefn axpy_mul(
alpha: Self,
a: &[Self],
b: &[Self],
out: &mut [Self],
) -> Result<(), SimdError>
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.
Sourcefn axpy_rows(
alphas: &[Self],
x: &[Self],
out: &mut [Self],
row_stride: usize,
rows: usize,
cols: usize,
) -> Result<(), SimdError>
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].
Sourcefn axpy_rows_batch(
alphas: &[Self],
x_panel: &[Self],
out: &mut [Self],
row_stride: usize,
rows: usize,
depth: 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>
Fused batched multi-row update:
out[row, i] += sum_k alphas[k, row] * x_panel[k, i].
Sourcefn elementwise_mul(
a: &[Self],
b: &[Self],
out: &mut [Self],
) -> Result<(), SimdError>
fn elementwise_mul( a: &[Self], b: &[Self], out: &mut [Self], ) -> Result<(), SimdError>
Computes the elementwise product and writes to out.
Sourcefn elementwise_add(
a: &[Self],
b: &[Self],
out: &mut [Self],
) -> Result<(), SimdError>
fn elementwise_add( a: &[Self], b: &[Self], out: &mut [Self], ) -> Result<(), SimdError>
Computes the elementwise sum a[i] + b[i] and writes to out.
Sourcefn elementwise_sub(
a: &[Self],
b: &[Self],
out: &mut [Self],
) -> Result<(), SimdError>
fn elementwise_sub( a: &[Self], b: &[Self], out: &mut [Self], ) -> Result<(), SimdError>
Computes the elementwise difference a[i] - b[i] and writes to out.
Sourcefn elementwise_div(
a: &[Self],
b: &[Self],
out: &mut [Self],
) -> Result<(), SimdError>
fn elementwise_div( a: &[Self], b: &[Self], out: &mut [Self], ) -> Result<(), SimdError>
Computes the elementwise quotient a[i] / b[i] and writes to out.
Sourcefn masked_sum(data: &[Self], mask: &[bool]) -> Self
fn masked_sum(data: &[Self], mask: &[bool]) -> Self
Computes the sum of elements matching a boolean mask.
Sourcefn masked_dot(a: &[Self], b: &[Self], mask: &[bool]) -> Result<Self, SimdError>
fn masked_dot(a: &[Self], b: &[Self], mask: &[bool]) -> Result<Self, SimdError>
Computes the dot product of elements matching a boolean mask.
Sourcefn masked_add(
a: &[Self],
b: &[Self],
mask: &[bool],
out: &mut [Self],
) -> Result<(), SimdError>
fn masked_add( a: &[Self], b: &[Self], mask: &[bool], out: &mut [Self], ) -> Result<(), SimdError>
Computes the elementwise sum of elements matching a boolean mask.
Sourcefn spmv_csr(data: ValidatedData<CsrData<'_, Self>>, x: &[Self], y: &mut [Self])
fn spmv_csr(data: ValidatedData<CsrData<'_, Self>>, x: &[Self], y: &mut [Self])
Computes sparse SpMV using CSR.
Sourcefn spmv_bcoo<const BM: usize, const BN: usize>(
data: ValidatedData<BlockedCooData<'_, Self, BM, BN>>,
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], )
Computes sparse SpMV using const-generic Blocked-COO tiles.
Sourcefn spmv_dense_masked(
data: DenseWithMaskData<'_, Self>,
x: &[Self],
y: &mut [Self],
)
fn spmv_dense_masked( data: DenseWithMaskData<'_, Self>, x: &[Self], y: &mut [Self], )
Computes sparse SpMV using Dense-with-Mask.
Sourcefn spmv_sellp<const C: usize>(
data: ValidatedData<SellPData<'_, Self, C>>,
x: &[Self],
y: &mut [Self],
)
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).
Sourcefn tiled_gemm(
a: &[Self],
b: &[Self],
c: &mut [Self],
m: usize,
n: usize,
k: usize,
) -> Result<(), SimdError>
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.
Sourcefn gemv(
a: &[Self],
x: &[Self],
y: &mut [Self],
nrows: usize,
ncols: usize,
) -> Result<(), SimdError>
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).
Sourcefn gemv_transpose(
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>
Computes register-blocked transposed GEMV: y += Aᵀ * x
(A row-major nrows × ncols, x length nrows, y length ncols).
Sourcefn gemv_strided(
a: &[Self],
x: &[Self],
y: &mut [Self],
nrows: usize,
ncols: usize,
lda: usize,
) -> Result<(), SimdError>
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).
Sourcefn gemv_transpose_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>
Computes register-blocked transposed sub-matrix GEMV: y += Aᵀ * x with
row stride lda ≥ ncols (lda = ncols is the packed Self::gemv_transpose).
Sourcefn interleaved_complex_mul_assign<const CONJ_B: bool>(
a: &mut [Self],
b: &[Self],
) -> Result<(), SimdError>where
Self: Neg<Output = Self>,
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).
Sourcefn interleaved_complex_dot<const CONJ_B: bool>(
a: &[Self],
b: &[Self],
) -> Result<(Self, Self), 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>,
Computes the interleaved complex dot product (re, im) of sum(a[k] * b[k])
(sum(a[k] * conj(b[k])) when CONJ_B).
Sourcefn reduce_popcount(data: &[Self]) -> usize
fn reduce_popcount(data: &[Self]) -> usize
Computes the horizontal sum of population counts of all elements.
Sourcefn reduce_popcount_and(a: &[Self], b: &[Self]) -> Result<usize, SimdError>
fn reduce_popcount_and(a: &[Self], b: &[Self]) -> Result<usize, SimdError>
Computes the horizontal sum of population counts of a[i] & b[i].
Sourcefn reduce_popcount_or(a: &[Self], b: &[Self]) -> Result<usize, SimdError>
fn reduce_popcount_or(a: &[Self], b: &[Self]) -> Result<usize, SimdError>
Computes the horizontal sum of population counts of a[i] | b[i].
Sourcefn reduce_popcount_xor(a: &[Self], b: &[Self]) -> Result<usize, SimdError>
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".