Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
346 changes: 346 additions & 0 deletions .claude/board/AGENT_LOG.md

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,20 @@ serde = ["dep:serde"]
std = ["num-traits/std", "matrixmultiply/std"]
rayon = ["dep:rayon", "std"]

# Portable-SIMD backend (NIGHTLY ONLY). Routes `crate::simd::*` types
# through `core::simd::*` instead of the architecture-specific intrinsics
# in `simd_avx512.rs` / `simd_avx2.rs` / `simd_neon.rs`. The point is
# miri compatibility: miri can execute `core::simd` semantics but treats
# `_mm*_*` intrinsics as opaque. With this feature on, miri-run tests
# exercise the actual SIMD code paths in consumer code (`hpc/byte_scan`,
# `hpc/framebuffer`, etc.) and catch UB that the intrinsics backend hides.
#
# Requires `cargo +nightly` because `src/simd_nightly.rs` is gated on
# `#![feature(portable_simd)]` (Rust unstable issue #86656). The default
# build (stable 1.95) does NOT touch this; the existing intrinsics
# cfg-dispatch in `simd.rs` remains the production path.
nightly-simd = ["std"]

# HPC extras: blake3 hashing, p64 palette/NARS bridge, fractal manifold.
# These pull in a non-trivial dependency tree; downstream crates such as
# burn-ndarray that only need the core array layer can disable this with
Expand Down
14 changes: 14 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![crate_name = "ndarray"]
// Crate-level nightly feature gate for the optional `nightly-simd` backend
// (`src/simd_nightly/`). When the `nightly-simd` cargo feature is OFF
// (default), this attribute is absent and stable rustc compiles the crate
// normally. When ON, the crate requires nightly rustc to access
// `core::simd::*` types.
#![cfg_attr(feature = "nightly-simd", feature(portable_simd))]
#![doc(html_root_url = "https://docs.rs/ndarray/0.15/")]
#![doc(html_logo_url = "https://rust-ndarray.github.io/images/rust-ndarray_logo.svg")]
#![allow(
Expand Down Expand Up @@ -240,6 +246,14 @@ pub(crate) mod simd_avx512;
#[allow(clippy::all, missing_docs, dead_code, unused_variables, unused_imports)]
pub mod simd_avx2;

// Portable-SIMD backend — nightly-only. Wraps `core::simd::*` so miri can
// execute the polyfill paths (intrinsic-based backends are opaque to
// miri). Gated behind `nightly-simd` feature; the file itself requires
// `#![feature(portable_simd)]` so it only compiles on nightly rustc.
#[cfg(feature = "nightly-simd")]
#[allow(clippy::all, missing_docs)]
pub mod simd_nightly;

#[cfg(feature = "std")]
#[allow(clippy::all, missing_docs, dead_code, unused_variables, unused_imports)]
// AMX is an x86_64-only ISA (Intel Sapphire Rapids+); the module uses
Expand Down
9 changes: 9 additions & 0 deletions src/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ pub const PREFERRED_I16_LANES: usize = 16;
// at compile time → all types use native __m512/__m512d/__m512i.
// The 256-bit types (F32x8, F64x4) also live in simd_avx512 (__m256).

// Note on the `nightly-simd` feature: it adds the `crate::simd_nightly`
// module (a portable-simd backend wrapping `core::simd`) but does NOT
// replace the intrinsics dispatch below. Full type-parity coverage
// would require the nightly module to define ~30 types; the current
// draft covers 5 (F32x16, F64x8, U8x64, U32x16, F32Mask16). Consumers
// who want miri-runnable SIMD code import from `simd_nightly`
// explicitly (e.g. `use ndarray::simd_nightly::F32x16`). The main
// polyfill via `crate::simd::F32x16` continues to use intrinsics.

#[cfg(all(target_arch = "x86_64", target_feature = "avx512f"))]
pub use crate::simd_avx512::{
f32x16,
Expand Down
Loading
Loading