magetypes Type Overview

magetypes provides SIMD vector types with natural Rust operators. Each type wraps platform intrinsics and requires an archmage token for construction.

Available Types

x86-64 Types

TypeElementsWidthMin Token
f32x44 × f32128-bitX64V2Token
f32x88 × f32256-bitX64V3Token
f32x1616 × f32512-bitX64V4Token*
f64x22 × f64128-bitX64V2Token
f64x44 × f64256-bitX64V3Token
f64x88 × f64512-bitX64V4Token*
i32x44 × i32128-bitX64V2Token
i32x88 × i32256-bitX64V3Token
i32x1616 × i32512-bitX64V4Token*
i8x1616 × i8128-bitX64V2Token
i8x3232 × i8256-bitX64V3Token
............

*Requires avx512 feature

AArch64 Types (NEON)

TypeElementsWidthToken
f32x44 × f32128-bitNeonToken
f64x22 × f64128-bitNeonToken
i32x44 × i32128-bitNeonToken
i16x88 × i16128-bitNeonToken
i8x1616 × i8128-bitNeonToken
u32x44 × u32128-bitNeonToken
............

WASM Types (SIMD128)

TypeElementsWidthToken
f32x44 × f32128-bitSimd128Token
f64x22 × f64128-bitSimd128Token
i32x44 × i32128-bitSimd128Token
............

Basic Usage

#![allow(unused)]
fn main() {
use archmage::{Desktop64, SimdToken};
use magetypes::simd::f32x8;

fn example() {
    if let Some(token) = Desktop64::summon() {
        // Construct from array
        let a = f32x8::from_array(token, [1.0; 8]);

        // Splat a single value
        let b = f32x8::splat(token, 2.0);

        // Natural operators
        let c = a + b;
        let d = c * c;

        // Extract result
        let result: [f32; 8] = d.to_array();
    }
}
}

Type Properties

All magetypes SIMD types are:

  • Copy — Pass by value freely
  • Clone — Explicit cloning works
  • Debug — Print for debugging
  • Send + Sync — Thread-safe
  • Token-gated construction — Cannot create without proving CPU support
#![allow(unused)]
fn main() {
// Zero-cost copies
let a = f32x8::splat(token, 1.0);
let b = a;  // Copy, not move
let c = a + b;  // Both still valid
}

Why no Pod/Zeroable? Implementing bytemuck traits would let users bypass token-gated construction (e.g., bytemuck::zeroed::<f32x8>()), creating vectors without proving CPU support. Use the token-gated cast_slice and from_bytes methods instead.

Using the Prelude

For convenience, import everything:

#![allow(unused)]
fn main() {
use magetypes::prelude::*;

// Now you have all types and archmage re-exports
if let Some(token) = Desktop64::summon() {
    let v = f32x8::splat(token, 1.0);
}
}

Platform-Specific Imports

If you need just one platform:

#![allow(unused)]
fn main() {
// x86-64 only
#[cfg(target_arch = "x86_64")]
use magetypes::simd::x86::*;

// AArch64 only
#[cfg(target_arch = "aarch64")]
use magetypes::simd::arm::*;

// WASM only
#[cfg(target_arch = "wasm32")]
use magetypes::simd::wasm::*;
}

Feature Flags

FeatureEffect
avx512Enable 512-bit types on x86-64
stdStandard library support (default)