Skip to main content

SimdBackend

Enum SimdBackend 

Source
pub enum SimdBackend {
    Scalar,
    Sse2,
    Avx2,
}
Expand description

Available SIMD backends, selected at runtime based on CPU features.

Variants§

§

Scalar

Scalar fallback — works on all platforms.

§

Sse2

x86/x86_64 SSE2 (128-bit, 4 floats at a time).

§

Avx2

x86/x86_64 AVX2 + FMA (256-bit, 8 floats at a time).

Implementations§

Source§

impl SimdBackend

Source

pub fn name(self) -> &'static str

Returns the name of this backend.

Source

pub fn dot_product(self, a: &[f32], b: &[f32]) -> f32

Compute the dot product of two float slices.

a and b must have the same length. Returns sum of a[i]*b[i].

Source

pub fn dual_dot_product( self, input: &[f32], k1: &[f32], k2: &[f32], ) -> (f32, f32)

Compute two dot products in parallel (for sinc resampler convolution).

Returns (dot(input, k1), dot(input, k2)). All slices must have the same length.

Source

pub fn convolve_sinc( self, input: &[f32], k1: &[f32], k2: &[f32], kernel_interpolation_factor: f64, ) -> f32

Sinc resampler convolution: dual dot product with interpolation.

Computes (1-f)*dot(input,k1) + f*dot(input,k2) where f is the kernel_interpolation_factor. Unlike dual_dot_product() followed by scalar interpolation, this performs interpolation on SIMD vectors before horizontal reduction, matching C++ SincResampler::Convolve_* rounding behavior exactly.

The scalar fallback interpolates in f64 matching C++ Convolve_C.

Source

pub fn multiply_accumulate(self, acc: &mut [f32], a: &[f32], b: &[f32])

Element-wise multiply-accumulate: acc[i] += a[i] * b[i]

acc, a, and b must have the same length.

Source

pub fn sum(self, x: &[f32]) -> f32

Compute the sum of all elements in a slice.

Source

pub fn elementwise_sqrt(self, x: &mut [f32])

Elementwise square root: x[i] = sqrt(x[i])

Source

pub fn elementwise_multiply(self, x: &[f32], y: &[f32], z: &mut [f32])

Elementwise vector multiplication: z[i] = x[i] * y[i]

x, y, and z must have the same length.

Source

pub fn elementwise_accumulate(self, x: &[f32], z: &mut [f32])

Elementwise accumulate: z[i] += x[i]

x and z must have the same length.

Source

pub fn power_spectrum(self, re: &[f32], im: &[f32], out: &mut [f32])

Compute the power spectrum: out[i] = re[i]^2 + im[i]^2

re, im, and out must have the same length.

Source

pub fn elementwise_min(self, a: &[f32], b: &[f32], out: &mut [f32])

Elementwise minimum: out[i] = min(a[i], b[i])

a, b, and out must have the same length.

Source

pub fn elementwise_max(self, a: &[f32], b: &[f32], out: &mut [f32])

Elementwise maximum: out[i] = max(a[i], b[i])

a, b, and out must have the same length.

Source

pub fn complex_multiply_accumulate( self, x_re: &[f32], x_im: &[f32], h_re: &[f32], h_im: &[f32], acc_re: &mut [f32], acc_im: &mut [f32], )

Complex multiply-accumulate (AEC3 conjugate convention): acc_re[i] += x_re[i]*h_re[i] + x_im[i]*h_im[i] acc_im[i] += x_re[i]*h_im[i] - x_im[i]*h_re[i]

All slices must have the same length.

Source

pub fn complex_multiply_accumulate_standard( self, x_re: &[f32], x_im: &[f32], h_re: &[f32], h_im: &[f32], acc_re: &mut [f32], acc_im: &mut [f32], )

Standard complex multiply-accumulate: acc_re[i] += x_re[i]*h_re[i] - x_im[i]*h_im[i] acc_im[i] += x_re[i]*h_im[i] + x_im[i]*h_re[i]

All slices must have the same length.

Trait Implementations§

Source§

impl Clone for SimdBackend

Source§

fn clone(&self) -> SimdBackend

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SimdBackend

Source§

impl Debug for SimdBackend

Source§

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

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

impl Eq for SimdBackend

Source§

impl PartialEq for SimdBackend

Source§

fn eq(&self, other: &SimdBackend) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SimdBackend

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.