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
impl SimdBackend
Sourcepub fn dot_product(self, a: &[f32], b: &[f32]) -> f32
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].
Sourcepub fn dual_dot_product(
self,
input: &[f32],
k1: &[f32],
k2: &[f32],
) -> (f32, f32)
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.
Sourcepub fn convolve_sinc(
self,
input: &[f32],
k1: &[f32],
k2: &[f32],
kernel_interpolation_factor: f64,
) -> f32
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.
Sourcepub fn multiply_accumulate(self, acc: &mut [f32], a: &[f32], b: &[f32])
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.
Sourcepub fn elementwise_sqrt(self, x: &mut [f32])
pub fn elementwise_sqrt(self, x: &mut [f32])
Elementwise square root: x[i] = sqrt(x[i])
Sourcepub fn elementwise_multiply(self, x: &[f32], y: &[f32], z: &mut [f32])
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.
Sourcepub fn elementwise_accumulate(self, x: &[f32], z: &mut [f32])
pub fn elementwise_accumulate(self, x: &[f32], z: &mut [f32])
Elementwise accumulate: z[i] += x[i]
x and z must have the same length.
Sourcepub fn power_spectrum(self, re: &[f32], im: &[f32], out: &mut [f32])
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.
Sourcepub fn elementwise_min(self, a: &[f32], b: &[f32], out: &mut [f32])
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.
Sourcepub fn elementwise_max(self, a: &[f32], b: &[f32], out: &mut [f32])
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.
Sourcepub 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],
)
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.
Sourcepub 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],
)
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
impl Clone for SimdBackend
Source§fn clone(&self) -> SimdBackend
fn clone(&self) -> SimdBackend
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more