Skip to content

Commit ca2fc14

Browse files
committed
refactor(substrate): graduate 5 modules from hpc/ to crate root
Continues the substrate-graduation thread documented in #192's wrap-up and extended in #193's simd_caps lift. Five more modules move from `crate::hpc::*` (the rustynum migration staging area) to crate root where they sit alongside `simd.rs`, `simd_runtime/`, `simd_caps`, and the W1a polyfill surface they're supposed to compose with. | Module | Reason | |---|---| | `bitwise` | Pure SIMD primitives (popcount, hamming over byte slices); already uses `crate::simd::U64x8` polyfill internally; already re-exported via `simd.rs:512`. | | `heel_f64x8` | All-F64x8 polyfill consumer (dot, cosine, sum-sq, weighted-hamming); already re-exported via `simd.rs:563`. | | `distance` | Spatial 3D + slice-shape L1/L2/L∞ (PR-X10 A6); the linalg/mod.rs hard-boundary comment now points here at root. | | `byte_scan` | Pure SIMD utility (needle search, delimiter find). | | `spatial_hash` | Pure SIMD utility (bucketing, candidate gather). | # Why these five, why now All five satisfied the low-hanging-fruit criteria from #193's wrap-up discussion: 1. No internal `hpc/` dependencies (only `super::simd_caps` which still resolves correctly because `simd_caps` is itself at crate root post-#192). 2. Already polyfill-clean — no raw-intrinsic refactor needed before the move. 3. Already partially exposed via `crate::simd::*` re-exports. The next graduation tier (`fingerprint`, `dn_tree`, `ogit_bridge`, `splat3d`) needs a polyfill audit before it can move, and `fingerprint` in particular is gated on the W1a-#5 POPCOUNT-U64 primitive landing (so its bit ops can route through `U64xN.popcnt()` instead of raw `u64.count_ones()`). # Back-compat preserved end-to-end Every cross-repo consumer using `ndarray::hpc::{bitwise, heel_f64x8, distance, byte_scan, spatial_hash}::*` continues to compile unmodified. The `src/hpc/mod.rs` declarations change from `pub mod X;` to `pub use crate::X;` — Rust re-exports modules just like other items, so `crate::hpc::X::*` resolves through to the same items as `crate::X::*`. Internal `super::simd_caps::simd_caps()` calls inside the moved files continue to work because `super::` at crate root resolves to `crate::*` which has `simd_caps` (graduated in #192). # Changes - `git mv` five files from `src/hpc/` to `src/`. - `src/lib.rs` gains five `#[cfg(feature = "std")] pub mod X;` declarations next to the existing `simd_caps` block, each with a one-liner docstring naming the graduation source and the substrate-tier reason for the move. - `src/hpc/mod.rs` replaces five `pub mod X;` with `pub use crate::X;` (back-compat re-exports). - `src/hpc/linalg/mod.rs` updates the hard-boundary comment from "No distance metrics — those live in `crate::hpc::distance`" to point at `crate::distance` (the new canonical path) with a parenthetical noting the back-compat re-export. - The `bitwise.rs` declaration in `src/hpc/mod.rs` is now a comment instead of being interleaved with `pub mod hdc`/`pub mod projection` to make the graduation status visible at a glance. # Verification - `cargo build -p ndarray --lib` — clean - `cargo build -p ndarray --lib --no-default-features` — clean (the new `#[cfg(feature = "std")]` gates match the existing `simd_caps` pattern; nostd targets see no change) - `cargo test -p ndarray --lib bitwise:: distance:: heel_f64x8:: byte_scan:: spatial_hash::` — all 119 tests on the five graduated modules pass at the new path (test names now `bitwise::tests::*` rather than `hpc::bitwise::tests::*`) - `cargo test -p ndarray --lib --features "pillar,ogit_bridge, runtime-dispatch" hpc::` — 2167 passed, 0 failed, 28 ignored - `cargo fmt --all --check` — clean - `cargo clippy --features "pillar,ogit_bridge,runtime-dispatch" --lib -- -D warnings` — clean # Next graduation candidates (deferred) - `hpc::fingerprint` — needs W1a-#5 POPCOUNT-U64 to land first so bit ops can route through `U64xN.popcnt()` instead of raw `u64.count_ones()`. Cognitive-shader-foundation explicitly names `Fingerprint<N>` as a MUST-be-in-`ndarray::simd::*` type. - `hpc::dn_tree` (bitwise core) — same polyfill-audit dependency. The cognitive DNTree/DNConfig/TraversalHit state stays in `hpc/` after the split. - `hpc::ogit_bridge` — pure logic, no SIMD, can move once the fingerprint + dn_tree audits are out of the way (avoids three partial graduations in flight at once). - `hpc::splat3d` — already mostly polyfill-clean; pure path rewrite. Defer because it's a larger consumer surface than the five in this PR.
1 parent a0f8fb3 commit ca2fc14

8 files changed

Lines changed: 40 additions & 8 deletions

File tree

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/hpc/linalg/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
//!
4141
//! - **No SIMD primitives** — use `crate::simd::{F32x16, …}` directly.
4242
//! - **No `#[target_feature]` annotations** — those live in `simd_avx512.rs`.
43-
//! - **No distance metrics** — those live in `crate::hpc::distance`.
43+
//! - **No distance metrics** — those live in `crate::distance` (graduated
44+
//! from `crate::hpc::distance`; back-compat re-export in `crate::hpc::*`).
4445
4546
mod matrix;
4647
pub use matrix::{Mat2, Mat3, Mat4, MatN, Spd2, Spd3};

src/hpc/mod.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ pub mod reductions;
2727
pub mod statistics;
2828
pub mod activations;
2929
pub mod hdc;
30-
pub mod bitwise;
30+
// Bitwise SIMD primitives — graduated to crate root. Back-compat re-export.
31+
pub use crate::bitwise;
3132
pub mod projection;
3233
pub mod cogrecord;
3334
pub mod graph;
@@ -56,8 +57,8 @@ pub mod soa;
5657
pub mod node;
5758
#[allow(missing_docs)]
5859
pub mod cascade;
59-
#[allow(missing_docs)]
60-
pub mod heel_f64x8;
60+
// HEEL F64x8 distance kernels — graduated to crate root. Back-compat re-export.
61+
pub use crate::heel_f64x8;
6162
// AMX is an x86_64-only ISA (Intel Sapphire Rapids+); both modules use
6263
// `asm!` with `rcx`/`rax` register names that don't exist on other
6364
// architectures (rejected at parse time on s390x / aarch64 / wasm32).
@@ -169,10 +170,11 @@ pub mod parallel_search;
169170
// ZeckF64 progressive edge encoding + batch/top-k
170171
pub mod zeck;
171172

172-
// SIMD-accelerated spatial / byte-scan / hash utilities
173-
pub mod distance;
174-
pub mod byte_scan;
175-
pub mod spatial_hash;
173+
// SIMD-accelerated spatial / byte-scan / hash utilities — graduated to crate root.
174+
// Back-compat re-exports for existing `use ndarray::hpc::{distance,byte_scan,spatial_hash}::*`.
175+
pub use crate::byte_scan;
176+
pub use crate::distance;
177+
pub use crate::spatial_hash;
176178

177179
// Variable-width palette index codec (Minecraft-style bit packing)
178180
#[allow(missing_docs)]

src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,35 @@ pub mod simd_amx;
272272
#[cfg(feature = "std")]
273273
pub mod simd_caps;
274274

275+
/// Bitwise SIMD primitives — popcount, Hamming distance over byte slices.
276+
/// Graduated from `crate::hpc::bitwise::*` (substrate-tier; uses
277+
/// `crate::simd::U64x8` polyfill internally). Back-compat re-export in
278+
/// `crate::hpc::*` preserves existing import paths.
279+
#[cfg(feature = "std")]
280+
pub mod bitwise;
281+
282+
/// F64x8 HEEL distance kernels — 8-plane weighted Hamming, f64 SIMD
283+
/// dot / cosine / sum-of-squares. Graduated from `crate::hpc::heel_f64x8::*`.
284+
#[cfg(feature = "std")]
285+
pub mod heel_f64x8;
286+
287+
/// Batch distance computations — spatial 3D-point queries +
288+
/// slice-shape L1 / L2 / L∞ (PR-X10 A6). Graduated from
289+
/// `crate::hpc::distance::*`.
290+
#[cfg(feature = "std")]
291+
pub mod distance;
292+
293+
/// SIMD-accelerated byte-scan utilities — needle search, delimiter
294+
/// finding, parallel byte comparison. Graduated from
295+
/// `crate::hpc::byte_scan::*`.
296+
#[cfg(feature = "std")]
297+
pub mod byte_scan;
298+
299+
/// SIMD-accelerated spatial hash — bucketing, candidate gather, hash
300+
/// collision detection. Graduated from `crate::hpc::spatial_hash::*`.
301+
#[cfg(feature = "std")]
302+
pub mod spatial_hash;
303+
275304
#[cfg(feature = "std")]
276305
#[allow(clippy::all, missing_docs, dead_code, unused_variables, unused_imports)]
277306
pub mod simd_neon;

0 commit comments

Comments
 (0)