Recompiler: read a second atomic operand only where it is used #1911

Open
github-bot wants to merge 1 commit from github-bot/gh-1911 into main AGit
Owner

@⁠Kalmarv on GitHub · 2026-11-24 23:00 UTC · original
Kalmarv:atomic-operand-use → main · +80 −15 · 2 files · 1 commits · open

Part of #1269. The 32-bit buffer, flat and LDS atomic lowering read a second VGPR before selecting the operation. For add, min, max and exchange that register is not one of the instruction's operands, so the per-lane bridge correctly refused the extra read and the whole program fell back to the HLSL form.

What is in it

  • crates/xcl/src/gpu/dxil/lower_mem.rs: the second register is resolved only for compare-exchange and masked OR, the two operations that use it.
  • crates/xcl/src/gpu/recomp/lower_dxil.rs: a GPU test that checks the return values and memory of the per-lane atomics against HLSL.

Tested

  • Ryzen 9 9950X, RTX 5070 Ti (NVIDIA 610.74), Windows 11 build 26200, Rust 1.99.0 (MSVC x64), release, DXC 1.9.2609.5.
  • On the rebased head 39601b4 (base main cbc296a, after #1910): cargo test --release -p xcl --lib, unfiltered with GPU tests included, 1,099 passed, 0 failed, 26 ignored, with 23 skip notices (20 for no native wave64, 3 for unsupported wave32 FP). The atomics GPU test and #1910's native-wave branch test both ran on the card.
  • AMD RX 9070 XT (RDNA4, native wave64), measured by @⁠DarkPanda69 (comment) on 39601b4, Ryzen 7 5800X, DXC 1.9.2602, cargo test --release -p xcl --lib -- --test-threads=4: 1,097 passed, 2 failed, 26 ignored, with no no wave64 skips, so every native-wave64 test ran. The two failures are the fuzz seeds 722 and 1599 tracked in #2115, which fail the same way on main on that card. On an RTX 3060 on the same machine: 1,099 passed, 0 failed, 26 ignored.
  • Before the rebase, on 8ca5f81: cargo test --offline --release --workspace -- --test-threads=4 gave 960 passed, 0 failed, 43 ignored. A native compute survey with four switch-selected memory windows put 329 of 2,689 programs in the per-lane form, up from 316 on main c4d37be.

Regression run

scripts/smoke.ps1, the same retail title for 60 s each, one after the other on the machine under Tested, release builds from clean trees.

main cbc296a (this PR's base):

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1113 (PresentX 1113)
presents per 2 s (last 3): 0 2 0
device removals: 0
crashes: 0
peak commit: 24774 MB

this PR, 39601b4:

xcl-smoke v1
commit: 39601b4825354e6e262dc20aa51bcd1bb2eb00ae
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1287 (PresentX 1288)
presents per 2 s (last 3): 39 38 40
device removals: 0
crashes: 0
peak commit: 26844 MB

PR vs main: 1287 / 1113 frames (116 %), peak commit 26844 / 24774 MB (108 %); device removals 0 and crashes 0 on the PR run, 0 and 0 on main.

Both runs are on the rebased head and its new base. main's run was still loading over its last 6 s (0, 2 and 0 presents), so the difference in frames is load timing, not this change.

Not tested

  • A title run on AMD, and Linux.
  • 64-bit atomics and image atomics, which this change doesn't touch.

AI use

OpenAI Codex (GPT-6.2) wrote the change and the test and ran the suite and the pack count. Claude Code (Claude Opus 5.5) wrote this description and opened the PR.

🤖 Generated with Claude Code

**@⁠Kalmarv** on GitHub · 2026-11-24 23:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/1911) `Kalmarv:atomic-operand-use` → `main` · +80 −15 · 2 files · 1 commits · open Part of #1269. The 32-bit buffer, flat and LDS atomic lowering read a second VGPR before selecting the operation. For add, min, max and exchange that register is not one of the instruction's operands, so the per-lane bridge correctly refused the extra read and the whole program fell back to the HLSL form. **What is in it** - `crates/xcl/src/gpu/dxil/lower_mem.rs`: the second register is resolved only for compare-exchange and masked OR, the two operations that use it. - `crates/xcl/src/gpu/recomp/lower_dxil.rs`: a GPU test that checks the return values and memory of the per-lane atomics against HLSL. **Tested** - Ryzen 9 9950X, RTX 5070 Ti (NVIDIA 610.74), Windows 11 build 26200, Rust 1.99.0 (MSVC x64), release, DXC 1.9.2609.5. - On the rebased head `39601b4` (base `main` `cbc296a`, after #1910): `cargo test --release -p xcl --lib`, unfiltered with GPU tests included, 1,099 passed, 0 failed, 26 ignored, with 23 skip notices (20 for no native wave64, 3 for unsupported wave32 FP). The atomics GPU test and #1910's native-wave branch test both ran on the card. - **AMD RX 9070 XT (RDNA4, native wave64), measured by @⁠DarkPanda69** ([comment](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1911)) on `39601b4`, Ryzen 7 5800X, DXC 1.9.2602, `cargo test --release -p xcl --lib -- --test-threads=4`: 1,097 passed, 2 failed, 26 ignored, with no `no wave64` skips, so every native-wave64 test ran. The two failures are the fuzz seeds 722 and 1599 tracked in #2115, which fail the same way on `main` on that card. On an RTX 3060 on the same machine: 1,099 passed, 0 failed, 26 ignored. - Before the rebase, on `8ca5f81`: `cargo test --offline --release --workspace -- --test-threads=4` gave 960 passed, 0 failed, 43 ignored. A native compute survey with four switch-selected memory windows put 329 of 2,689 programs in the per-lane form, up from 316 on `main` `c4d37be`. **Regression run** `scripts/smoke.ps1`, the same retail title for 60 s each, one after the other on the machine under **Tested**, release builds from clean trees. `main` `cbc296a` (this PR's base): ``` xcl-smoke v1 commit: cbc296ab65a2661a61e3e2da109134bcd5319f60 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1113 (PresentX 1113) presents per 2 s (last 3): 0 2 0 device removals: 0 crashes: 0 peak commit: 24774 MB ``` this PR, `39601b4`: ``` xcl-smoke v1 commit: 39601b4825354e6e262dc20aa51bcd1bb2eb00ae gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1287 (PresentX 1288) presents per 2 s (last 3): 39 38 40 device removals: 0 crashes: 0 peak commit: 26844 MB ``` PR vs `main`: 1287 / 1113 frames (116 %), peak commit 26844 / 24774 MB (108 %); device removals 0 and crashes 0 on the PR run, 0 and 0 on `main`. Both runs are on the rebased head and its new base. `main`'s run was still loading over its last 6 s (0, 2 and 0 presents), so the difference in frames is load timing, not this change. **Not tested** - A title run on AMD, and Linux. - 64-bit atomics and image atomics, which this change doesn't touch. **AI use** OpenAI Codex (GPT-6.2) wrote the change and the test and ran the suite and the pack count. Claude Code (Claude Opus 5.5) wrote this description and opened the PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The 32-bit buffer, flat and LDS lowering read a second VGPR before selecting the atomic operation. For add, min, max and exchange this register is outside the instruction's declared operands. The per-lane bridge correctly rejected that extra read.

Resolve the extra register only for compare-exchange and masked OR. The GPU test checks return values and memory against HLSL. A four-window sweep accepts 329 of 2689 compute programs, up from 316.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:09:15 +00:00
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-24 23:11 UTC · original

Independent split-wave64 check of 14dec7f on an RTX 3080 Ti (621.35), Windows 11 build 26300, Rust 1.99.1 MSVC debug, DXC 1.8.2502.11.

I extended the bundled buffer, global, and LDS atomic fixture to run a 64-lane program on two hardware waves. The shader enabled 21 lanes across both halves. Per-lane DXIL matched the HLSL and CPU expectations for all 128 memory words and 448 destination values. The 43 inactive lanes retained their initial memory and register values, and both EXEC words restored correctly. With only main’s memory lowering restored, per-lane translation refused BUFFER_ATOMIC_ADD because it read a second register that the instruction did not supply.

cargo test --offline --locked -p xcl --lib per_lane_atomics -- --nocapture --test-threads=1: 2 passed (stock wave32 and the split-wave64 extension), zero skips. Synthetic inputs only.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) extended and ran the test and drafted this report.

**@⁠thehollowedone** on GitHub · 2026-11-24 23:11 UTC · [original](https://github.com/xcl-dev/xcl/pull/1911#issuecomment-7147117202) Independent split-wave64 check of [14dec7f](https://github.com/xcl-dev/xcl/commit/14dec7f0240fcfc0ec71f7e5665e4ad6586719ed) on an RTX 3080 Ti (621.35), Windows 11 build 26300, Rust 1.99.1 MSVC debug, DXC 1.8.2502.11. I extended the bundled buffer, global, and LDS atomic fixture to run a 64-lane program on two hardware waves. The shader enabled 21 lanes across both halves. Per-lane DXIL matched the HLSL and CPU expectations for all 128 memory words and 448 destination values. The 43 inactive lanes retained their initial memory and register values, and both EXEC words restored correctly. With only [main’s](https://github.com/xcl-dev/xcl/commit/689f2db477c3c062cf162649781640ef8a977c18) memory lowering restored, per-lane translation refused `BUFFER_ATOMIC_ADD` because it read a second register that the instruction did not supply. `cargo test --offline --locked -p xcl --lib per_lane_atomics -- --nocapture --test-threads=1`: 2 passed (stock wave32 and the split-wave64 extension), zero skips. Synthetic inputs only. AI-assisted. Codex (GPT-6 family, exact variant unavailable) extended and ran the test and drafted this report.
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 01:08 UTC · original

Build and test and PR description are green on b6e884f and the code review is approved.

Remaining before merge: one independent AMD GPU pass on the current head b6e884f (and if possible an NVIDIA sanity check on b6e884f, since prior NVIDIA runs were pre-rebase).

**@⁠raylitebull** on GitHub · 2026-11-25 01:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/1911#issuecomment-7149240215) `Build and test` and `PR description` are green on `b6e884f` and the code review is approved. **Remaining before merge:** one independent **AMD** GPU pass on the current head `b6e884f` (and if possible an NVIDIA sanity check on `b6e884f`, since prior NVIDIA runs were pre-rebase).
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-25 01:10 UTC · original

Thanks, @⁠raylitebull. An AMD pass on the current head b6e884f is the one missing piece. We have no AMD card here, so this needs someone who does. @⁠srcamarda and @⁠DarkPanda69, you've run AMD passes on related heads before. If either of you has time:

git fetch https://github.com/xcl-dev/xcl.git pull/1911/head && git checkout FETCH_HEAD
cargo test --release -p xcl --lib -- --test-threads=4

Please post the passed, failed and ignored counts, any SKIPPED lines, and your GPU, driver and DXC version.

We will post the NVIDIA run on b6e884f here as soon as our GPU is free.

AI use: Claude Code (Claude Opus 5.5) wrote this.

**@⁠Kalmarv** on GitHub · 2026-11-25 01:10 UTC · [original](https://github.com/xcl-dev/xcl/pull/1911#issuecomment-7149281819) Thanks, @⁠raylitebull. An AMD pass on the current head `b6e884f` is the one missing piece. We have no AMD card here, so this needs someone who does. @⁠srcamarda and @⁠DarkPanda69, you've run AMD passes on related heads before. If either of you has time: ~~~ git fetch https://github.com/xcl-dev/xcl.git pull/1911/head && git checkout FETCH_HEAD cargo test --release -p xcl --lib -- --test-threads=4 ~~~ Please post the passed, failed and ignored counts, any SKIPPED lines, and your GPU, driver and DXC version. We will post the NVIDIA run on `b6e884f` here as soon as our GPU is free. AI use: Claude Code (Claude Opus 5.5) wrote this.
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-25 01:30 UTC · original

NVIDIA run on the exact head b6e884f (b6e884f88993a6febb6c8fbdd05f00e0374ea6db), from a clean worktree.

  • RTX 5070 Ti, NVIDIA 610.74, Ryzen 9 9950X, Windows 11 26200, DXC and DXIL 1.9.2609.5, rustc 1.99.0, release.
  • cargo test --release -p xcl --lib -- --test-threads=4: 938 passed, 0 failed, 25 ignored. 11 tests printed 21 SKIPPED messages. 18 are native-wave64 subcases, which this card doesn't have, and 3 are per-lane FP subcases unsupported on wave32.
  • The 6 GPU tests this PR touches, rerun on their own: 6 passed, 0 failed, 0 skipped. These include per_lane_atomics_take_their_declared_operands and the shared, buffer and global atomic cases.
  • No XCL_SAMPLE_* variables were set. Both commands exited 0.

The AMD pass is still open; the request is above.

AI use: OpenAI Codex (GPT-6) ran the tests and summarized the logs; Claude Code (Claude Opus 5.5) wrote this comment.

**@⁠Kalmarv** on GitHub · 2026-11-25 01:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/1911#issuecomment-7149619615) NVIDIA run on the exact head `b6e884f` (`b6e884f88993a6febb6c8fbdd05f00e0374ea6db`), from a clean worktree. - RTX 5070 Ti, NVIDIA 610.74, Ryzen 9 9950X, Windows 11 26200, DXC and DXIL 1.9.2609.5, rustc 1.99.0, release. - `cargo test --release -p xcl --lib -- --test-threads=4`: 938 passed, 0 failed, 25 ignored. 11 tests printed 21 SKIPPED messages. 18 are native-wave64 subcases, which this card doesn't have, and 3 are per-lane FP subcases unsupported on wave32. - The 6 GPU tests this PR touches, rerun on their own: 6 passed, 0 failed, 0 skipped. These include `per_lane_atomics_take_their_declared_operands` and the shared, buffer and global atomic cases. - No `XCL_SAMPLE_*` variables were set. Both commands exited 0. The AMD pass is still open; the request is above. AI use: OpenAI Codex (GPT-6) ran the tests and summarized the logs; Claude Code (Claude Opus 5.5) wrote this comment.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 02:15 UTC · original

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-25 02:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/1911#issuecomment-7150508059) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-25 02:30 UTC · original

@⁠DavidM1911 Rebased onto main cbc296ab (after #1910) as 39601b4. Thanks for the note.

The one conflict was in the atomic lowering. main's IEEE fcas32 and this PR's integer compare-exchange now each fetch the second operand only in their own arm.

Tested on the rebased head:

  • RTX 5070 Ti, NVIDIA 610.74, Windows 11 build 26200, release, DXC 1.9.2609.5.
  • cargo test --release -p xcl --lib, unfiltered (GPU tests included): 1,099 passed, 0 failed, 26 ignored.
  • 23 SKIPPED messages across 13 tests: 20 for no native wave64, 3 for unsupported wave32 FP.
  • This PR's atomic regression test and #1910's native-wave branch test both pass on the card.

Not tested: AMD.

AI use: a Codex (GPT-6.2) helper did the rebase and ran the suite; Claude Code (Claude Opus 5.5) pushed it and wrote this.

**@⁠Kalmarv** on GitHub · 2026-11-25 02:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/1911#issuecomment-7150802290) @⁠DavidM1911 Rebased onto `main` `cbc296ab` (after #1910) as `39601b4`. Thanks for the note. The one conflict was in the atomic lowering. `main`'s IEEE `fcas32` and this PR's integer compare-exchange now each fetch the second operand only in their own arm. **Tested** on the rebased head: - RTX 5070 Ti, NVIDIA 610.74, Windows 11 build 26200, release, DXC 1.9.2609.5. - `cargo test --release -p xcl --lib`, unfiltered (GPU tests included): 1,099 passed, 0 failed, 26 ignored. - 23 SKIPPED messages across 13 tests: 20 for no native wave64, 3 for unsupported wave32 FP. - This PR's atomic regression test and #1910's native-wave branch test both pass on the card. **Not tested:** AMD. AI use: a Codex (GPT-6.2) helper did the rebase and ran the suite; Claude Code (Claude Opus 5.5) pushed it and wrote this.
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-25 12:24 UTC · original

@⁠Kalmarv here's the AMD pass you asked for, on the rebased head 39601b4 (39601b482), checked out as is (no local changes), in the form you gave.

Tested: Windows 11 Pro 26200, Ryzen 7 5800X, rustc 1.100.0, DXC 1.9.2602.17, release. cargo test --release -p xcl --lib -- --test-threads=4:

  • AMD RX 9070 XT (RDNA4, driver 32.0.32029.2010, waves 32..64): 1097 passed, 2 failed, 26 ignored. The 2 failures are fuzz_validate_and_gpu_1 and fuzz_validate_and_gpu_3, the AMD fuzz seeds 722 and 1599 tracked in #2115, which fail the same way on main on this card. SKIPPED (7): the 6 per-lane refused cases of f16_programs_on_the_gpu / f32_programs_on_the_gpu (f16 arithmetic, f16 packed, f32 conversions; wave32 and wave64 each), and pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache without Developer Mode). No no wave64 skips, so every native-wave64 test ran.
  • NVIDIA RTX 3060 (driver 32.0.16.1088, waves 32 only), for comparison: 1099 passed, 0 failed, 26 ignored, 25 SKIPPED (the no wave64 ones, the same 3 per-lane refusals for wave32, and the driver-cache one).

Not tested: a title, b6e884f (I ran the rebased head that is current now).
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

**@⁠DarkPanda69** on GitHub · 2026-11-25 12:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/1911#issuecomment-7162339029) @⁠Kalmarv here's the AMD pass you asked for, on the rebased head `39601b4` (`39601b482`), checked out as is (no local changes), in the form you gave. **Tested:** Windows 11 Pro 26200, Ryzen 7 5800X, rustc 1.100.0, DXC 1.9.2602.17, release. `cargo test --release -p xcl --lib -- --test-threads=4`: - **AMD RX 9070 XT** (RDNA4, driver 32.0.32029.2010, waves 32..64): **1097 passed, 2 failed, 26 ignored**. The 2 failures are `fuzz_validate_and_gpu_1` and `fuzz_validate_and_gpu_3`, the AMD fuzz seeds 722 and 1599 tracked in #2115, which fail the same way on `main` on this card. SKIPPED (7): the 6 per-lane `refused` cases of `f16_programs_on_the_gpu` / `f32_programs_on_the_gpu` (f16 arithmetic, f16 packed, f32 conversions; wave32 and wave64 each), and `pso_measurement_compiles_an_exact_synthetic_record` (cannot disable the driver cache without Developer Mode). No `no wave64` skips, so every native-wave64 test ran. - **NVIDIA RTX 3060** (driver 32.0.16.1088, waves 32 only), for comparison: **1099 passed, 0 failed, 26 ignored**, 25 SKIPPED (the `no wave64` ones, the same 3 per-lane refusals for wave32, and the driver-cache one). Not tested: a title, `b6e884f` (I ran the rebased head that is current now). AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 00:34 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 00:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/1911#issuecomment-7178904478) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-26 01:00 UTC · original

@⁠DarkPanda69 thank you. That is the AMD pass on the current head 39601b4. The 2 failures are the #2115 fuzz seeds, and they fail the same way on main on that card.

With it, the items @⁠raylitebull listed on 11-25 are all in for 39601b4: both checks are green, there are two approving reviews, an NVIDIA run (RTX 5070 Ti) and this AMD run (RX 9070 XT, RDNA4). The head merges into main b49be18 without conflicts.

AI use: Claude Code (Claude Opus 5.5) checked the merge with git merge-tree and wrote this.

**@⁠Kalmarv** on GitHub · 2026-11-26 01:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/1911#issuecomment-7179339622) @⁠DarkPanda69 thank you. That is the AMD pass on the current head `39601b4`. The 2 failures are the #2115 fuzz seeds, and they fail the same way on `main` on that card. With it, the items @⁠raylitebull listed on 11-25 are all in for `39601b4`: both checks are green, there are two approving reviews, an NVIDIA run (RTX 5070 Ti) and this AMD run (RX 9070 XT, RDNA4). The head merges into `main` `b49be18` without conflicts. AI use: Claude Code (Claude Opus 5.5) checked the merge with `git merge-tree` and wrote this.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1911/head:github-bot/gh-1911'
git switch 'github-bot/gh-1911'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1911'
git switch 'github-bot/gh-1911'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1911'
git switch 'github-bot/gh-1911'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1911'
git switch 'main'
git merge --squash 'github-bot/gh-1911'
git switch 'main'
git merge --ff-only 'github-bot/gh-1911'
git switch 'main'
git merge 'github-bot/gh-1911'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.