Skip to main content

truce_simd/
lib.rs

1//! Portable SIMD primitives + canonical block-rate audio ops.
2//!
3//! Two backends, feature-gated:
4//! - `wide-backend` (default): stable Rust, uses the `wide` crate.
5//!   Maps `f32x4`/`f32x8`/`f64x2`/`f64x4` onto SSE2 / AVX2 on x86,
6//!   NEON on `AArch64`, scalar fallback elsewhere.
7//! - (planned) `portable-simd-backend`: nightly-only, swaps in
8//!   `core::simd` when it stabilizes. Same public type aliases.
9//!
10//! Consumers never name the backend - they import
11//! `truce_simd::ops` (f32) / `truce_simd::ops64` (f64) and the
12//! correct intrinsics get wired in automatically.
13//!
14//! All ops here are pure math. No atomics, no parameter reads, no
15//! audio-thread allocation. They're meant to be the inner-loop
16//! complement to a `truce_params::FloatParam::read_block::<N>()` /
17//! `truce_core::AudioBuffer::chunks_mut::<N>()` driver in
18//! `process()`.
19
20#![allow(clippy::module_name_repetitions)]
21
22pub mod math;
23pub mod ops;
24pub mod ops64;
25
26/// Lane-width aliases. Stable across backends so consumers don't
27/// have to rewrite types when we flip the default to
28/// `portable-simd-backend`.
29#[cfg(feature = "wide-backend")]
30pub mod simd {
31    pub use wide::{f32x4, f32x8, f64x2, f64x4};
32}