tropical_gemm/simd/mod.rs
1//! SIMD-optimized microkernels for tropical GEMM.
2//!
3//! This module provides architecture-specific SIMD implementations of the
4//! microkernel, which is the innermost loop of the BLIS-style GEMM algorithm.
5//!
6//! # Supported Architectures
7//!
8//! | Architecture | Instruction Set | Register Width | Supported Types |
9//! |--------------|-----------------|----------------|-----------------|
10//! | x86_64 | AVX2 | 256-bit | f32/f64 argmax, u32/u64 Bitwise, selected float value kernels |
11//! | aarch64 | NEON | 128-bit | f32/f64 argmax, u32/u64 Bitwise, selected float value kernels |
12//! | Any | Portable | Scalar | All types |
13//!
14//! # Runtime Dispatch
15//!
16//! At runtime, [`tropical_gemm_dispatch`] selects the best kernel:
17//!
18//! ```rust,ignore
19//! // Automatically uses AVX2 on supported CPUs
20//! tropical_gemm_dispatch::<MaxPlus<f32>>(...);
21//! ```
22//!
23//! The dispatch mechanism:
24//! 1. [`simd_level()`] detects CPU features at runtime
25//! 2. [`KernelDispatch`] trait routes to the appropriate implementation
26//! 3. Falls back to portable kernel if no SIMD available
27//!
28//! # Microkernel Design
29//!
30//! For tropical MaxPlus f32 with AVX2 (8-wide vectors):
31//!
32//! ```text
33//! // MR×NR = 8×8 output tile
34//! for k in 0..KC:
35//! a_vec = load_8xf32(packed_a) // 8 elements from A column
36//! for j in 0..8:
37//! b_scalar = broadcast(packed_b[j]) // 1 element from B row
38//! prod = a_vec + b_scalar // tropical multiply
39//! c[j] = max(c[j], prod) // tropical accumulate
40//! ```
41//!
42//! # Module Contents
43//!
44//! - [`detect`](detect): CPU feature detection ([`SimdLevel`])
45//! - [`dispatch`](dispatch): Runtime kernel selection ([`KernelDispatch`])
46//! - [`kernels`](kernels): Architecture-specific microkernel implementations
47
48mod argmax;
49mod detect;
50pub mod dispatch;
51pub mod kernels;
52
53pub use detect::{simd_level, SimdLevel};
54pub use dispatch::{tropical_gemm_dispatch, tropical_gemm_with_argmax_dispatch, KernelDispatch};
55pub use kernels::*;