magetypes
Token-gated SIMD types with natural operators.
Overview
magetypes provides SIMD vector types (f32x8, i32x4, etc.) that require archmage tokens for safe construction. This ensures SIMD operations are only performed when CPU features have been verified at runtime.
Key features:
- Natural operators (
+,-,*,/,&,|,^) - Token-gated construction (safe by design)
- Zero-cost abstractions (compiles to raw SIMD instructions)
- Cross-platform (x86-64 with AVX2/AVX-512, AArch64 with NEON, WASM with SIMD128)
Quick Start
use ;
use f32x8;
Available Types
x86-64 (x86-64-v3 - 128-bit)
f32x4, f64x2, i8x16, i16x8, i32x4, i64x2, u8x16, u16x8, u32x4, u64x2
x86-64 (x86-64-v3 - 256-bit)
f32x8, f64x4, i8x32, i16x16, i32x8, i64x4, u8x32, u16x16, u32x8, u64x4
x86-64 (AVX-512 - 512-bit, requires avx512 feature)
f32x16, f64x8, i8x64, i16x32, i32x16, i64x8, u8x64, u16x32, u32x16, u64x8
AArch64 (NEON - 128-bit)
f32x4, f64x2, i8x16, i16x8, i32x4, i64x2, u8x16, u16x8, u32x4, u64x2
WASM (SIMD128 - 128-bit)
f32x4, f64x2, i8x16, i16x8, i32x4, i64x2, u8x16, u16x8, u32x4, u64x2
Build with RUSTFLAGS="-C target-feature=+simd128" for WASM targets.
// WASM example - no runtime detection needed
use ;
use f32x4;
// When compiled with +simd128, token is always available
let token = summon.unwrap;
let a = splat;
let b = splat;
let c = a + b;
Token-Gated Construction
All constructors require a token proving CPU support:
// Load from array
let v = load;
// Broadcast scalar
let v = splat;
// Zero vector
let v = zero;
// From array (zero-cost transmute)
let v = from_array;
// From bytes
let v = from_bytes;
Platform Support
| Platform | Status | Token | Vector Sizes |
|---|---|---|---|
| x86-64 | Full | X64V3Token, X64V4Token |
128, 256, 512-bit |
| AArch64 | Full | NeonToken |
128-bit |
| WASM | Full | Simd128Token |
128-bit |
Features
std(default): Enable std library supportavx512: Enable 512-bit types for AVX-512
Relationship to archmage
magetypes depends on archmage for:
- Token types (
X64V3Token,NeonToken, etc.) - The
#[arcane]macro for writing SIMD kernels - Runtime CPU feature detection
Use archmage directly when you need raw intrinsics. Use magetypes when you want ergonomic SIMD types with operators.
License
MIT OR Apache-2.0