Recompiler: read a second atomic operand only where it is used #1901
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1911"
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 ivall/xcl. Originally posted by Kalmarv on 2026-11-24T23:00:29Z.
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
39601b4(basemaincbc296a, 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.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 nono wave64skips, so every native-wave64 test ran. The two failures are the fuzz seeds 722 and 1599 tracked in #2115, which fail the same way onmainon that card. On an RTX 3060 on the same machine: 1,099 passed, 0 failed, 26 ignored.8ca5f81:cargo test --offline --release --workspace -- --test-threads=4gave 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 onmainc4d37be.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.maincbc296a(this PR's base):this PR,
39601b4: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 onmain.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
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
Imported from ivall/xcl. Originally posted by Melow-code on 2026-11-24T23:11:01Z.
Review: APPROVED
Real bug — VGPR data+1 was read outside the declared operands for add/min/max/swap. The fix is minimal and correct: register index instead of value, resolved only in the cmpxchg and mskor branches. 13 programs unblocked (329→316 refused) is a credible sweep.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-24T23:11:25Z.
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_ADDbecause 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.
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T01:08:06Z.
Build and testandPR descriptionare green onb6e884fand 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 onb6e884f, since prior NVIDIA runs were pre-rebase).Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-25T01:10:32Z.
Thanks, @raylitebull. An AMD pass on the current head
b6e884fis 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: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
b6e884fhere as soon as our GPU is free.AI use: Claude Code (Claude Opus 5.5) wrote this.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-25T01:30:14Z.
NVIDIA run on the exact head
b6e884f(b6e884f88993a6febb6c8fbdd05f00e0374ea6db), from a clean worktree.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.per_lane_atomics_take_their_declared_operandsand the shared, buffer and global atomic cases.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.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T02:15:51Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-25T02:30:00Z.
@DavidM1911 Rebased onto
maincbc296ab(after #1910) as39601b4. Thanks for the note.The one conflict was in the atomic lowering.
main's IEEEfcas32and this PR's integer compare-exchange now each fetch the second operand only in their own arm.Tested on the rebased head:
cargo test --release -p xcl --lib, unfiltered (GPU tests included): 1,099 passed, 0 failed, 26 ignored.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.
upstream-sync referenced this pull request2026-11-25 04:08:41 +00:00
upstream-sync referenced this pull request2026-11-25 10:09:30 +00:00
Imported from ivall/xcl. Originally posted by Melow-code on 2026-11-25T11:54:17Z.
Review: APPROVED
Review: XCL PR #1911 — read a second atomic operand only where it is used
Author: Kalmarv. lower_mem.rs +33/-11, lower_dxil.rs tests +57. Fetch:
git fetch xcl pull/1911/head:xcl1911(base689f2db).Verdict: mergeable as is
The bug is real and the fix is minimal: the 32-bit buffer/flat/LDS atomic lowering read
vreg(vdata + 1)unconditionally before knowing which atomic op it was lowering. Foradd,min,maxandswapthat register is outside the instruction's declared operands, and the per-lane bridge rightly rejects reads the ISA does not name — which is why the sweep sat at 316 of 2689 programs.The fix changes
rmw32to take the register index of the second operand instead of a resolvedValue, and resolves it only inside the two branches that need it —cmpswap/fcmpswap/cmpst_*(the comparand) andmskor_b32(the mask). Both resolutions happen inside theguardedblock, so the bridge sees exactly the ISA's operand list. The 64-bit path (atomic64, x2) is untouched — it already reads both halves of its pair. The MGSAD/imm path (DATA0/DATA1) keeps its operand-order swap forcmpst_*(cmpstputs the comparand in DATA0 per the ISA) while deferring thevregto the use site.The test is the right shape: a kernel with ADD, CMPSWAP, flat ADD, DS WRITE/ADD_RTN/CMPST_RTN/READ/MSKOR, run through DXC as reference and the direct-DXIL pipeline as the test subject, asserting both memory contents and per-lane VGPR return values against HLSL-computed expectations. The sweep result (329 accepted, up from 316 — thirteen programs that previously failed on the phantom read now translate) is the number that matters, and it is small enough to be believable rather than suspicious.
Notes (non-blocking)
rmw32'ssecond_vgpr: u64is only meaningful for two op names; every other caller passesvdata + 1unused. A doc line on the parameter ("read for cmpswap and mskor only") would stop the next caller from passing a real value expecting it to be used.rmw32's match — the fix is per-op, so a regression shows as one op failing again.upstream-sync referenced this pull request2026-11-25 12:04:57 +00:00
Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-25T12:24:49Z.
@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:fuzz_validate_and_gpu_1andfuzz_validate_and_gpu_3, the AMD fuzz seeds 722 and 1599 tracked in #2115, which fail the same way onmainon this card. SKIPPED (7): the 6 per-lanerefusedcases off16_programs_on_the_gpu/f32_programs_on_the_gpu(f16 arithmetic, f16 packed, f32 conversions; wave32 and wave64 each), andpso_measurement_compiles_an_exact_synthetic_record(cannot disable the driver cache without Developer Mode). Nono wave64skips, so every native-wave64 test ran.no wave64ones, 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.
xcl nvprofileputs xcl.exe in an NVIDIA profile with a bigger shader heap (#2403) #2580Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T00:34:54Z.
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
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-26T01:00:55Z.
@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 onmainon 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 intomainb49be18without conflicts.AI use: Claude Code (Claude Opus 5.5) checked the merge with
git merge-treeand wrote this.Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T20:30:00Z.
NVIDIA test report for head
39601b4825(merge-basecbc296ab65): RTX 3070 8 GB, driver 616.56, Windows 11 26100, rustc 1.100.0, debug, DXC 1.8.2502.11.New test
per_lane_atomics_take_their_declared_operands(cargo test -p xcl --lib per_lane_atomics_take_their_declared_operands): 3 of 3 runs passed on the head, not skipped; it does not exist on the merge-base.cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4: head 1090 passed, 0 failed, 26 ignored; merge-base 1089 passed, 0 failed, 26 ignored. SKIPPED identical on both: 20 no native wave64, 3 per-lane forms the translator refuses (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32), 1 needs Developer Mode. No nvlddmkm resets.Lib tests only; no title run.
AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T10:22:25Z.
Independent desktop NVIDIA verification of PR #1911 at head
39601b4825354e6e262dc20aa51bcd1bb2eb00ae(1commit; exact parent & merge-base:cbc296ab65a2661a61e3e2da109134bcd5319f60, pre-#2555ancestor ofmain).Environment
7956 MiBreported by D3D12, Wave32-only Ada), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted tests & build (
39601b48)cargo test --release -p xcl --lib per_lane_atomics_take_their_declared_operands -- --nocapture(3 consecutive runs)1 passed; 0 failed; 0 ignored; 1124 filtered out× 3 (0.27s,0.23s,0.23s,0skipped; live DXIL1.9.2609.5validation of per-lane atomic operand reads)cargo test --release -p xcl --lib gpu::dxil:: -- --nocapture(3 consecutive runs)122 passed; 0 failed; 3 ignored; 1000 filtered out× 3 (3.65s,3.69s,3.78s,0runtime skips;3pre-existing#[ignore]debug/seed tests; includes2000DXIL fuzz validation seeds and1232live RTX 4060 GPU comparisons per run)cargo build --release -p xcl1m 19s, exit0,0new warnings inlower_mem.rs/lower_dxil.rs)Paired quiet 60 s retail smoke (
title: 29640639)Exact parent & merge-base (
cbc296ab65a2661a61e3e2da109134bcd5319f60, cached baseline on the same machine):PR #1911 (
39601b4825354e6e262dc20aa51bcd1bb2eb00ae):Limits of coverage
per_lane_atomics_take_their_declared_operandstest and thegpu::dxil::suite (122tests +2000fuzz seeds /1232GPU comparisons) passed3/3on desktop RTX 4060 (Wave32-only Ada; native Wave64 paths are not exercised).0device removals,0crashes); single-run frame/commit delta vs. the cached parent reflects normal startup variance.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by throny on 2026-11-27T22:28:49Z.
merge-check claim
head:
39601b4825Imported from ivall/xcl. Originally posted by throny on 2026-11-27T23:13:05Z.
merge-check
base:
2c717a04head:
39601b4825merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1467 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1466 passed, 0 failed, 47 ignored
review: none. Operand order is unchanged for the compare-store and mask-or forms; the register read moved inside the guarded block is a read only; all three callers of rmw32 on main are updated. The test fails on main without a GPU (the translation is refused there).
performance: none by default (per-lane and direct DXIL are opt-in); only the direct-DXIL cache is re-keyed (reasoned).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T01:51:52Z.
merge-check claim
head:
39601b4825Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T02:44:31Z.
merge-check
base:
753e8b1a25head:
39601b4825merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1513 passed, 0 failed, 47 ignored, 25 SKIPPED: 21 no wave64, 3 per-lane f16/f32 forms refused (#1426 semantics), 1 no heap windows; failing: none. The suite ran on this PC at the same time as 6 other PRs' suites, in one queued job.
review: none. Whole diff read (lower_mem.rs rmw32 takes the second VGPR's number and reads it only for cmpswap / fcmpswap / mskor, for buffer, global and DS atomics; lower_dxil.rs GPU test against the HLSL path). Atomics with one data operand no longer read vdata+1 / DATA1 (which marked an undeclared VGPR as used); the operand order for DS cmpst (DATA1 value, DATA0 compare) is unchanged.
performance: reasoned, not measured: translation only; one fewer register read for single-operand atomics.
verdict: safe to merge
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile; trial merge 9a05804d48a4f785dd43c64816166ae00abbfa04 (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).