pub struct SimdVectorOps;Expand description
SIMD-optimized vector operations for high-performance similarity calculations
Production optimizations:
- AVX-512 support for modern CPUs (8x performance improvement)
- FMA (Fused Multiply-Add) instructions for better precision and performance
- Cache-aware processing for large vector batches
- Memory prefetching for optimal cache utilization
- Aligned memory access patterns
Implementations§
Source§impl SimdVectorOps
impl SimdVectorOps
Sourcepub fn dot_product(a: &Array1<f32>, b: &Array1<f32>) -> f32
pub fn dot_product(a: &Array1<f32>, b: &Array1<f32>) -> f32
Compute dot product using SIMD instructions
This provides 2-8x speedup over naive implementations by using AVX-512/AVX2/SSE instructions when available, with automatic CPU feature detection and optimal instruction selection.
Performance optimizations:
- AVX-512: 16 f32 operations per instruction (8x speedup)
- FMA instructions: Fused multiply-add for better precision
- Memory prefetching for cache optimization
- Unrolled loops for reduced overhead
Sourcepub fn squared_norm(a: &Array1<f32>) -> f32
pub fn squared_norm(a: &Array1<f32>) -> f32
Compute squared L2 norm using SIMD instructions
Sourcepub fn cosine_similarity(a: &Array1<f32>, b: &Array1<f32>) -> f32
pub fn cosine_similarity(a: &Array1<f32>, b: &Array1<f32>) -> f32
Compute cosine similarity using SIMD-optimized operations
Auto Trait Implementations§
impl Freeze for SimdVectorOps
impl RefUnwindSafe for SimdVectorOps
impl Send for SimdVectorOps
impl Sync for SimdVectorOps
impl Unpin for SimdVectorOps
impl UnwindSafe for SimdVectorOps
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more