Skip to content

Commit 9016621

Browse files
committed
docs(simd): fix two codex P2 findings on dispatch doc
- Drop the `target_arch = x86_64 | aarch64` constraint from the nightly-simd arm. `core::simd` is portable, so this arm must match on wasm32 / riscv too — otherwise enabling `nightly-simd` on those targets leaves no backend (every other arm excludes it). - Tighten the scalar fallback predicate to the exact negation of arms 1-4 so x86_64-without-AVX2 also routes to scalar. - Correct `BF16x8` parity row: `simd_nightly` already re-exports `BF16x8` (alongside `BF16x16`); the matrix was stale.
1 parent 2c1942b commit 9016621

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

.claude/knowledge/simd-dispatch-architecture.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@ that exactly one arm matches. The order below is the source-of-truth
5757
ranking the compiler walks:
5858

5959
```rust
60-
// 1. Explicit portable-SIMD polyfill (nightly + opt-in feature)
61-
#[cfg(all(feature = "nightly-simd", any(target_arch = "x86_64", target_arch = "aarch64")))]
60+
// 1. Explicit portable-SIMD polyfill (nightly + opt-in feature).
61+
// No `target_arch` constraint — `core::simd` is portable, so this
62+
// arm is the one true backend on wasm32 / riscv / any other target
63+
// as soon as `nightly-simd` is on. Keeping it unconditional on
64+
// `feature = "nightly-simd"` is what makes the `not(feature =
65+
// "nightly-simd")` exclusion on every other arm sound.
66+
#[cfg(feature = "nightly-simd")]
6267
pub use crate::simd_nightly::{F32x16, F64x8, U8x32, U8x64, U16x32, U32x16, U64x8, I8x32, I8x64, I16x16, I16x32, I32x16, I64x8, F32Mask16, F64Mask8, BF16x16, BF16x8};
6368

6469
// 2. AVX-512 (target_feature = "avx512f"; set by `v4` and `native` configs on AVX-512 hosts)
@@ -73,8 +78,14 @@ pub use crate::simd_avx2::{...};
7378
#[cfg(all(target_arch = "aarch64", not(feature = "nightly-simd")))]
7479
pub use crate::simd_neon::aarch64_simd::{...};
7580

76-
// 5. Scalar fallback (everything else: wasm32, riscv, x86_64 without AVX2, etc.)
77-
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64", feature = "nightly-simd")))]
81+
// 5. Scalar fallback (everything else: wasm32, riscv, x86_64 without
82+
// AVX2, etc.). The predicate is the negation of arms 1-4 so that
83+
// *exactly one* arm matches on every (target, feature) pair.
84+
#[cfg(not(any(
85+
feature = "nightly-simd",
86+
all(target_arch = "x86_64", target_feature = "avx2"),
87+
target_arch = "aarch64",
88+
)))]
7889
pub use scalar::{...};
7990
```
8091

@@ -137,7 +148,7 @@ scalar polyfill via `core::simd`, ❌ missing, ⛔ N/A for this arch.
137148
| `I16x32` |`__m512i` ||| 🔵 ||
138149
| `I32x16` |`__m512i` ||| 🔵 ||
139150
| `I64x8` |`__m512i` ||| 🔵 ||
140-
| `BF16x8` |`__m128bh` ||| ||
151+
| `BF16x8` |`__m128bh` ||| 🔵 ||
141152
| `BF16x16` |`__m256bh` ||| 🔵 ||
142153
| `F16x16` || 🟡 `F16Scaler` (scalar) || 🔵 ||
143154
| `F32Mask16` |`__mmask16` |`u16` bitmask |`u16` bitmask | 🔵 ||

0 commit comments

Comments
 (0)