Expand description
Attribute macros wrapping multiversion with predefined SIMD target presets.
This crate provides the #[multiversed] attribute that wraps #[multiversion::multiversion]
with carefully curated target sets for each architecture.
§Usage
ⓘ
use multiversed::multiversed;
// Use targets from enabled cargo features (default: x86-64-v3, x86-64-v4x, arm64-v2)
#[multiversed]
pub fn dot_product(a: &[f32], b: &[f32]) -> f32 {
a.iter().zip(b).map(|(x, y)| x * y).sum()
}
// Explicit presets
#[multiversed("x86-64-v4", "arm64-v2")]
pub fn optimized_sum(data: &[f32]) -> f32 {
data.iter().sum()
}
// Mix presets with custom raw target strings
#[multiversed("x86-64-v3", "aarch64+neon+dotprod")]
pub fn custom_targets(data: &[f32]) -> f32 {
data.iter().sum()
}§Cargo Features (Presets)
Feature lists match the archmage token registry — the source of truth. Each feature is a complete, non-cumulative preset based on the x86-64 psABI microarchitecture levels and ARM architecture versions.
§x86/x86_64
| Feature | Archmage Token | Key Features | Hardware |
|---|---|---|---|
x86-64-v2 | X64V2Token | SSE4.2, POPCNT | Nehalem 2008+, Bulldozer 2011+ |
x86-64-v3 | X64V3Token | AVX2, FMA, BMI1/2 | Haswell 2013+, Zen 1 2017+ |
x86-64-v4 | X64V4Token | AVX-512 (F/BW/DQ/VL/CD) | Skylake-X 2017+, Zen 4 2022+ |
x86-64-v4-modern / x86-64-v4x | X64V4xToken | + VNNI, VBMI2, GFNI, VAES | Ice Lake 2019+, Zen 4 2022+ |
Note: Intel consumer CPUs (Alder Lake 12th gen through Arrow Lake) do NOT have AVX-512 due to E-core limitations. Only Xeon server, i9-X workstation, and AMD Zen 4+ have AVX-512.
§aarch64
| Feature | Archmage Token | Key Features | Hardware |
|---|---|---|---|
arm64 / arm64-v2 | Arm64V2Token | NEON, CRC, DotProd, FP16, AES | Cortex-A55+, Apple M1+, Graviton 2+ |
arm64-v3 | Arm64V3Token | + SHA3, I8MM, BF16 | Cortex-A510+, Apple M2+, Graviton 3+ |
§wasm32
| Feature | Archmage Token | Notes |
|---|---|---|
wasm32-simd128 | Wasm128Token | No-op (multiversion elides on wasm32) |
§Attribute Arguments
The #[multiversed] attribute accepts:
- No arguments: Uses targets from enabled cargo features
- Preset names:
"x86-64-v3","arm64", etc. - Raw target strings: Any string containing
+is passed through as-is
Multiple arguments are comma-separated and all are included in the target list.
Attribute Macros§
- multiversed
- Apply multiversion with SIMD target presets.