Expand description
High-performance, zero-overhead SIMD abstraction library.
§Architecture
hermes-simd is the public facade for the hermes-simd workspace:
hermes_simd_core— core abstractions, traits, viewshermes_simd_intrinsics— architecture-specific kernelshermes_simd_macros— proc-macro code generation
§Feature Flags
| Feature | Description |
|---|---|
std (default) | Runtime CPU feature detection (is_x86_feature_detected!); without it dispatch uses compile-time cfg!(target_feature) only |
mnemosyne-memory (default) | Route AlignedVec allocation through the mnemosyne allocator |
libnuma | Linux NUMA affinity and residency probes via libnuma (links -lnuma); allocation still routes through Mnemosyne/the configured allocator |
§Usage Examples
Dense sum (runtime dispatch):
use hermes_simd::sum;
let data = vec![1.0f32; 1024];
assert_eq!(sum(&data), 1024.0);Masked dot product:
use hermes_simd::masked_dot;
let a = vec![1.0f32, 2.0, 3.0, 4.0, 5.0];
let b = vec![1.0f32; 5];
let mask = vec![true, false, true, false, true];
assert_eq!(masked_dot(&a, &b, &mask).unwrap(), 9.0); // 1+3+5Re-exports§
pub use attacks::bishop_attacks;pub use attacks::queen_attacks;pub use attacks::rook_attacks;pub use cpu::has_fma3;pub use cpu::AmxSupport;pub use cpu::Avx512Support;pub use cpu::FmaSupport;pub use dispatcher::AdaptiveDispatcher;pub use dispatcher::DispatchDecision;pub use target::dispatch_view_mut_to;pub use target::dispatch_view_to;pub use target::TargetId;pub use tile_matmul::dispatch_tile_matmul;pub use tile_matmul::gemm;pub use tile_matmul::unpack_int4;pub use tile_matmul::widen_I8_to_I16;pub use tile_matmul::widen_I8_to_I32;pub use tile_matmul::widen_i8_to_i16;pub use tile_matmul::widen_i8_to_i32;pub use tile_matmul::TiledGemm;pub use dispatch::abs_max;pub use dispatch::abs_sum;pub use dispatch::argmax;pub use dispatch::argmax;pub use dispatch::argmin;pub use dispatch::argmin;pub use dispatch::axpy;pub use dispatch::axpy_mul;pub use dispatch::axpy_rows;pub use dispatch::axpy_rows_batch;pub use dispatch::dot;pub use dispatch::dot;pub use dispatch::elementwise_add;pub use dispatch::elementwise_div;pub use dispatch::elementwise_mul;pub use dispatch::elementwise_sub;pub use dispatch::gemv;pub use dispatch::gemv;pub use dispatch::gemv_strided;pub use dispatch::gemv_strided;pub use dispatch::gemv_transpose;pub use dispatch::gemv_transpose;pub use dispatch::gemv_transpose_strided;pub use dispatch::gemv_transpose_strided;pub use dispatch::interleaved_complex_dot;pub use dispatch::interleaved_complex_dot_runtime;pub use dispatch::interleaved_complex_mul_assign;pub use dispatch::interleaved_complex_mul_assign_runtime;pub use dispatch::masked_add;pub use dispatch::masked_dot;pub use dispatch::masked_sum;pub use dispatch::max;pub use dispatch::max;pub use dispatch::min;pub use dispatch::min;pub use dispatch::ntt_butterfly_stage_u64;pub use dispatch::reduce_popcount;pub use dispatch::reduce_popcount_and;pub use dispatch::reduce_popcount_or;pub use dispatch::reduce_popcount_xor;pub use dispatch::scale;pub use dispatch::scale;pub use dispatch::spmv_bcoo;pub use dispatch::spmv_csr;pub use dispatch::spmv_dense_masked;pub use dispatch::spmv_sellp;pub use dispatch::sum;pub use dispatch::sum;pub use dispatch::tiled_gemm;pub use dispatch::SimdOps;
Modules§
- attacks
- Chess board attack generation kernels using bitboards and SWAR.
- cpu
- Runtime CPU feature detection utilities.
- dispatch
- Runtime-dispatched SIMD abstractions and dynamic facade. Runtime-dispatched SIMD operations.
- dispatcher
- Dynamic dispatcher choosing optimal backends based on hardware/layout. Dynamic runtime dispatch choosing the optimal execution backend.
- target
- Explicit runtime target tokens and forced dispatch helpers. Explicit SIMD target tokens and forced view dispatch helpers.
- tile_
matmul - Tiled matrix multiplication dispatch and kernel interfaces. Register-blocked tile matrix multiplication module.
Structs§
- Abs
- Elementwise absolute value:
|a[i]|. - Add
- Elementwise addition:
a[i] + b[i]. - Aligned
- A static alignment guarantee of
Abytes. - Aligned
Vec - A heap-allocated vector with statically guaranteed memory alignment layout.
- AmxBatch
Session - An RAII guard that encapsulates a complete AMX batch computation.
- AmxBf16
- x86/x86_64 AMX BF16 matrix multiply backend.
- AmxConfig
- 64-byte AMX tile configuration structure (TILECFG).
- AmxInt8
- x86/x86_64 AMX INT8 matrix multiply backend.
- AmxSession
- A session guard that manages AMX tile configuration lifecycle on the current thread.
- Archived
Packed4 Cow - Archived representation of a
Packed4Cowfor zero-copy deserialization. - Archived
Simd Cow - Archived representation of a
SimdCowused byrkyvzero-copy serialization. - Avx2
- x86/x86_64 AVX2 instruction set architecture marker.
- Avx512
- x86/x86_64 AVX-512F instruction set architecture marker.
- AvxVnni
- x86/x86_64 AVX-VNNI (256-bit VEX-encoded VNNI) instruction set marker.
- Bf4
- Brain Float 4: finite-only E2M1 with the top exponent reserved for NaN.
- Bf8
- Brain Float 8: IEEE-style E5M2 with infinity and NaN.
- Bf16
- bfloat16 (E8M7), stored as its raw
u16bit pattern. - BitAnd
- Elementwise bitwise AND:
a[i] & b[i]. - BitBoard
View - A zero-copy newtype family for chess bitboards.
- BitMask
- Bit-packed predicate mask for exactly
NSIMD lanes. - BitOr
- Elementwise bitwise OR:
a[i] | b[i]. - BitXor
- Elementwise bitwise XOR:
a[i] ^ b[i]. - Blocked
Coo - Blocked COO format marker.
- Clamp
- Elementwise clamp:
min(max(a[i], lo), hi). - ColMajor
- Column-major (Fortran-order) layout marker ZST.
- Csr
- Compressed Sparse Row format marker.
- Dense
With Mask - Dense storage with a boolean mask indicating non-zero elements.
- Div
- Elementwise division:
a[i] / b[i]. - Dot
- Dot-product pairwise operation: multiply two vectors lane-wise.
- Exclusive
- Exclusive scan ZST marker.
- F4
- Finite-only 4-bit float: E3M0 with the top exponent reserved for NaN.
- F8
- Finite-only 8-bit float: E4M3 with the top exponent reserved for NaN.
- F16
- IEEE 754 binary16 (half precision), stored as its raw
u16bit pattern. - F32
- Transparent wrapper for f32.
- F64
- Transparent wrapper for f64.
- FmaAdd
- Fused-multiply-add elementwise operation:
out[i] = a[i] * b[i] + a[i](binary form). - Hybrid
Swar Magic - ZST marker for hybrid SWAR and Magic Bitboards backend.
- Hyperbola
- ZST marker for Hyperbola Quintessence backend.
- I8
- Transparent wrapper for i8.
- I16
- Transparent wrapper for i16.
- I32
- Transparent wrapper for i32.
- Inclusive
- Inclusive scan ZST marker.
- Kogge
Stone - ZST marker for direction-parallel vectorized Kogge-Stone backend.
- Magic
- ZST marker for Fancy Magic Bitboards backend.
- Mask
- A type-safe, architecture-native SIMD mask type.
- Masked
- Predicated execution — a hardware mask selects active lanes.
- Mul
- Elementwise multiplication:
a[i] * b[i]. - Neg
- Elementwise negation:
-a[i]. - Neon
- AArch64 NEON instruction set architecture marker.
- Numa
Binding - RAII scope guard that binds the current thread to a specific NUMA node.
- Owned
Blocked Coo - Owned heap-backed Blocked-COO storage.
- Owned
Csr - Owned heap-backed CSR storage.
- Owned
Dense With Mask - Owned heap-backed DenseWithMask storage.
- Owned
SellP - Owned heap-backed SELL-p storage.
- Packed4
CowResolver - Resolver type for
Packed4Cow. - Packed4
Iter - Iterator over a packed 4-bit slice.
- Packed4
Slice - A read-only view over a packed slice of 4-bit values, stored 2 per byte.
- Packed4
Slice Mut - A mutable view over a packed slice of 4-bit values, stored 2 per byte.
- Packed4
Vec - A heap-allocated packed vector of 4-bit values, stored 2 per byte.
- Popcount
- Elementwise population count: count of set bits in each lane.
- Product
- Multiplicative reduction: computes
∏ data[i]. - Recip
Sqrt - Elementwise reciprocal square root:
1.0 / sqrt(a[i]). - RowMajor
- Row-major (C-order) layout marker ZST.
- Scalar
- Fallback scalar implementation marker.
- ScanAdd
- Addition scan strategy ZST marker.
- ScanMax
- Maximum scan strategy ZST marker.
- ScanMin
- Minimum scan strategy ZST marker.
- ScanMul
- Multiplication scan strategy ZST marker.
- SellP
- Sliced ELLPACK format marker.
- Simd
Chunks - Iterator over non-overlapping
LANE_COUNT-wide sub-views of aSimdView. - Simd
Chunks Mut - Iterator over non-overlapping mutable
LANE_COUNT-wide sub-views of aSimdView. - Simd
CowResolver - Resolver type for
SimdCowserialization. - Simd
View - A zero-copy, typed slice view parameterized by architecture, alignment, execution mode, and reference typestates.
- Sparse
View - Format-parameterized sparse matrix view.
- Sqrt
- Elementwise square root:
sqrt(a[i]). - Sub
- Elementwise subtraction:
a[i] - b[i]. - Sum
- Sum reduction: accumulate by adding vectors, finalize with
sum_reduce. - SveArch
- AArch64 SVE architecture ZST marker.
- Swar
- ZST marker for pure SWAR primitives backend.
- Swar
Utils - Pure SWAR bitwise utility primitives.
- Tensor
View - Zero-copy N-dimensional strided view over a borrowed slice.
- Tile
View - A 2D matrix tile view, parameterized by dimensions, alignment, execution mode, and backing reference type.
- Tiling
Policy - Zero-sized strategy marker for tiled execution policy.
- Unaligned
- No static alignment guarantee.
- Unmasked
- Dense execution — all lanes are active. Default mode for
crate::view::SimdView. - Validated
- Typestate marker for sparse formats whose structural invariants were checked before kernel entry.
- Validated
Data - Sparse storage whose structural invariants have been checked once at construction.
- Vector
- A monomorphized vector register type wrapping the architecture-native raw register.
- ZipChunks
- Iterator over non-overlapping paired
LANE_COUNT-wide sub-views of twoSimdViews. - ZipChunks
Mut - Paired iterator over non-overlapping
LANE_COUNT-wide sub-views where the first operand is mutable and the second is immutable.
Enums§
- AmxSession
Error - Error returned when an AMX session cannot be entered safely.
- Dispatched
View - Target-specific, runtime-dispatched SIMD view wrapper.
- Packed4
Cow - A Clone-on-Write (CoW) container for packed 4-bit elements.
- SimdCow
- A Clone-on-Write SIMD container.
- Simd
Error - Error types for SIMD view operations.
- Sparse
Cow - Clone-on-Write sparse matrix, generic over the storage format
F. - Tensor
Cow - A Clone-on-Write (CoW) container for strided tensors.
- Tensor
Error - Error type for tensor construction and indexing.
Traits§
- Alignment
- Trait representing a memory alignment guarantee.
- BitBoard
Kernel - Trait defining the sliding attack generation interface.
- Cast
From - Helper trait for generic casting between SIMD scalar types.
- CastTo
- Helper trait for generic casting to another SIMD scalar type.
- Compute
Reduce - Extension trait that provides
reduce()over anySimdView-backedComputeView. - Compute
View - Top-level trait abstracting over dense, masked, sparse, tiled, and bitboard backends.
- CowFormat
- Maps a sparse format marker to its owned storage and Cow conversions.
- Element
Op - Sealed ZST trait for pairwise SIMD elementwise operations.
- Execution
Mode - Marker trait for SIMD execution modes.
- Float
Element - Float-specific capabilities.
- Packable4
- Trait for 4-bit types that can be packed two per byte.
- Packed4
CowExt - Extension trait for packed Clone-on-Write containers to support zero-copy unpacking directly into
SimdCow. - Reduction
Op - Sealed ZST trait for SIMD horizontal reduction strategies.
- Scan
Mode - Sealed ZST trait for prefix scan inclusion modes.
- ScanOp
- Sealed ZST trait for prefix scan operations.
- Simd
Arch - Trait representing a SIMD instruction set architecture.
- Simd
CowExt - Extension trait for
SimdCowproviding vector-register level operations. - Simd
Kernel - Abstract trait defining low-level vector operations.
- Simd
Scalar - Core numeric element trait. The main extension point for monomorphized operations across all precisions.
- Sparse
Format - Marker trait for sparse matrix storage formats.
- Sparse
Ops - Unified trait for elementwise and reduction operations on sparse matrices.
- Sparse
SpMv - Unified trait for sparse matrix-vector multiplication.
- Tile
Matrix Multiply - Trait mediating zero-overhead matrix multiplication on 2D tiles.
- Tiling
Strategy - Trait representing a monomorphized register-blocking/tiling strategy.
- UnaryOp
- Sealed ZST trait for single-operand SIMD elementwise operations.
Functions§
- current_
numa_ node - Returns the index of the NUMA node the current thread is executing on.
- dispatch_
view - Dispatches a shared slice into the best matching
DispatchedViewbased on runtime CPU feature detection. - dispatch_
view_ mut - Dispatches a mutable slice into the best matching
DispatchedViewbased on runtime CPU feature detection. - refresh_
numa_ node - Refreshes and returns the current NUMA node index for the executing thread.
- tiled_
dot - Compute the dot product of two slices using
TILE_Mindependent vector accumulators. - tiled_
gemv - Compute a register-blocked tiled GEMV:
y += A * x. - unpack_
bf4_ to_ bf16 - Unpacks Bf4 elements to Bf16.
- unpack_
bf4_ to_ bf16_ packed - Unpacks packed 4-bit Bf4 pairs (stored 2 per byte) into a Bf16 slice.
- unpack_
bf8_ to_ bf16 - Unpacks Bf8 elements to Bf16.
- unpack_
f4_ to_ f32 - Unpacks F4 elements to F32.
- unpack_
f4_ to_ f32_ packed - Unpacks packed 4-bit F4 pairs (stored 2 per byte) into an F32 slice.
- unpack_
f8_ to_ f32 - Unpacks F8 elements to F32.
- verify_
numa_ locality - Verify if the physical memory backing a pointer range is resident on a specific node.
Type Aliases§
- Avx2Bf4
- Concrete AVX2 bfloat4 vector register (32 lanes).
- Avx2Bf8
- Concrete AVX2 bfloat8 vector register (32 lanes).
- Avx2
Bf16 - Concrete AVX2 bfloat16 vector register (16 lanes).
- Avx2F4
- Concrete AVX2 float4 vector register (32 lanes).
- Avx2F8
- Concrete AVX2 float8 vector register (32 lanes).
- Avx2F16
- Concrete AVX2 standard f16 vector register (16 lanes).
- Avx2F32
- Concrete AVX2 f32 vector register (8 lanes).
- Avx2F64
- Concrete AVX2 f64 vector register (4 lanes).
- Avx2I8
- Concrete AVX2 i8 vector register (32 lanes).
- Avx2I16
- Concrete AVX2 i16 vector register (16 lanes).
- Avx2I32
- Concrete AVX2 i32 vector register (8 lanes).
- Avx2
Mask Bf16 - Concrete AVX2 bfloat16 mask register (16 lanes).
- Avx2
Mask F16 - Concrete AVX2 f16 mask register (16 lanes).
- Avx2
Mask F32 - Concrete AVX2 f32 mask register (8 lanes).
- Avx2
Mask F64 - Concrete AVX2 f64 mask register (4 lanes).
- Avx512
Bf4 - Concrete AVX-512 bfloat4 vector register (64 lanes).
- Avx512
Bf8 - Concrete AVX-512 bfloat8 vector register (64 lanes).
- Avx512
Bf16 - Concrete AVX-512 bfloat16 vector register (32 lanes).
- Avx512
F4 - Concrete AVX-512 float4 vector register (64 lanes).
- Avx512
F8 - Concrete AVX-512 float8 vector register (64 lanes).
- Avx512
F16 - Concrete AVX-512 standard f16 vector register (32 lanes).
- Avx512
F32 - Concrete AVX-512 f32 vector register (16 lanes).
- Avx512
F64 - Concrete AVX-512 f64 vector register (8 lanes).
- Avx512
I8 - Concrete AVX-512 i8 vector register (64 lanes).
- Avx512
I16 - Concrete AVX-512 i16 vector register (32 lanes).
- Avx512
I32 - Concrete AVX-512 i32 vector register (16 lanes).
- Avx512
Mask Bf16 - Concrete AVX-512 bfloat16 mask register (32 lanes).
- Avx512
Mask F16 - Concrete AVX-512 f16 mask register (32 lanes).
- Avx512
Mask F32 - Concrete AVX-512 f32 mask register (16 lanes).
- Avx512
Mask F64 - Concrete AVX-512 f64 mask register (8 lanes).
- Blocked
CooData - Backward-compatible type alias.
- CsrData
- Backward-compatible type alias.
- Dense
With Mask Data - Backward-compatible type alias.
- MaskBf4
- Generic bfloat4 SIMD lane selection mask.
- MaskBf8
- Generic bfloat8 SIMD lane selection mask.
- Mask
Bf16 - Generic bfloat16 SIMD lane selection mask.
- MaskF4
- Generic float4 SIMD lane selection mask.
- MaskF8
- Generic float8 SIMD lane selection mask.
- MaskF16
- Generic standard f16 SIMD lane selection mask.
- MaskF32
- Generic f32 SIMD lane selection mask.
- MaskF64
- Generic f64 SIMD lane selection mask.
- MaskI8
- Generic i8 SIMD lane selection mask.
- MaskI16
- Generic i16 SIMD lane selection mask.
- MaskI32
- Generic i32 SIMD lane selection mask.
- Packed
Bf4Cow - Type alias for a Clone-on-Write view over packed Bf4 values.
- Packed
Bf4Slice - Type alias for a read-only view over a packed slice of Bf4 values.
- Packed
Bf4Slice Mut - Type alias for a mutable view over a packed slice of Bf4 values.
- Packed
Bf4Vec - Type alias for a heap-allocated packed vector of Bf4 values.
- Packed
F4Cow - Type alias for a Clone-on-Write view over packed F4 values.
- Packed
F4Slice - Type alias for a read-only view over a packed slice of F4 values.
- Packed
F4Slice Mut - Type alias for a mutable view over a packed slice of F4 values.
- Packed
F4Vec - Type alias for a heap-allocated packed vector of F4 values.
- Preferred
Arch - The optimal target architecture typestate compiled for the current host CPU target.
- Scalar
Bf4 - Concrete 1-element scalar emulation bfloat4 vector register.
- Scalar
Bf8 - Concrete 1-element scalar emulation bfloat8 vector register.
- Scalar
Bf16 - Concrete 1-element scalar emulation bfloat16 vector register.
- Scalar
F4 - Concrete 1-element scalar emulation float4 vector register.
- Scalar
F8 - Concrete 1-element scalar emulation float8 vector register.
- Scalar
F16 - Concrete 1-element scalar emulation f16 vector register.
- Scalar
F32 - Concrete 1-element scalar emulation f32 vector register.
- Scalar
F64 - Concrete 1-element scalar emulation f64 vector register.
- Scalar
I8 - Concrete 1-element scalar emulation i8 vector register.
- Scalar
I16 - Concrete 1-element scalar emulation i16 vector register.
- Scalar
I32 - Concrete 1-element scalar emulation i32 vector register.
- Scalar
Mask F32 - Concrete 1-element scalar emulation f32 mask register.
- Scalar
Mask F64 - Concrete 1-element scalar emulation f64 mask register.
- SellP
Data - Backward-compatible type alias.
- SimdBf4
- Optimal bfloat4 SIMD register compiled for the host.
- SimdBf8
- Optimal bfloat8 SIMD register compiled for the host.
- Simd
Bf16 - Optimal bfloat16 SIMD register compiled for the host.
- SimdF4
- Optimal float4 SIMD register compiled for the host.
- SimdF8
- Optimal float8 SIMD register compiled for the host.
- SimdF16
- Optimal f16 SIMD register compiled for the host.
- SimdF32
- Optimal f32 SIMD register compiled for the host.
- SimdF64
- Optimal f64 SIMD register compiled for the host.
- SimdI8
- Optimal i8 SIMD register compiled for the host.
- SimdI16
- Optimal i16 SIMD register compiled for the host.
- SimdI32
- Optimal i32 SIMD register compiled for the host.
- Simd
Mask Bf4 - Optimal bfloat4 SIMD mask register compiled for the host.
- Simd
Mask Bf8 - Optimal bfloat8 SIMD mask register compiled for the host.
- Simd
Mask Bf16 - Optimal bfloat16 SIMD mask register compiled for the host.
- Simd
Mask F4 - Optimal float4 SIMD mask register compiled for the host.
- Simd
Mask F8 - Optimal float8 SIMD mask register compiled for the host.
- Simd
Mask F16 - Optimal f16 SIMD mask register compiled for the host.
- Simd
Mask F32 - Optimal f32 SIMD mask register compiled for the host.
- Simd
Mask F64 - Optimal f64 SIMD mask register compiled for the host.
- Simd
Mask I8 - Optimal i8 SIMD mask register compiled for the host.
- Simd
Mask I16 - Optimal i16 SIMD mask register compiled for the host.
- Simd
Mask I32 - Optimal i32 SIMD mask register compiled for the host.
- Vector
Bf4 - Generic bfloat4 SIMD vector register.
- Vector
Bf8 - Generic bfloat8 SIMD vector register.
- Vector
Bf16 - Generic bfloat16 SIMD vector register.
- Vector
F4 - Generic float4 SIMD vector register.
- Vector
F8 - Generic float8 SIMD vector register.
- Vector
F16 - Generic standard f16 SIMD vector register.
- Vector
F32 - Generic f32 SIMD vector register.
- Vector
F64 - Generic f64 SIMD vector register.
- Vector
I8 - Generic i8 SIMD vector register.
- Vector
I16 - Generic i16 SIMD vector register.
- Vector
I32 - Generic i32 SIMD vector register.