Expand description
SIMD-accelerated distance calculations
This module provides SIMD-optimized implementations of distance metrics for improved performance on supported CPUs.
§Features
- Auto-vectorization hints: Helps the compiler generate SIMD code
- x86_64 optimizations: Automatically uses AVX-512, FMA+AVX2, or AVX2 when available
- aarch64 optimizations: Automatically uses NEON (always available on ARM64)
- Cache-friendly: Optimized memory access patterns
- Fallback: Automatically falls back to auto-vectorization on unsupported platforms
§Performance Hierarchy
- x86_64: AVX-512 (16-wide) → FMA+AVX2 (8-wide) → AVX2 (8-wide) → auto-vectorization
- aarch64: NEON (4-wide)
- other: auto-vectorization
§Usage
use oxify_vector::simd::cosine_similarity_simd;
let v1 = vec![1.0, 2.0, 3.0, 4.0];
let v2 = vec![2.0, 3.0, 4.0, 5.0];
let similarity = cosine_similarity_simd(&v1, &v2);Functions§
- compute_
distance_ lower_ is_ better_ simd - Compute distance using the specified metric with SIMD optimization
- compute_
distance_ simd - Compute similarity/distance using the specified metric with SIMD optimization
- cosine_
similarity_ simd - SIMD-optimized cosine similarity calculation
- dot_
product_ simd - SIMD-optimized dot product calculation
- euclidean_
distance_ simd - SIMD-optimized Euclidean distance calculation
- is_
avx2_ available - Check if AVX2 is available at runtime
- is_
avx512_ available - Check if AVX-512 is available at runtime (x86_64 only)
- is_
fma_ available - Check if FMA is available at runtime
- is_
neon_ available - Check if NEON is available at runtime (non-aarch64 always returns false)
- manhattan_
distance_ simd - SIMD-optimized Manhattan distance calculation
- normalize_
vector_ simd - Normalize a vector in-place using SIMD optimization
- quantized_
dot_ product_ simd - Compute dot product between two quantized (u8) vectors using SIMD
- quantized_
euclidean_ squared_ simd - Compute Euclidean distance between two quantized (u8) vectors using SIMD
- quantized_
manhattan_ distance_ simd - Compute Manhattan distance between two quantized (u8) vectors using SIMD
- scale_
vector_ simd - Scale a vector by a constant using SIMD optimization