Expand description
hydroplane: float-agnostic, ISPC-style SPMD/SIMD infrastructure.
Write one kernel generic over the scalar element (Scalar: f32, f64, f16, bf16);
dispatch() runs it on the widest backend runtime CPU detection finds, else the portable
ScalarBackend (also the rust-gpu/SPIR-V lowering target). Kernels never name a backend.
Stable Rust, no_std-compatible, no SIMD-crate dependency; f16/bf16 come from the
half crate, re-exported as f16/bf16.
Re-exports§
pub use backend::Backend;pub use backend::BackendAll;pub use backend::ScalarBackend;pub use dispatch::Kernel;pub use dispatch::SimdDispatch;pub use dispatch::dispatch;pub use dispatch::run_scalar;pub use dense::Diag;pub use dense::Mat;pub use dense::Side;pub use dense::Trans;pub use dense::Uplo;pub use dense::col_sums;pub use dense::fro_norm;pub use dense::gemv;pub use dense::row_sums;pub use dense::MatMut;pub use dense::gemm;pub use dense::potrf;pub use dense::syrk;pub use dense::trsm;pub use matrix::Accumulator;pub use matrix::Layout;pub use matrix::MatrixA;pub use matrix::MatrixB;pub use matrix::MatrixBackend;pub use matrix::MatrixDispatch;pub use matrix::MatrixKernel;pub use matrix::Role;pub use matrix::Tile;pub use matrix::Tiles;pub use matrix::dispatch_matrix;pub use matrix::run_matrix_scalar;pub use scalar::FloatScalar;pub use scalar::IntScalar;pub use scalar::Scalar;pub use varying::ChunksExact;pub use varying::Varying;pub use varying::VaryingI32;pub use varying::VaryingU32;pub use varying::Mask;pub use varying::Gang;pub use cols::Cols;pub use soa::Soa;pub use num_traits;
Modules§
- arch
- Low-level SIMD primitives (raw
asm!) and the ARM backend-selection policy. Scalable (SVE/RVV) registers can’t live in Rust structs, so ops work on fixed-size memory images: one byte width = one vector length = one backend. - backend
- ISA tokens: a
Backend<T>is a zero-sized token identifying an instruction set (scalar, AVX2, NEON, …, GPU subgroup) for a specific scalarT, each(ISA, scalar)pair its own impl. The lane count is afn, not aconst: the GPU subgroup only learns it at runtime. - cols
- Fixed-arity bundles of SoA columns:
ColsownsNparallelVec<T>planes and hands out[&[T]; N]/[&mut [T]; N]views. The planes are unpadded, so kernels overColsviews use the masked-tail combinators (orload_partial) rather than sentinel padding. - dense
- Runtime-dimensioned dense linear algebra (the compile-time tile counterpart is
matrix). Every routine goes to Apple Accelerate where present, otherwise to a fallback built on the SIMD backend (Gang/Varying). - dispatch
- Entry points that pick a
Backendand run a genericKernel: runtime CPU detection chooses the widest implemented backend per scalar (build-timetarget_features on no-std or under--cfg hp_static_dispatch), withScalarBackendas the universal fallback. - matrix
- Portable tile matrix-multiply:
MatrixBackendextends the element-wiseBackendwith a 2-D tile and the fused multiply-addD = A·B + C, lowered per backend. Mixed precision followsFloatScalar::Compute: anf16matmul accumulates inf32. - scalar
- The “uniform” scalar element abstraction:
Scalaris the element a kernel operates on. Each float scalar declaresFloatScalar::Compute, the precision its math is carried out in — the type itself forf32/f64;f32forf16/bf16, which widen-compute-narrow. - soa
- Columnar (SoA) storage padded to
MAX_LANESso kernels never need a remainder path; tail lanes take a caller-chosen fill (e.g.NaNradius). Requiresalloc. - varying
- The ergonomic “varying” surface:
Gangis the load/splat context,Varying/Maskwrap a whole backend register (the ISPC “varying”) with operator overloads, so kernels read like ordinary scalar Rust. Everything isCopyand monomorphizes per(Backend, Scalar).
Structs§
- bf16
f16/bf16element types (from thehalfcrate), usable anywhere aScalaris expected. A 16-bit floating point type implementing thebfloat16format.- f16
f16/bf16element types (from thehalfcrate), usable anywhere aScalaris expected. A 16-bit floating point type implementing the IEEE 754-2008 standardbinary16a.k.a “half” format.
Constants§
- MAX_
LANES - Padding granularity: the widest lane count we target (AVX-512-FP16 is 32-wide f16). Every
backend’s lane count (1, 2, 4, 8, 16, 32) divides this, so a full-register loop never has
a remainder, and a single inline
[T; MAX_LANES]buffer holds any one register. - MAX_
UNROLL - Upper bound on a backend’s
UNROLL: the most independent accumulator chains any reduction unrolls to. Sizes the fixed[init; MAX_UNROLL]chain array, so a backend’sUNROLLmust not exceed it.
Attribute Macros§
- kernel
- The
#[kernel]attribute: write aKernel/MatrixKernelas a plain generic function. Contexts, tuning flags (tiny,noalias,unroll = N), the generated<name>_oncompanion for calling one kernel from another without re-dispatching, and thematrixform are all documented on the attribute itself. Generate aKernel(or, with#[kernel(matrix)], aMatrixKernel) and a dispatching wrapper from one annotated function. See the crate docs for the full shape.