gpu: add reductions, prefixes and quad reads to wave64 emulation #1425

Merged
archielcqp-a11y merged 1 commit from upstream-pr/1432 into main 2026-11-24 13:57:02 +00:00
archielcqp-a11y commented 2026-11-24 11:24:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by archielcqp-a11y on 2026-11-24T11:24:46Z.


Change

Extends src/wave64_emulate.hlsli, the group-shared-memory emulation of 64-lane wave operations, with the operations its docs listed as missing:

  • Reductions: Wave64ActiveMin, Wave64ActiveMax, Wave64ActiveBitAnd, Wave64ActiveBitOr, Wave64ActiveBitXor and Wave64ActiveCountBits. Min and max compare values as unsigned uint.
  • Exclusive prefixes: Wave64PrefixSum and Wave64PrefixCountBits. Lane 0 gets 0, as with WavePrefixSum.
  • Quad reads: Wave64QuadReadLaneAt, Wave64QuadReadAcrossX, Wave64QuadReadAcrossY and Wave64QuadReadAcrossDiagonal. Quad q is lanes 4q..4q+3, the compute quad layout of SM 6.6.

The reductions and prefixes share Wave64Fold, which folds lanes 0..count-1. A prefix passes its own lane as the count, so the loop bound differs per lane, but both group barriers stay outside the loop. Wave64ActiveSum now uses the same helper.

The requirements are unchanged: exactly 64 threads in the group, and every call reached in uniform control flow. Signed and floating-point reductions, WavePrefixProduct, WaveActiveAllEqual and WaveMatch are still not provided.

Verification

Commit 49776ef on upstream eebc6c8. Windows 10 build 19045.6466, debug layer enabled.

ctest --test-dir out/build/w10 --no-tests=error -R '^wave64_emulate_' -V: 2/2 passed. The test now checks 1,216 values per run against the CPU reference, up from 448.

Adapter Native width Forced width 64 Negative control
WARP 1.0.22 (Agility SDK 1.620.2), lane range 4..128 0 of 1,216 wrong 0 of 1,216 wrong 128 of 128 reported, none elsewhere
NVIDIA GeForce RTX 3080 (32.0.15.9174) 0 of 1,216 wrong Skipped, lane range 32..32 (capability, not a failure) 128 of 128 reported, none elsewhere

Both runs reported debug_errors=0 debug_warnings=0. Also ran docs_links_check and bidi_controls_check; both pass.

Not run: the in-box WARP 10.0.19041 run from the first version (lane range 4..4) was not repeated for this version.

Fixtures and negative control

  • Test inputs: the predicate is t % 3 == 0. The AND reduction reads each value with the bits of 0x0f0000f0 set, so its result is not trivially 0.
  • Negative control: the skewed build now also makes the prefix sum inclusive, in addition to its off-by-one affine read. The test requires exactly the 64 affine reads and the 64 prefix sums to be reported, and nothing else.

docs/experiments.md (Wave64 emulation with group-shared memory) is updated with the operations, the limits and the new measurements.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

This change was AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6580689392 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1432). Originally posted by [archielcqp-a11y](https://github.com/archielcqp-a11y) on 2026-11-24T11:24:46Z. --- ## Change Extends `src/wave64_emulate.hlsli`, the group-shared-memory emulation of 64-lane wave operations, with the operations its docs listed as missing: - **Reductions:** `Wave64ActiveMin`, `Wave64ActiveMax`, `Wave64ActiveBitAnd`, `Wave64ActiveBitOr`, `Wave64ActiveBitXor` and `Wave64ActiveCountBits`. Min and max compare values as unsigned `uint`. - **Exclusive prefixes:** `Wave64PrefixSum` and `Wave64PrefixCountBits`. Lane 0 gets 0, as with `WavePrefixSum`. - **Quad reads:** `Wave64QuadReadLaneAt`, `Wave64QuadReadAcrossX`, `Wave64QuadReadAcrossY` and `Wave64QuadReadAcrossDiagonal`. Quad q is lanes 4q..4q+3, the compute quad layout of SM 6.6. The reductions and prefixes share `Wave64Fold`, which folds lanes 0..count-1. A prefix passes its own lane as the count, so the loop bound differs per lane, but both group barriers stay outside the loop. `Wave64ActiveSum` now uses the same helper. The requirements are unchanged: exactly 64 threads in the group, and every call reached in uniform control flow. Signed and floating-point reductions, `WavePrefixProduct`, `WaveActiveAllEqual` and `WaveMatch` are still not provided. ## Verification Commit `49776ef` on upstream `eebc6c8`. Windows 10 build 19045.6466, debug layer enabled. `ctest --test-dir out/build/w10 --no-tests=error -R '^wave64_emulate_' -V`: 2/2 passed. The test now checks 1,216 values per run against the CPU reference, up from 448. | Adapter | Native width | Forced width 64 | Negative control | |---|---|---|---| | WARP 1.0.22 (Agility SDK 1.620.2), lane range 4..128 | 0 of 1,216 wrong | 0 of 1,216 wrong | 128 of 128 reported, none elsewhere | | NVIDIA GeForce RTX 3080 (32.0.15.9174) | 0 of 1,216 wrong | Skipped, lane range 32..32 (capability, not a failure) | 128 of 128 reported, none elsewhere | Both runs reported `debug_errors=0 debug_warnings=0`. Also ran `docs_links_check` and `bidi_controls_check`; both pass. **Not run:** the in-box WARP 10.0.19041 run from the first version (lane range 4..4) was not repeated for this version. ## Fixtures and negative control - **Test inputs:** the predicate is `t % 3 == 0`. The AND reduction reads each value with the bits of `0x0f0000f0` set, so its result is not trivially 0. - **Negative control:** the skewed build now also makes the prefix sum inclusive, in addition to its off-by-one affine read. The test requires exactly the 64 affine reads and the 64 prefix sums to be reported, and nothing else. `docs/experiments.md` (Wave64 emulation with group-shared memory) is updated with the operations, the limits and the new measurements. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. This change was AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tedin7 commented 2026-11-24 12:02:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T11:49:15Z.

Review: COMMENTED


Reviewed at 49776ef6:

  • Diff & static audit: git diff --check clean. Wave64Fold keeps both GroupMemoryBarrierWithGroupSync() calls outside the per-lane count loop (uniform barrier reachability preserved for exclusive prefixes count = lane). Quad reads ((lane & ~3u) | (quadLane & 3u), lane ^ 1/2/3) match SM 6.6 compute quad layout. CPU reference in tests/wave64_emulate.cpp checks all 1,216 outputs (19 fields × 64 lanes) and requires the SKEW negative control to fail on all 64 affine reads and all 64 inclusive prefix sums.
  • Linux checks: docs_links_check.py (322 links) and bidi_controls_check.py (1185 files) passed.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev, offscreen_check): wave64_emulate_warp 1/1 PASS (0.06s).
    • Release /O2 (--preset release, offscreen_check): wave64_emulate_warp 1/1 PASS (0.05s).
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6038650048 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1432#pullrequestreview-6038650048). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T11:49:15Z. **Review:** COMMENTED --- Reviewed at `49776ef6`: - **Diff & static audit**: `git diff --check` clean. `Wave64Fold` keeps both `GroupMemoryBarrierWithGroupSync()` calls outside the per-lane `count` loop (uniform barrier reachability preserved for exclusive prefixes `count = lane`). Quad reads (`(lane & ~3u) | (quadLane & 3u)`, `lane ^ 1/2/3`) match SM 6.6 compute quad layout. CPU reference in `tests/wave64_emulate.cpp` checks all 1,216 outputs (19 fields × 64 lanes) and requires the `SKEW` negative control to fail on all 64 affine reads and all 64 inclusive prefix sums. - **Linux checks**: `docs_links_check.py` (322 links) and `bidi_controls_check.py` (1185 files) passed. - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - Debug (`--preset dev`, `offscreen_check`): `wave64_emulate_warp` **1/1 PASS** (`0.06s`). - Release `/O2` (`--preset release`, `offscreen_check`): `wave64_emulate_warp` **1/1 PASS** (`0.05s`).
ChazY11 commented 2026-11-24 13:00:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T12:06:20Z.


The two configurations you did not run both pass, including a 32-lane Intel adapter

Independent reviewer, not the author. Reviewed 49776ef; nothing pushed to the branch.

Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, DXC 1.8.2502.11, debug layer enabled.

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^wave64_emulate_' -V
Backend Native lane range Native Skew control Forced width 64 Debug
in-box WARP 10.0.26100.9818 4..4 0 of 1,216 wrong (affine_wrong=0 prefix_wrong=0) 128 of 1,216, split 64 affine + 64 prefix Skipped 0 errors, 0 warnings
Intel Arc 140T, driver 32.0.101.8132 8..32 0 of 1,216 wrong (affine_wrong=0 prefix_wrong=0) 128 of 1,216, split 64 affine + 64 prefix Skipped 0 errors, 0 warnings

Two points I think are worth having in the log:

  1. In-box WARP, which your table lists as not repeated for this version, passes at lane range 4..4 — the narrowest range in the project — with the same 1,216 values and the same control split. So the extension does not depend on the app-local WARP either.
  2. A 32-lane Intel adapter also reports 0 of 1,216. wave64_emulate is the one place where the group is guaranteed to be 64 threads while the hardware wave is 32, so a passing Intel run is the strongest form of the "width-independent" claim your body makes: the fold and the prefixes never read a hardware lane above 31 on this adapter.

The skew control reporting exactly 64 affine plus 64 prefix reads, and nothing else, is the property I would rely on to detect a later change to Wave64Fold. It held on both of my runs.

Forced width 64 reports skipped on the Arc, the same capability skip your RTX 3080 row shows for lane range 32..32 — reported separately, not as a failure, which matches AGENTS.md.

Verdict

Reviewed 49776ef. Builds clean, both of my runs pass, the control split matches your description, and the requirements (64 threads, uniform control flow) are unchanged. No objection from me.

If you want the docs table extended, I can send the two rows as a separate docs-only change rather than touching your branch — say the word.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7130972016 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1432#issuecomment-7130972016). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T12:06:20Z. --- ## The two configurations you did not run both pass, including a 32-lane Intel adapter Independent reviewer, not the author. Reviewed `49776ef`; nothing pushed to the branch. Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, DXC 1.8.2502.11, debug layer enabled. ```powershell cmake --preset dev cmake --build --preset dev ctest --preset dev --no-tests=error -R '^wave64_emulate_' -V ``` | Backend | Native lane range | Native | Skew control | Forced width 64 | Debug | |---|---|---|---|---|---| | in-box WARP 10.0.26100.9818 | 4..4 | 0 of 1,216 wrong (`affine_wrong=0 prefix_wrong=0`) | 128 of 1,216, split 64 affine + 64 prefix | Skipped | 0 errors, 0 warnings | | Intel Arc 140T, driver 32.0.101.8132 | 8..32 | 0 of 1,216 wrong (`affine_wrong=0 prefix_wrong=0`) | 128 of 1,216, split 64 affine + 64 prefix | Skipped | 0 errors, 0 warnings | Two points I think are worth having in the log: 1. **In-box WARP**, which your table lists as not repeated for this version, passes at lane range 4..4 — the narrowest range in the project — with the same 1,216 values and the same control split. So the extension does not depend on the app-local WARP either. 2. **A 32-lane Intel adapter** also reports 0 of 1,216. `wave64_emulate` is the one place where the group is guaranteed to be 64 threads while the hardware wave is 32, so a passing Intel run is the strongest form of the "width-independent" claim your body makes: the fold and the prefixes never read a hardware lane above 31 on this adapter. The skew control reporting exactly 64 affine plus 64 prefix reads, and nothing else, is the property I would rely on to detect a later change to `Wave64Fold`. It held on both of my runs. Forced width 64 reports `skipped` on the Arc, the same capability skip your RTX 3080 row shows for lane range 32..32 — reported separately, not as a failure, which matches `AGENTS.md`. ### Verdict Reviewed `49776ef`. Builds clean, both of my runs pass, the control split matches your description, and the requirements (64 threads, uniform control flow) are unchanged. No objection from me. If you want the docs table extended, I can send the two rows as a separate docs-only change rather than touching your branch — say the word.
upstream-sync closed this pull request 2026-11-24 14:02:44 +00:00
linusbrunotte-arch commented 2026-11-24 14:03:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by linusbrunotte-arch on 2026-11-24T13:13:10Z.


Independent physical forced-Wave64 pass on Polaris

Source: 49776ef626a69328530b793d8c0320f58a90c593, the PR head.

Windows 11 x64 build 26300.9974, offscreen_check Release built with Clang 23.1.6 in MSVC mode, Windows SDK 10.0.26100, DXC 1.9.2609.5. D3D12 debug layer unavailable. Radeon RX 590 Series (1002:67df) driver 31.0.21923.1000 where used; in-box WARP 10.0.26100.9818.

Backend Lane range Native Forced 64 Skew control
Radeon RX 590 64..64 0/1,216 wrong 0/1,216 wrong 128/1,216 wrong (64 affine, 64 prefix)
WARP 4..4 0/1,216 wrong Capability skip 128/1,216 wrong (64 affine, 64 prefix)

Both registered tests passed. The Radeon ran the forced-width branch and printed affine_wrong=0 prefix_wrong=0 for it. The skew mismatches were expected.

$env:XBOX2WINDOWS_ADAPTER = 'RX 590'
ctest --test-dir <build> --no-tests=error -V -R '^wave64_emulate_(hardware|warp)$'

Codex (GPT-6) assisted with test execution and reporting.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7132516669 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1432#issuecomment-7132516669). Originally posted by [linusbrunotte-arch](https://github.com/linusbrunotte-arch) on 2026-11-24T13:13:10Z. --- ### Independent physical forced-Wave64 pass on Polaris Source: `49776ef626a69328530b793d8c0320f58a90c593`, the PR head. Windows 11 x64 build 26300.9974, `offscreen_check` Release built with Clang 23.1.6 in MSVC mode, Windows SDK 10.0.26100, DXC 1.9.2609.5. D3D12 debug layer unavailable. Radeon RX 590 Series (`1002:67df`) driver `31.0.21923.1000` where used; in-box WARP `10.0.26100.9818`. | Backend | Lane range | Native | Forced 64 | Skew control | |---|---|---|---|---| | Radeon RX 590 | 64..64 | 0/1,216 wrong | 0/1,216 wrong | 128/1,216 wrong (64 affine, 64 prefix) | | WARP | 4..4 | 0/1,216 wrong | Capability skip | 128/1,216 wrong (64 affine, 64 prefix) | Both registered tests passed. The Radeon ran the forced-width branch and printed `affine_wrong=0 prefix_wrong=0` for it. The skew mismatches were expected. ```powershell $env:XBOX2WINDOWS_ADAPTER = 'RX 590' ctest --test-dir <build> --no-tests=error -V -R '^wave64_emulate_(hardware|warp)$' ``` Codex (GPT-6) assisted with test execution and reporting.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1425
No description provided.