Installation
Magetypes depends on archmage for capability tokens. Add both to your Cargo.toml:
[dependencies]
archmage = "0.8"
magetypes = "0.8"
Magetypes re-exports what it needs from archmage, but you'll want archmage directly for SimdToken, token types, and macros like #[arcane].
Feature Flags
magetypes
| Feature | Default | Description |
|---|---|---|
std | yes | Standard library support |
avx512 | no | 512-bit types (f32x16, i32x16, etc.) |
archmage
| Feature | Default | Description |
|---|---|---|
std | yes | Standard library support |
macros | yes | #[arcane], #[rite], incant! |
avx512 | no | AVX-512 token support |
Enable AVX-512 types in both crates:
[dependencies]
archmage = { version = "0.8", features = ["avx512"] }
magetypes = { version = "0.8", features = ["avx512"] }no_std
Both crates support no_std with alloc:
[dependencies]
archmage = { version = "0.8", default-features = false, features = ["macros"] }
magetypes = { version = "0.8", default-features = false }Platform Requirements
x86-64
Works out of the box. Tokens detect CPU features at runtime via CPUID.
To compile for a known target CPU (detection compiles away):
RUSTFLAGS="-Ctarget-cpu=native" cargo build --releaseAArch64
NEON is baseline on 64-bit ARM. NeonToken::summon() succeeds on all AArch64 hardware.
WASM
Enable SIMD128 in your build:
RUSTFLAGS="-Ctarget-feature=+simd128" cargo build --target wasm32-unknown-unknownVerify It Works
use archmage::{X64V3Token, SimdToken};
use magetypes::simd::{
generic::f32x8,
backends::F32x8Backend,
};
#[inline(always)]
fn print_splat<T: F32x8Backend>(token: T, val: f32) {
let v = f32x8::<T>::splat(token, val);
println!("f32x8: {:?}", v.to_array());
}
fn main() {
match X64V3Token::summon() {
Some(token) => print_splat(token, 42.0),
None => println!("AVX2+FMA not available on this CPU"),
}
}cargo run
Found an error or it needs a clarification?
Open an issue on GitHub.
Substantiated corrections will be incorporated with attribution.
Found a typo?
Fork, modify and open a PR.