compute: order wave32 LDS accesses within the host wave with a ballot #3356

Closed
Not-Saii wants to merge 4 commits from upstream-pr/3356 into main
Not-Saii commented 2026-11-28 13:33:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-28T13:33:55Z.


Depends on #3352, which must land first. This branch sits on its head 2c8a38be, rebased onto main eeb52277; until #3352 merges
the diff here also shows its changes. The note also sits next to the lines #3354 edits in the same file; the
sections were kept apart, but a rebase may be needed after both.

On the wave32 model (a guest wave32, or a narrow guest wave64 of at most 32 threads) one host wave is one guest
wave and nothing stands before an LDS access: no group barrier, no wave operation. A lane may read a word that
another lane of the wave wrote one instruction earlier. App-local WARP 1.0.22 returned that word unwritten.
#3352 gave lane-pair modules a ballot for the same reason; this widens its condition from lane_pairs to
!wave64 || lane_pairs, i.e. every LDS access without a group barrier in front takes its lane predicate from a
WaveActiveBallot.

  • src/gfx1013_direct_compute.inl: the condition and its comment in local_memory().
  • tests/native_wave32_lds_order_check.py, tests/cmake/native_wave32_lds_order.cmake: new fixture, modes
    controls, hardware, warp.
  • docs/experiments/native-wave64-lane-pairs.md: the wave32 paragraph, fixture, result and limits.

Every wave32 module that uses LDS changes bytes: one more wave operation per LDS access. Timing not measured.
Split-halves and lane-pair modules are unchanged by construction (both have wave64 true; lane pairs already had
the ballot), not by a byte comparison. No existing test pins a wave32 LDS module or counts its ballots; the mesh
fixtures with ds_ instructions go through the Python mesh_entry_aot lowering, not this path.

Test

Commit 8042961a (source and fixture as tested; only the note changed afterwards), Debug build, Windows 11 build 26300, NVIDIA GeForce RTX 4090
(vendor=10de device=2684, driver 32.0.16.1088), DXC from Windows SDK 10.0.26100, debug layer off. App-local WARP
d3d10warp.dll 1.0.22 copied beside native_store_replay.exe for the WARP runs, in-box D3D12 runtime.
"Before" = same tree without the widened condition. Each replay mode run 12 times by hand.

Run Before After
controls failed: wave32 events ballot, lds, lds (negative control) passed, both requests
warp (WARP 1.0.22) differed 12/12: word 8, expected 0x00001f05, got 0x00000000 (9 runs), 0x0000020d, 0x00000275, 0x000001da matched 12/12, both requests
hardware (RTX 4090) matched 12/12, both requests matched 12/12, both requests

Own-word negative control reported a mismatch in every replay run (word 8, got 0x00001f05, expected 0x00000005).

ctest --preset dev --no-tests=error -R '^(native_direct_container|native_scalar_lds_hardware|native_wave64_lane_pairs_(controls|hardware)|native_wave32_lds_order_(controls|hardware|warp))$'

6 passed, native_wave32_lds_order_warp skipped (77, in-box WARP).

After the rebase (head 1d03b1fe, Debug, same machine), the same ctest command: 6 passed,
native_wave32_lds_order_warp skipped (77, in-box WARP). With app-local WARP 1.0.22 beside the replay executable,
ctest --preset dev --no-tests=error -R '^native_wave32_lds_order_warp$' --repeat until-fail:12 -V passed 12 of 12;
both requests matched and the own-word negative control reported a mismatch. The before/after table above was taken
on 8042961a before the rebase. main's virtual waves are wave64 and keep their group barrier before LDS accesses,
so this change does not touch them.

Not run: the full ^native_ set; any second GPU; a partial-wave LDS program (its WARP behaviour is inferred from #3160); the narrow wave64 request failing
before the change (the fixture stops at the wave32 request first).

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5540644984 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3356). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-28T13:33:55Z. --- **Depends on #3352, which must land first.** This branch sits on its head `2c8a38be`, rebased onto `main` `eeb52277`; until #3352 merges the diff here also shows its changes. The note also sits next to the lines #3354 edits in the same file; the sections were kept apart, but a rebase may be needed after both. On the wave32 model (a guest wave32, or a narrow guest wave64 of at most 32 threads) one host wave is one guest wave and nothing stands before an LDS access: no group barrier, no wave operation. A lane may read a word that another lane of the wave wrote one instruction earlier. App-local WARP 1.0.22 returned that word unwritten. #3352 gave lane-pair modules a ballot for the same reason; this widens its condition from `lane_pairs` to `!wave64 || lane_pairs`, i.e. every LDS access without a group barrier in front takes its lane predicate from a `WaveActiveBallot`. - `src/gfx1013_direct_compute.inl`: the condition and its comment in `local_memory()`. - `tests/native_wave32_lds_order_check.py`, `tests/cmake/native_wave32_lds_order.cmake`: new fixture, modes `controls`, `hardware`, `warp`. - `docs/experiments/native-wave64-lane-pairs.md`: the wave32 paragraph, fixture, result and limits. Every wave32 module that uses LDS changes bytes: one more wave operation per LDS access. Timing not measured. Split-halves and lane-pair modules are unchanged by construction (both have `wave64` true; lane pairs already had the ballot), not by a byte comparison. No existing test pins a wave32 LDS module or counts its ballots; the mesh fixtures with `ds_` instructions go through the Python `mesh_entry_aot` lowering, not this path. ## Test Commit `8042961a` (source and fixture as tested; only the note changed afterwards), Debug build, Windows 11 build 26300, NVIDIA GeForce RTX 4090 (`vendor=10de device=2684`, driver 32.0.16.1088), DXC from Windows SDK 10.0.26100, debug layer off. App-local WARP `d3d10warp.dll` 1.0.22 copied beside `native_store_replay.exe` for the WARP runs, in-box D3D12 runtime. "Before" = same tree without the widened condition. Each replay mode run 12 times by hand. | Run | Before | After | |---|---|---| | controls | failed: `wave32` events `ballot, lds, lds` (negative control) | passed, both requests | | warp (WARP 1.0.22) | differed 12/12: word 8, expected `0x00001f05`, got `0x00000000` (9 runs), `0x0000020d`, `0x00000275`, `0x000001da` | matched 12/12, both requests | | hardware (RTX 4090) | matched 12/12, both requests | matched 12/12, both requests | Own-word negative control reported a mismatch in every replay run (word 8, got `0x00001f05`, expected `0x00000005`). ``` ctest --preset dev --no-tests=error -R '^(native_direct_container|native_scalar_lds_hardware|native_wave64_lane_pairs_(controls|hardware)|native_wave32_lds_order_(controls|hardware|warp))$' ``` 6 passed, `native_wave32_lds_order_warp` skipped (77, in-box WARP). After the rebase (head `1d03b1fe`, Debug, same machine), the same `ctest` command: 6 passed, `native_wave32_lds_order_warp` skipped (77, in-box WARP). With app-local WARP 1.0.22 beside the replay executable, `ctest --preset dev --no-tests=error -R '^native_wave32_lds_order_warp$' --repeat until-fail:12 -V` passed 12 of 12; both requests matched and the own-word negative control reported a mismatch. The before/after table above was taken on `8042961a` before the rebase. `main`'s virtual waves are wave64 and keep their group barrier before LDS accesses, so this change does not touch them. Not run: the full `^native_` set; any second GPU; a partial-wave LDS program (its WARP behaviour is inferred from #3160); the narrow wave64 request failing before the change (the fixture stops at the wave32 request first). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
R0D4X commented 2026-11-28 14:42:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0D4X on 2026-11-28T14:42:04Z.

Review: COMMENTED


Reviewed PR head 423b6c3ccf on Windows 11 Pro 26H2. No blocking defect was found in the tested paths.

Builds:

  • . .\tools\dev.ps1; cmake --preset dev; cmake --build --preset dev --target compile_dxil native_store_replay succeeded.
  • . .\tools\dev.ps1; cmake --preset release; cmake --build --preset release --target compile_dxil native_store_replay succeeded.

Hardware environment: adapter=NVIDIA GeForce RTX 5080 vendor=10de device=2c02, adapter_luid=00000000:00010887, driver=32.0.16.2140. native_store_replay does not enable the D3D12 debug layer, so no debug-layer report was collected. In-box WARP (C:\Windows\System32\d3d10warp.dll 10.0.26100.9818) was used for the WARP test.

Dev result:

  • . .\tools\dev.ps1; ctest --test-dir out/build/dev --no-tests=error -j 1 -V -R '^(native_wave32_lds_order_controls|native_wave32_lds_order_hardware|native_wave32_lds_order_warp|native_wave64_lane_pairs_controls|native_wave64_lane_pairs_hardware|native_direct_container)$' gave 5 passed and 1 skipped; CTest reported 100% tests passed, 0 tests failed out of 6. native_wave32_lds_order_warp was a capability skip: wave32: replay --direct-warp returned 77 (adapter lacks the required capabilities). The new wave32 LDS hardware cases and all lane-pair hardware cases matched their models and negatives on the RTX 5080.

Release result:

  • . .\tools\dev.ps1; ctest --test-dir out/build/release --no-tests=error -j 1 -V -R '^(native_wave32_lds_order_controls|native_wave64_lane_pairs_controls|native_direct_container)$' gave 3 passed.
  • . .\tools\dev.ps1; ctest --test-dir out/build/release --no-tests=error -j 1 -V -R '^(native_wave32_lds_order_hardware|native_wave64_lane_pairs_hardware|native_scalar_lds_hardware|native_wave32_lds_order_warp)$' gave native_wave32_lds_order_hardware and native_wave64_lane_pairs_hardware passed, native_wave32_lds_order_warp skipped with 77, and native_scalar_lds_hardware failed with native compute PSO creation failed. The same command in the base worktree at 052abe6f28f7f2aba31b58273afa81e79fbac841 failed identically with native compute PSO creation failed, so that failure is pre-existing and not caused by this PR.

Mutation checks:

  • Changing compiler.lane_pairs = branches && synchronizes; to compiler.lane_pairs = false; made . .\tools\dev.ps1; ctest --test-dir out/build/dev --no-tests=error -j 1 -V -R '^native_wave64_lane_pairs_controls$' fail at the expected lane-pair assertion (NumThreads=(64,1,1) was required; the mutant emitted (128,1,1)).
  • Changing if (!wave64 || lane_pairs) to if (false) in the LDS ballot path made . .\tools\dev.ps1; ctest --test-dir out/build/dev --no-tests=error -j 1 -V -R '^(native_wave64_lane_pairs_controls|native_wave32_lds_order_controls)$' fail both tests (ballots == 5 saw 1; wave32 IR events were ballot, lds, lds instead of ballot, ballot, lds, ballot, lds).
  • Both mutations were reverted with git checkout -- . immediately after their runs; the unmodified rebuild then produced the final clean dev result above.

Capability skips are reported separately from passes and failures. These fixtures support the tested translator behavior only; they do not establish full-game startup.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6098437027 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3356#pullrequestreview-6098437027). Originally posted by [R0D4X](https://github.com/R0D4X) on 2026-11-28T14:42:04Z. **Review:** COMMENTED --- Reviewed PR head 423b6c3ccf77676f8a66b26292b599829f47e5cb on Windows 11 Pro 26H2. No blocking defect was found in the tested paths. Builds: - `. .\tools\dev.ps1; cmake --preset dev; cmake --build --preset dev --target compile_dxil native_store_replay` succeeded. - `. .\tools\dev.ps1; cmake --preset release; cmake --build --preset release --target compile_dxil native_store_replay` succeeded. Hardware environment: `adapter=NVIDIA GeForce RTX 5080 vendor=10de device=2c02`, `adapter_luid=00000000:00010887`, `driver=32.0.16.2140`. `native_store_replay` does not enable the D3D12 debug layer, so no debug-layer report was collected. In-box WARP (`C:\Windows\System32\d3d10warp.dll` 10.0.26100.9818) was used for the WARP test. Dev result: - `. .\tools\dev.ps1; ctest --test-dir out/build/dev --no-tests=error -j 1 -V -R '^(native_wave32_lds_order_controls|native_wave32_lds_order_hardware|native_wave32_lds_order_warp|native_wave64_lane_pairs_controls|native_wave64_lane_pairs_hardware|native_direct_container)$'` gave 5 passed and 1 skipped; CTest reported `100% tests passed, 0 tests failed out of 6`. `native_wave32_lds_order_warp` was a capability skip: `wave32: replay --direct-warp returned 77 (adapter lacks the required capabilities)`. The new wave32 LDS hardware cases and all lane-pair hardware cases matched their models and negatives on the RTX 5080. Release result: - `. .\tools\dev.ps1; ctest --test-dir out/build/release --no-tests=error -j 1 -V -R '^(native_wave32_lds_order_controls|native_wave64_lane_pairs_controls|native_direct_container)$'` gave 3 passed. - `. .\tools\dev.ps1; ctest --test-dir out/build/release --no-tests=error -j 1 -V -R '^(native_wave32_lds_order_hardware|native_wave64_lane_pairs_hardware|native_scalar_lds_hardware|native_wave32_lds_order_warp)$'` gave `native_wave32_lds_order_hardware` and `native_wave64_lane_pairs_hardware` passed, `native_wave32_lds_order_warp` skipped with 77, and `native_scalar_lds_hardware` failed with `native compute PSO creation failed`. The same command in the base worktree at `052abe6f28f7f2aba31b58273afa81e79fbac841` failed identically with `native compute PSO creation failed`, so that failure is pre-existing and not caused by this PR. Mutation checks: - Changing `compiler.lane_pairs = branches && synchronizes;` to `compiler.lane_pairs = false;` made `. .\tools\dev.ps1; ctest --test-dir out/build/dev --no-tests=error -j 1 -V -R '^native_wave64_lane_pairs_controls$'` fail at the expected lane-pair assertion (`NumThreads=(64,1,1)` was required; the mutant emitted `(128,1,1)`). - Changing `if (!wave64 || lane_pairs)` to `if (false)` in the LDS ballot path made `. .\tools\dev.ps1; ctest --test-dir out/build/dev --no-tests=error -j 1 -V -R '^(native_wave64_lane_pairs_controls|native_wave32_lds_order_controls)$'` fail both tests (`ballots == 5` saw 1; wave32 IR events were `ballot, lds, lds` instead of `ballot, ballot, lds, ballot, lds`). - Both mutations were reverted with `git checkout -- .` immediately after their runs; the unmodified rebuild then produced the final clean dev result above. Capability skips are reported separately from passes and failures. These fixtures support the tested translator behavior only; they do not establish full-game startup. AI-assisted; commands listed were executed locally.
KelboLive commented 2026-11-28 20:54:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T20:54:40Z.

Review: APPROVED


LGTM — clean WaveActiveBallot before LDS accesses.

The ballot predicate ensures all lanes of the host wave reach the LDS access at the same point, fixing out-of-order reads on WARP where a lane reads words other lanes haven't written yet. The change applies correctly to both the wave32 model (where one host wave is one guest wave) and the lane-pair layout. Test controls verify the three-event pattern (entry ballot, LDS write ballot, LDS read ballot) in both request types.

Ready to land.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100049526 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3356#pullrequestreview-6100049526). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-28T20:54:40Z. **Review:** APPROVED --- LGTM — clean WaveActiveBallot before LDS accesses. The ballot predicate ensures all lanes of the host wave reach the LDS access at the same point, fixing out-of-order reads on WARP where a lane reads words other lanes haven't written yet. The change applies correctly to both the wave32 model (where one host wave is one guest wave) and the lane-pair layout. Test controls verify the three-event pattern (entry ballot, LDS write ballot, LDS read ballot) in both request types. Ready to land.
KelboLive commented 2026-11-28 21:57:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:57:29Z.

Review: APPROVED


LGTM — clean WaveActiveBallot before LDS accesses.

The ballot predicate ensures all lanes of the host wave reach the LDS access at the same point, fixing out-of-order reads on WARP where a lane reads words other lanes haven't written yet. The change applies correctly to both the wave32 model (where one host wave is one guest wave) and the lane-pair layout. Test controls verify the three-event pattern (entry ballot, LDS write ballot, LDS read ballot) in both request types.

Ready to land.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100254208 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3356#pullrequestreview-6100254208). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-28T21:57:29Z. **Review:** APPROVED --- LGTM — clean WaveActiveBallot before LDS accesses. The ballot predicate ensures all lanes of the host wave reach the LDS access at the same point, fixing out-of-order reads on WARP where a lane reads words other lanes haven't written yet. The change applies correctly to both the wave32 model (where one host wave is one guest wave) and the lane-pair layout. Test controls verify the three-event pattern (entry ballot, LDS write ballot, LDS read ballot) in both request types. Ready to land.
Not-Saii commented 2026-11-29 01:43:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-29T01:43:51Z.


Closing. The only failure this fixes was seen on app-local WARP 1.0.22; both NVIDIA GPUs matched without the ballot, and the cost of one more wave operation per LDS access in every wave32 module that uses LDS was not measured. The head 1d03b1fe stays reachable if WARP runs with that DLL become part of the suite.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7248975766 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3356#issuecomment-7248975766). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-29T01:43:51Z. --- Closing. The only failure this fixes was seen on app-local WARP 1.0.22; both NVIDIA GPUs matched without the ballot, and the cost of one more wave operation per LDS access in every wave32 module that uses LDS was not measured. The head `1d03b1fe` stays reachable if WARP runs with that DLL become part of the suite. AI-assisted.

Pull request closed

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!3356
No description provided.