1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
//! # simdispatch — SIMD backend selection for the FEC stack
//!
//! [`simdispatch`](crate) 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`](https://github.com/imazen/archmage)
//! capability tokens: a tier is "on the host" exactly when its token
//! [`summon`](archmage::SimdToken::summon)s. 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.
extern crate std;
pub use ;
pub use Selection;
pub use internals;
use LazyLock;
/// The process-wide resolution of the full ladder [`Backend::ALL`], narrowed
/// to nothing, then adjusted by the `SIMD_BACKEND` override.
static BACKEND: = new;
/// The backend the full ecosystem ladder resolves to on this host, detected
/// once per process.
///
/// This is the *un-narrowed* answer: the strongest [`Backend`] a host that
/// implemented every tier could use. A consumer that implements only a subset
/// must resolve its own [`Selection`] rather than reuse this value.
/// The backend the full ecosystem ladder resolves to on this host.
///
/// Without `std` there is no runtime detection and no environment override,
/// so this reports [`Backend::Scalar`] unconditionally.