gpu: add reductions, prefixes and quad reads to wave64 emulation #1425
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1432"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:Wave64ActiveMin,Wave64ActiveMax,Wave64ActiveBitAnd,Wave64ActiveBitOr,Wave64ActiveBitXorandWave64ActiveCountBits. Min and max compare values as unsigneduint.Wave64PrefixSumandWave64PrefixCountBits. Lane 0 gets 0, as withWavePrefixSum.Wave64QuadReadLaneAt,Wave64QuadReadAcrossX,Wave64QuadReadAcrossYandWave64QuadReadAcrossDiagonal. 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.Wave64ActiveSumnow 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,WaveActiveAllEqualandWaveMatchare still not provided.Verification
Commit
49776efon upstreameebc6c8. 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.Both runs reported
debug_errors=0 debug_warnings=0. Also randocs_links_checkandbidi_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
t % 3 == 0. The AND reduction reads each value with the bits of0x0f0000f0set, so its result is not trivially 0.docs/experiments.md(Wave64 emulation with group-shared memory) is updated with the operations, the limits and the new measurements.Checklist
This change was AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T11:49:15Z.
Review: COMMENTED
Reviewed at
49776ef6:git diff --checkclean.Wave64Foldkeeps bothGroupMemoryBarrierWithGroupSync()calls outside the per-lanecountloop (uniform barrier reachability preserved for exclusive prefixescount = lane). Quad reads ((lane & ~3u) | (quadLane & 3u),lane ^ 1/2/3) match SM 6.6 compute quad layout. CPU reference intests/wave64_emulate.cppchecks all 1,216 outputs (19 fields × 64 lanes) and requires theSKEWnegative control to fail on all 64 affine reads and all 64 inclusive prefix sums.docs_links_check.py(322 links) andbidi_controls_check.py(1185 files) passed.--preset dev,offscreen_check):wave64_emulate_warp1/1 PASS (0.06s)./O2(--preset release,offscreen_check):wave64_emulate_warp1/1 PASS (0.05s).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.
affine_wrong=0 prefix_wrong=0)affine_wrong=0 prefix_wrong=0)Two points I think are worth having in the log:
wave64_emulateis 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
skippedon the Arc, the same capability skip your RTX 3080 row shows for lane range 32..32 — reported separately, not as a failure, which matchesAGENTS.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.
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_checkRelease 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) driver31.0.21923.1000where used; in-box WARP10.0.26100.9818.Both registered tests passed. The Radeon ran the forced-width branch and printed
affine_wrong=0 prefix_wrong=0for it. The skew mismatches were expected.Codex (GPT-6) assisted with test execution and reporting.