Skip to content

Commit ef07808

Browse files
committed
refactor(simd_caps): graduate from hpc/ to crate root with back-compat re-export
First step in the substrate-graduation thread documented in #192's wrap-up: lift the substrate-tier modules out of `hpc/` (which was the rustynum migration staging area) to crate root, where they sit in scope of the W1a polyfill contract and no longer carry the spurious `std`-gate inherited from `hpc/`. `simd_caps` is the smallest and cleanest first move: * No internal `hpc/` dependencies (only `use std::sync::LazyLock`). * 8 internal callers; back-compat re-export keeps them working. * Pure CPU-detection metadata; the most polyfill-adjacent module in the entire `hpc/` set. Changes: 1. `src/hpc/simd_caps.rs` → `src/simd_caps.rs` (file move). 2. `src/lib.rs` adds `#[cfg(feature = "std")] pub mod simd_caps;`. The std-gate is retained for now (uses `std::sync::LazyLock`); lifting it to `core::sync::LazyLock` is a separate follow-up. 3. `src/hpc/mod.rs` replaces `pub mod simd_caps;` with `pub use crate::simd_caps;` — keeps `crate::hpc::simd_caps::*` resolving for cross-repo consumers (lance-graph, WoA, MedCare, q2 may have `use ndarray::hpc::simd_caps::*` imports that this preserves untouched). No public-API breakage; the test suite picks up the new path (test names now `simd_caps::tests::*` rather than `hpc::simd_caps::*`), all 10 tests pass under both default and `runtime-dispatch` configs. The 8 internal callers (`crate::simd_avx512`, `crate::hpc::p64_bridge`, `crate::simd_runtime::{cpu_ops, add_mul, vnni_dot}`) continue using `crate::hpc::simd_caps::*` via the re-export and work unmodified. Next graduation candidates (deferred to follow-up PRs): - `fingerprint` (bitwise substrate; raw `u64` polyfill audit) - `dn_tree` (bitwise substrate; same audit) - `ogit_bridge` (pure logic, no SIMD primitives) - `splat3d` (already uses `crate::simd::*` polyfilled types) Each move follows the same pattern: relocate file, drop std-gate inheritance where unneeded, keep back-compat re-export. Cognitive layer (pillar, plane, seal, merkle_tree, deepnsm, …) stays inside `hpc/` and keeps its legitimate std-gate.
1 parent 510d5f3 commit ef07808

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/hpc/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
//! - FFT (forward, inverse, real-to-complex)
1414
//! - VML (vectorized math library)
1515
16-
// SIMD capability singleton — detect once, all modules share
17-
pub mod simd_caps;
16+
// SIMD capability singleton — graduated to crate root (it never depended
17+
// on anything else in `hpc/`); re-exported here for back-compat with
18+
// existing `crate::hpc::simd_caps::*` imports across the workspace.
19+
pub use crate::simd_caps;
1820
// LazyLock frozen SIMD dispatch — function pointers selected once at startup
1921
pub mod simd_dispatch;
2022

src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,16 @@ pub mod simd_nightly;
262262
#[cfg(target_arch = "x86_64")]
263263
pub mod simd_amx;
264264

265+
/// SIMD capability detection (CPUID on x86_64, runtime feature detection
266+
/// on aarch64). One `LazyLock<SimdCaps>` detected at first access; every
267+
/// substrate dispatch site is one pointer deref. Graduated from
268+
/// `crate::hpc::simd_caps::*` in this same migration; the old path stays
269+
/// available as a `pub use` re-export inside `crate::hpc::*` for
270+
/// back-compat. Uses `std::sync::LazyLock`, hence the `std` gate (a
271+
/// `core::sync::LazyLock` follow-up could lift it).
272+
#[cfg(feature = "std")]
273+
pub mod simd_caps;
274+
265275
#[cfg(feature = "std")]
266276
#[allow(clippy::all, missing_docs, dead_code, unused_variables, unused_imports)]
267277
pub mod simd_neon;
File renamed without changes.

0 commit comments

Comments
 (0)