Bridge Core
Shared utilities for BridgeRust engines.
SIMD Optimizations
The simd module provides high-performance vector operations with automatic SIMD acceleration when available.
Available Operations
dot_product(a, b)- Computes the dot product of two vectorsl2_distance(a, b)- Computes the Euclidean distance between two vectorscosine_similarity(a, b)- Computes cosine similarity (range: [-1, 1])normalize_in_place(v)- Normalizes a vector to unit length in-placel2_norm(v)- Computes the L2 norm (magnitude) of a vector
Enabling SIMD
SIMD optimizations are enabled via compile-time flags:
For x86_64 with AVX2:
RUSTFLAGS="-C target-feature=+avx2"
For x86_64 with SSE4.1:
RUSTFLAGS="-C target-feature=+sse4.1"
For ARM64 with NEON:
RUSTFLAGS="-C target-feature=+neon"
The functions automatically fall back to scalar implementations when SIMD is not available, ensuring compatibility across all platforms.
Performance
Expected speedups:
- AVX2: 5-8x faster than scalar for large vectors (512+ dimensions)
- SSE4.1: 3-4x faster than scalar
- NEON: 3-4x faster than scalar
Run benchmarks to measure actual performance on your hardware: