Skip to content

Commit 9a5cb6a

Browse files
committed
docs(array_windows): clarify non-overlapping semantics vs std::slice::ArrayWindows
1 parent 2a2dfbf commit 9a5cb6a

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

src/hpc/array_windows.rs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,35 @@
66
//! (fine but undiscoverable) or rolls a raw slice index without the
77
//! compile-time bounds check.
88
//!
9+
//! # Semantics — non-overlapping (NOT std `array_windows`)
10+
//!
11+
//! Despite the plural name, this is the **non-overlapping** chunk variant —
12+
//! consecutive windows do not share elements. The name follows std's
13+
//! plural iterator-type convention ([`std::slice::ArrayWindows`]), but the
14+
//! semantics match [`std::slice::ArrayChunks`] / `slice::as_chunks`.
15+
//!
16+
//! For an 8-element input walked at `N = 4`:
17+
//! - `array_windows` (this module): yields `[0..4]`, `[4..8]` — **2 windows**.
18+
//! - `std::slice::array_windows` (overlapping): would yield 5 windows.
19+
//!
20+
//! Non-overlapping is the correct shape for SIMD-staged inner loops where
21+
//! each lane-register load consumes its N elements before advancing by N.
22+
//!
923
//! # Layering
1024
//!
11-
//! Lives in `hpc::array_windows`; the `crate::simd::*` re-export lands in the
12-
//! PR-X1 re-export sweep (see `.claude/knowledge/pr-x1-design.md` § 4).
13-
//! Doctests therefore use the canonical `ndarray::hpc::array_windows` path
14-
//! until the sweep ships.
25+
//! Lives in `hpc::array_windows`, re-exported from `crate::simd::*` per the
26+
//! W1a consumer contract at
27+
//! `.claude/knowledge/vertical-simd-consumer-contract.md`.
1528
//!
1629
//! # Design reference
1730
//!
18-
//! `.claude/knowledge/pr-x1-design.md` § "3. `array_windows`". This module
31+
//! `.claude/knowledge/pr-x1-design.md` § "3. `array_window`". This module
1932
//! ships the **iterator-shape** variant (whole-buffer walk yielding all
20-
//! const-size windows). The design doc sketches a singular-window form
21-
//! (`array_windows(slice, offset) -> &[T; N]`); the maintainer-blessed final
22-
//! shape is the iterator form here, which composes directly with SIMD-staged
23-
//! consumer loops and avoids per-call panic surface in tight inner loops.
33+
//! const-size windows); the design doc's singular-window sketch
34+
//! (`array_window(slice, offset) -> &[T; N]`) was superseded by the
35+
//! iterator form here, which composes directly with SIMD-staged consumer
36+
//! loops and avoids per-call panic surface in tight inner loops. The name
37+
//! was pluralised to match the std iterator-type convention.
2438
2539
/// Walk `data` as a sequence of non-overlapping const-size windows.
2640
///

0 commit comments

Comments
 (0)