Recompiler: group-shared and texel sub as a compare-exchange loop #2752

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

@⁠jhincromwel-star on GitHub · 2026-11-26 10:09 UTC · original
jhincromwel-star:ds-sub-blackwell-main → main · +72 −14 · 4 files · 1 commits · open

What is in it

Tested

  • hardware (GPU + driver, CPU), Rust version, debug / release:
  • cargo test --workspace -- --test-threads=4: N passed, N failed, N ignored (SKIPPED GPU tests: …)

Regression run

main:

PR:

Not tested

AI use

  • none / tool and model, and what it did
**@⁠jhincromwel-star** on GitHub · 2026-11-26 10:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/2752) `jhincromwel-star:ds-sub-blackwell-main` → `main` · +72 −14 · 4 files · 1 commits · open <!-- What changes and why, in a few sentences. "Fixes #N" / "Part of #N". Stacked: "Stacked on #N". --> **What is in it** - **Tested** - hardware (GPU + driver, CPU), Rust version, debug / release: - `cargo test --workspace -- --test-threads=4`: N passed, N failed, N ignored (SKIPPED GPU tests: …) **Regression run** <!-- Required when the PR changes crates/xcl/src outside tests: `scripts/smoke.ps1` on a real title, built from main and from this PR's head commit (no uncommitted changes); paste both blocks. Rerun the PR's after every push. Not needed for docs / tests / scripts only. --> main: PR: **Not tested** - **AI use** - none / tool and model, and what it did
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:14:43 +00:00
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 10:16 UTC · original · reviewed

At efb14e7, the LDS part of this PR replaces variable ds_sub with a compare-exchange loop in both emit.rs and lower_mem.rs. #1919 is already open for the same Blackwell LDS subtract failure and changes those same files and the fuzz/test fixtures. Its author first tried a compare-exchange loop, then replaced it after measuring 318.9 ms for that loop versus 9.7 ms for the current #1919 approach in a 32-lane, one-slot contention case. Those are #1919's published measurements, not a benchmark of this PR.

Could you compare or coordinate the LDS approach with #1919 before both fixes proceed, and identify which texel-sub behavior here is distinct? A focused contention comparison of this head against #1919 would make the tradeoff reviewable. This is an exact-head source and overlap review assisted by Codex (GPT-6.2 Astra and GPT-6.2 Sol); I have not measured this head's performance or Blackwell behavior.

**@⁠luckyteagirl** on GitHub · 2026-11-26 10:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/2752#pullrequestreview-6072244096) · **reviewed** At `efb14e7`, the LDS part of this PR replaces variable `ds_sub` with a compare-exchange loop in both `emit.rs` and `lower_mem.rs`. [#1919](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1919) is already open for the same Blackwell LDS subtract failure and changes those same files and the fuzz/test fixtures. Its author first tried a compare-exchange loop, then replaced it after measuring 318.9 ms for that loop versus 9.7 ms for the current #1919 approach in a 32-lane, one-slot contention case. Those are #1919's published measurements, **not** a benchmark of this PR. Could you compare or coordinate the LDS approach with #1919 before both fixes proceed, and identify which texel-sub behavior here is distinct? A focused contention comparison of this head against #1919 would make the tradeoff reviewable. This is an exact-head source and overlap review assisted by Codex (GPT-6.2 Astra and GPT-6.2 Sol); I have not measured this head's performance or Blackwell behavior.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 10:26 UTC · original

On the RX 6800M, the new gpu_ds_sub_rtn_u32_with_a_variable_operand test fails on the HLSL/DXC path at exact clean head efb14e746d6a4367ed56bb5468daa39f87fce4b2. The Direct DXIL path passes.

Tested

Windows 11 Home build 26200, Ryzen 9 5980HX, AMD Radeon RX 6800M (PCI 1002:73df, driver 30.0.13002.13003), Rust 1.99.0 MSVC, and Windows SDK DXC/DXIL 1.8.2502.11. I set XCL_ADAPTER=AMD Radeon RX 6800M and XCL_REQUIRE_GPU=1. The test does not print the adapter name. I independently enumerated it in DXGI, and the test runner requires the explicit name match.

cargo test --locked -p xcl --lib -j 1 gpu::recomp::tests::gpu_ds_sub_rtn_u32_with_a_variable_operand -- --exact --test-threads=1 --nocapture
Revision and backend Passed Failed Ignored Filtered Skip markers Exit
Exact head, XCL_DIRECT_DXIL=0 0 1 0 1336 0 101
Exact head, XCL_DIRECT_DXIL=1 1 0 0 1336 0 0
Main b49be18 with this test added, HLSL/DXC 1 0 0 1336 0 0
Head with test-only HLSL capture, default DXC flags 0 1 0 1336 0 101
Head with the same capture and explicit DXC -O0 1 0 0 1336 0 0

The failing HLSL runs read 0xffffffff at lane 0, expected 0xfffff7e0 (0 - (1 + … + 64)). The main control added the PR test plus an HLSL dump and kept main's translator unchanged. The two captured HLSL files differ only in the subtract statement: main uses InterlockedAdd with a negated value, while head uses a bounded compare-exchange loop. Both emit GroupMemoryBarrierWithGroupSync() before and after the subtraction. The optimization control changed only the test's compilation argument. These results isolate an optimization-sensitive failure with the new HLSL lowering on this stack. They do not identify the compiler or driver stage responsible.

Not tested

Blackwell, other driver and DXC versions, #1919's alternate implementation, full workspace suite, retail title, and performance. The local control files were restored after testing.

AI use

OpenAI Codex (GPT-6.2 Sol) ran the tests and local controls, compared emitted HLSL, and drafted this report. OpenAI Codex (GPT-6.2 Astra) checked the logs and shader diff before posting.

**@⁠luckyteagirl** on GitHub · 2026-11-26 10:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/2752#issuecomment-7189371127) On the RX 6800M, the new `gpu_ds_sub_rtn_u32_with_a_variable_operand` test fails on the HLSL/DXC path at exact clean head `efb14e746d6a4367ed56bb5468daa39f87fce4b2`. The Direct DXIL path passes. **Tested** Windows 11 Home build 26200, Ryzen 9 5980HX, AMD Radeon RX 6800M (PCI `1002:73df`, driver `30.0.13002.13003`), Rust 1.99.0 MSVC, and Windows SDK DXC/DXIL 1.8.2502.11. I set `XCL_ADAPTER=AMD Radeon RX 6800M` and `XCL_REQUIRE_GPU=1`. The test does not print the adapter name. I independently enumerated it in DXGI, and the test runner requires the explicit name match. ```powershell cargo test --locked -p xcl --lib -j 1 gpu::recomp::tests::gpu_ds_sub_rtn_u32_with_a_variable_operand -- --exact --test-threads=1 --nocapture ``` | Revision and backend | Passed | Failed | Ignored | Filtered | Skip markers | Exit | | --- | ---: | ---: | ---: | ---: | ---: | ---: | | Exact head, `XCL_DIRECT_DXIL=0` | 0 | 1 | 0 | 1336 | 0 | 101 | | Exact head, `XCL_DIRECT_DXIL=1` | 1 | 0 | 0 | 1336 | 0 | 0 | | Main `b49be18` with this test added, HLSL/DXC | 1 | 0 | 0 | 1336 | 0 | 0 | | Head with test-only HLSL capture, default DXC flags | 0 | 1 | 0 | 1336 | 0 | 101 | | Head with the same capture and explicit DXC `-O0` | 1 | 0 | 0 | 1336 | 0 | 0 | The failing HLSL runs read `0xffffffff` at lane 0, expected `0xfffff7e0` (`0 - (1 + … + 64)`). The main control added the PR test plus an HLSL dump and kept main's translator unchanged. The two captured HLSL files differ only in the subtract statement: main uses `InterlockedAdd` with a negated value, while head uses a bounded compare-exchange loop. Both emit `GroupMemoryBarrierWithGroupSync()` before and after the subtraction. The optimization control changed only the test's compilation argument. These results isolate an optimization-sensitive failure with the new HLSL lowering on this stack. They do not identify the compiler or driver stage responsible. **Not tested** Blackwell, other driver and DXC versions, #1919's alternate implementation, full workspace suite, retail title, and performance. The local control files were restored after testing. **AI use** OpenAI Codex (GPT-6.2 Sol) ran the tests and local controls, compared emitted HLSL, and drafted this report. OpenAI Codex (GPT-6.2 Astra) checked the logs and shader diff before posting.
Author
Owner

@⁠sage-sage on GitHub · 2026-11-26 10:30 UTC · original

Test report: passes on NVIDIA Ada; this card does not show the bug. Exact head efb14e74 (its base is current main b49be18, so head = merged).

Tested

  • RTX 4080 SUPER (driver 621.40), Ryzen 5 7600X, Windows 11 26H2 build 26300.10075, rustc 1.100.0 MSVC, DXC 1.9.2602.17 (Windows SDK 10.0.26100), debug build
  • cargo test --workspace -- --test-threads=4: 1436 passed, 0 failed, 47 ignored; gpu_ds_sub_rtn_u32_with_a_variable_operand passes
  • SKIPPED: 29 lines, the same as on main on this machine (wave64, debug layer, Developer Mode, heap windows)
  • With lower_mem.rs and emit.rs taken back to main (local only), the new test still passes here: Ada's driver accepts the group-shared atomicrmw add of a negated value, so on this card the test checks the compare-exchange loop's result but does not reproduce the refusal.

Not tested

  • Blackwell (the driver the PR is about), AMD, Intel; no game.

Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

**@⁠sage-sage** on GitHub · 2026-11-26 10:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/2752#issuecomment-7189461999) **Test report: passes on NVIDIA Ada; this card does not show the bug.** Exact head `efb14e74` (its base is current `main` `b49be18`, so head = merged). **Tested** - RTX 4080 SUPER (driver 621.40), Ryzen 5 7600X, Windows 11 26H2 build 26300.10075, rustc 1.100.0 MSVC, DXC 1.9.2602.17 (Windows SDK 10.0.26100), debug build - `cargo test --workspace -- --test-threads=4`: 1436 passed, 0 failed, 47 ignored; `gpu_ds_sub_rtn_u32_with_a_variable_operand` passes - SKIPPED: 29 lines, the same as on `main` on this machine (wave64, debug layer, Developer Mode, heap windows) - With `lower_mem.rs` and `emit.rs` taken back to `main` (local only), the new test still passes here: Ada's driver accepts the group-shared `atomicrmw add` of a negated value, so on this card the test checks the compare-exchange loop's result but does not reproduce the refusal. **Not tested** - Blackwell (the driver the PR is about), AMD, Intel; no game. Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
Author
Owner

@⁠SzczepanGrela on GitHub · 2026-11-26 12:15 UTC · original

Additional RX 9070 / Wine result: I did not reproduce the HLSL failure reported above on this stack.

Tested

  • Exact head efb14e746d6a4367ed56bb5468daa39f87fce4b2, against main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 with only the PR's new 35-line synthetic test appended. Main's translator was unchanged. No local source changes on the head.
  • AMD Radeon RX 9070 16 GB (RADV GFX1201), Ryzen 7 7700, CachyOS kernel 7.3.0-5-cachyos, Mesa 26.3.1-arch3.5, GE-Proton11-12 Wine 11.0 Staging, vkd3d-proton 8293130ebe370b1+ (local asserts-disabled build), DXC/DXIL 1.9.2602.17, Rust 1.97.1, release x86_64-pc-windows-gnu binaries.
  • Explicit adapter selection XCL_ADAPTER="AMD Radeon RX 9070", XCL_REQUIRE_GPU=wave64, XCL_NETWORK=0, and XCL_DIRECT_DXIL=0 or 1. Fresh process and XCL DXIL cache directory for every run; vkd3d shader cache disabled.
  • gpu::recomp::tests::gpu_ds_sub_rtn_u32_with_a_variable_operand: 3/3 fresh-process passes per backend on the head and 3/3 per backend on the main control. Each run reported 1 passed, 0 failed, 0 ignored, 0 skip markers. The test checks the final LDS value in all 64 lanes and 64 distinct returned old values.
  • Filter gpu::recomp::tests::gpu_ds_: 5 passed, 0 failed, 0 ignored, 0 skip markers per revision/backend.
  • gpu::dxil::ops_tests::groupshared_barrier_and_atomics_run: 1 passed, 0 failed, 0 ignored, 0 skip markers per revision.

The Windows libtest binaries were invoked directly through the GE-Proton Wine executable, with --nocapture --test-threads=1 and --exact for individual tests. Raw summaries, source inventories, and executable hashes were checked after the runs. This establishes a passing result on this particular stack; it does not explain the RX 6800M result.

Not tested

Native Windows, other GPUs, alternate DXC or driver versions, the full fuzz/workspace suites, retail workloads, smoke runs, or performance.

AI use

OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the diff, ran and checked the synthetic comparisons, and drafted this report. Publication authorized by the account owner.

**@⁠SzczepanGrela** on GitHub · 2026-11-26 12:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/2752#issuecomment-7191768526) Additional RX 9070 / Wine result: I did not reproduce the HLSL failure reported above on this stack. **Tested** - Exact head `efb14e746d6a4367ed56bb5468daa39f87fce4b2`, against main `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7` with only the PR's new 35-line synthetic test appended. Main's translator was unchanged. No local source changes on the head. - AMD Radeon RX 9070 16 GB (RADV GFX1201), Ryzen 7 7700, CachyOS kernel 7.3.0-5-cachyos, Mesa 26.3.1-arch3.5, GE-Proton11-12 Wine 11.0 Staging, vkd3d-proton `8293130ebe370b1+` (local asserts-disabled build), DXC/DXIL 1.9.2602.17, Rust 1.97.1, release `x86_64-pc-windows-gnu` binaries. - Explicit adapter selection `XCL_ADAPTER="AMD Radeon RX 9070"`, `XCL_REQUIRE_GPU=wave64`, `XCL_NETWORK=0`, and `XCL_DIRECT_DXIL=0` or `1`. Fresh process and XCL DXIL cache directory for every run; vkd3d shader cache disabled. - `gpu::recomp::tests::gpu_ds_sub_rtn_u32_with_a_variable_operand`: 3/3 fresh-process passes per backend on the head and 3/3 per backend on the main control. Each run reported 1 passed, 0 failed, 0 ignored, 0 skip markers. The test checks the final LDS value in all 64 lanes and 64 distinct returned old values. - Filter `gpu::recomp::tests::gpu_ds_`: 5 passed, 0 failed, 0 ignored, 0 skip markers per revision/backend. - `gpu::dxil::ops_tests::groupshared_barrier_and_atomics_run`: 1 passed, 0 failed, 0 ignored, 0 skip markers per revision. The Windows libtest binaries were invoked directly through the GE-Proton Wine executable, with `--nocapture --test-threads=1` and `--exact` for individual tests. Raw summaries, source inventories, and executable hashes were checked after the runs. This establishes a passing result on this particular stack; it does not explain the RX 6800M result. **Not tested** Native Windows, other GPUs, alternate DXC or driver versions, the full fuzz/workspace suites, retail workloads, smoke runs, or performance. **AI use** OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the diff, ran and checked the synthetic comparisons, and drafted this report. Publication authorized by the account owner.
Author
Owner

@⁠Anon64 on GitHub · 2026-11-26 12:15 UTC · original

Regression run of efb14e7 on a newer retail title: no device removal, no crash, frames and commit within the limits.

Setup: RTX 3060 12 GB (NVIDIA 581.80), i9-14900KF, Windows 11 26200, release builds of main b49be18 (this PR's base) and of this PR's exact head, scripts/smoke.ps1 -Game <title> for 60 s with XCL_NETWORK=0 and A pressed every 4 s from 20 s. Main was run right after this PR's head, since peak commit on this title drifted up over the day on this machine (main peaked at 19.2 GB this morning).

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1476 (PresentX 1476)
presents per 2 s (last 3): 29 6 0
device removals: 0
crashes: 0
peak commit: 23242 MB

this PR:

xcl-smoke v1
commit: efb14e746d6a4367ed56bb5468daa39f87fce4b2
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1499 (PresentX 1500)
presents per 2 s (last 3): 42 9 1
device removals: 0
crashes: 0
peak commit: 24923 MB

102 % of main's frames, 107 % of its peak commit. One run each.

Not tested: the suite on this head; whether the title runs the group-shared/texel sub atomics this PR changes in its first 60 s; AMD.

AI use: Claude Code (Claude Opus 5.5) ran these runs on this machine and wrote this report.

**@⁠Anon64** on GitHub · 2026-11-26 12:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/2752#issuecomment-7191780466) **Regression run of `efb14e7` on a newer retail title: no device removal, no crash, frames and commit within the limits.** **Setup:** RTX 3060 12 GB (NVIDIA 581.80), i9-14900KF, Windows 11 26200, release builds of main `b49be18` (this PR's base) and of this PR's exact head, `scripts/smoke.ps1 -Game <title>` for 60 s with `XCL_NETWORK=0` and A pressed every 4 s from 20 s. Main was run right after this PR's head, since peak commit on this title drifted up over the day on this machine (main peaked at 19.2 GB this morning). main: ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1476 (PresentX 1476) presents per 2 s (last 3): 29 6 0 device removals: 0 crashes: 0 peak commit: 23242 MB ``` this PR: ``` xcl-smoke v1 commit: efb14e746d6a4367ed56bb5468daa39f87fce4b2 gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1499 (PresentX 1500) presents per 2 s (last 3): 42 9 1 device removals: 0 crashes: 0 peak commit: 24923 MB ``` 102 % of main's frames, 107 % of its peak commit. One run each. **Not tested:** the suite on this head; whether the title runs the group-shared/texel sub atomics this PR changes in its first 60 s; AMD. AI use: Claude Code (Claude Opus 5.5) ran these runs on this machine and wrote this report.
This pull request can be merged automatically.
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/2752/head:github-bot/gh-2752'
git switch 'github-bot/gh-2752'

Merge

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