Expand description
SIMD-accelerated vector operations
This module provides high-performance SIMD implementations of vector operations
for x86_64 (AVX2, SSE) and ARM (NEON) architectures. The implementations use
the pulp crate for portable SIMD abstraction with runtime CPU detection.
§Performance
SIMD implementations provide 3-4x speedup over scalar operations for typical embedding dimensions (384, 768, 1024). The exact speedup depends on:
- Vector length (longer vectors benefit more)
- CPU architecture and SIMD support
- Memory alignment and cache behavior
§Architecture Support
- x86_64: AVX2 (8x f32), SSE (4x f32), scalar fallback
- ARM: NEON (4x f32), scalar fallback
- Other: Scalar fallback
§Usage
use foxstash_core::vector::simd::{dot_product_simd, cosine_similarity_simd};
let a = vec![1.0; 384];
let b = vec![2.0; 384];
let dot = dot_product_simd(&a, &b);
let similarity = cosine_similarity_simd(&a, &b);Functions§
- cosine_
distance_ prenorm - Computes cosine distance with a precomputed norm for vector
b. - cosine_
similarity_ simd - Computes cosine similarity using SIMD acceleration.
- dot_
product_ simd - Computes dot product using SIMD acceleration.
- l2_
distance_ simd - Computes L2 (Euclidean) distance using SIMD acceleration.
- norm_
simd - Computes the L2 norm (magnitude) of a vector using SIMD acceleration.