Expand description
Native SIMD intrinsics for maximum performance.
This module provides hand-tuned SIMD implementations using core::arch intrinsics
for AVX-512, AVX2, and ARM NEON architectures.
§Module Structure
scalar— Scalar fallback implementations and fast-rsqrt helperstail_unroll— Remainder/tail handling macros for SIMD loopsprefetch— CPU cache prefetch utilitiesreduction— Shared horizontal sum helpers for SIMD accumulatorsx86_avx512— AVX-512F kernel implementations (x86_64 only)x86_avx2— AVX2+FMA dot product and squared L2 kernels (x86_64 only)x86_avx2_similarity— AVX2+FMA cosine, Hamming, Jaccard kernels (x86_64 only)neon— ARM NEON kernel implementations (aarch64 only)dispatch— Runtime SIMD level detection and dispatch wiring
§Performance (based on arXiv research)
- AVX-512: True 16-wide f32 operations with masked remainder
- AVX2: 8-wide f32 with FMA, multi-accumulator ILP
- ARM NEON: Native 128-bit SIMD for Apple Silicon/ARM64
- Prefetch: Software prefetching for cache optimization
§References
- arXiv:2505.07621 “Bang for the Buck: Vector Search on Cloud CPUs”
- arXiv:2502.18113 “Accelerating Graph Indexing for ANNS on Modern CPUs”
Re-exports§
pub use scalar::cosine_similarity_fast;pub use scalar::fast_rsqrt;pub use prefetch::calculate_prefetch_distance;pub use prefetch::prefetch_vector;pub use prefetch::prefetch_vector_multi_cache_line;pub use prefetch::prefetch_vector_u64;pub use prefetch::L2_CACHE_LINE_BYTES;
Modules§
- adc
- ADC (Asymmetric Distance Computation) for PQ-compressed vector search.
- prefetch
- CPU cache prefetch utilities for SIMD operations.
- scalar
- Scalar fallback implementations for SIMD distance metrics.
Structs§
- Distance
Engine - Pre-resolved SIMD kernels for repeated distance operations at a fixed dimension.
Enums§
- Simd
Level - SIMD capability level detected at runtime.
Functions§
- batch_
cosine_ native - Batch cosine similarity with cross-platform multi-level prefetch hints.
- batch_
dot_ product_ native - Batch dot product with cross-platform multi-level prefetch hints.
- batch_
euclidean_ native - Batch euclidean distance with cross-platform multi-level prefetch hints.
- batch_
hamming_ native - Batch Hamming distance with cross-platform multi-level prefetch hints.
- batch_
jaccard_ native - Batch Jaccard similarity with cross-platform multi-level prefetch hints.
- batch_
squared_ l2_ native - Batch squared L2 distance with cross-platform multi-level prefetch hints.
- cosine_
normalized_ native - Cosine for pre-normalized vectors with runtime SIMD dispatch.
- cosine_
similarity_ native - Cosine similarity with runtime SIMD dispatch.
- dot_
product_ native - Dot product with runtime SIMD dispatch.
- euclidean_
native - Euclidean distance with runtime SIMD dispatch.
- hamming_
binary_ native - Binary Hamming distance with runtime SIMD dispatch.
- hamming_
distance_ native - Hamming distance with runtime SIMD dispatch.
- jaccard_
similarity_ native - Jaccard similarity with runtime SIMD dispatch.
- norm_
native - L2 norm with runtime SIMD dispatch.
- normalize_
inplace_ native - In-place normalization with runtime SIMD dispatch.
- simd_
level - Returns the cached SIMD level for the current process.
- squared_
l2_ native - Squared L2 distance with runtime SIMD dispatch.
- warmup_
simd_ cache - Warms up runtime SIMD dispatch cache and CPU caches for common dimensions.