Skip to main content

Crate simdispatch

Crate simdispatch 

Source
Expand description

§simdispatch — SIMD backend selection for the FEC stack

simdispatch is the Level 0 crate: the single source for SIMD capability selection across the FEC ecosystem. Everything else that ships vector kernels — fff, cafft, and every future consumer — gets its backend from here.

Capability proof comes from archmage capability tokens: a tier is “on the host” exactly when its token summons. There is one probe in the whole stack, and it lives here.

§The two primitives

  • Backend — the ladder. Variants are named after the archmage tier they prove and ordered by that tier’s dispatch priority (strongest first), so the order carries capability and cannot drift from archmage’s source of truth.
  • Selection — a consumer declares the backends it implements (Selection::supports) and resolves the choice for the current host: detected via summon, narrowed to the supported set, then adjusted by the downgrade-only SIMD_BACKEND override. Refusing to upgrade is a soundness property: running vector code the CPU cannot execute is undefined behaviour, not a preference.

backend() reports the process-wide resolution of the full ladder (Backend::ALL); a consumer with a narrower kernel set builds its own Selection instead.

§SIMD_BACKEND

The one stack-wide override, replacing the per-crate FFF_BACKEND / CAFFT_BACKEND as crates migrate. Accepted values are Backend::name() values (scalar, v1, v2, v3, v3_gfni_crypto, v4, v4x, neon, neon_aes, wasm128). It is downgrade-only: a request for a backend the host cannot run, or one stronger than what detection found, is ignored. The v4 and v4x tiers are available with the avx512 feature. SIMD_BACKEND=scalar forces the whole stack to portable code — the escape hatch operators and differential testing need.

§no_std

The crate is #![no_std]. Without the std feature there is no environment and no runtime detection, so backend() and any Selection::resolve report Backend::Scalar unconditionally — matching how the field kernels behave on a std-less build.

§Non-scope

No kernels, no intrinsics, no dispatch tables, no unsafe. Consumers keep every #[target_feature] function; this crate only answers which of them is legal to call on the current host.

Structs§

ParseBackendError
Error returned when a Backend name is not recognized.
Selection
A resolve pipeline: host detection via archmage summon(), narrowed to a consumer’s supported set, then adjusted by a downgrade-only environment override.

Enums§

Backend
The SIMD capability ladder, one variant per archmage tier the ecosystem has kernels for.

Functions§

backend
The backend the full ecosystem ladder resolves to on this host, detected once per process.