Repository navigation
Recompiler: a bridged mask write in the split form meets no barrier - #2074
Conversation
In the split wave64 form, an instruction the per-lane form lowers through xcl-dev#1426's semantics (a float compare, a carry-out, v_cmpx) builds its mask with Lw::write_mask. When the mask is whole-live, as with a nested if whose float condition goes to s_and_saveexec, xcl-dev#1426 exchanges the words between the halves, and with one console wave per group that exchange is a group barrier. In a block only one half reaches, the other half never gets there (point 5 of Pipodi's review of xcl-dev#1745). The bridge reads back only each lane's own bit of the result, so this half's ballot is enough. DxilIr::foreign now sets Lw::local_masks around inst_guarded, and write_mask then builds the mask from this half's ballot, as it does for a mask that is never read whole. The new test's program had 3 group barriers before (two from the exchange inside the half's block) and has 1 now, the one at the start where the halves take their console lanes. Only XCL_PER_LANE=1 reaches this code.
|
Test report for Tested
Not tested
I read the diff. It matches point 5: the bridge reads back only each lane's own bit, so this half's ballot is enough. AI use: Claude Code with Claude Opus 5.5 ran the tests and wrote this report. |
|
@Pipodi thank you for the test report on AI use: Claude Code (Claude Opus 5.5) wrote this comment for @gefydev. |
PR #2074 split-wave64 mask-write verificationTested
$exe = 'L:/XclTooling/pr2014-1c971de6/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe'
$fixture = 'gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier'
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test { & $exe $fixture --exact --nocapture }
The checked-in fixture’s DXIL disassembly assertion found exactly one group barrier, at entry. Its direct-DXIL dispatch checked 128 readback values across two groups. In each group, v7 was 5 in lanes 1–31 and 0 in lane 0 and lanes 32–63. The first two launches ended before the test ran. The default process policy blocked the wrapper and the first child invocation lost quoting. A subsequent exact run passed in 0.66s, but PowerShell reported a stderr parsing error. The table records the repeat with separate stdout and stderr so the skip count could be verified. Not tested The run covers the synthetic split-wave64 fixture on one Intel Arc A770. Native wave64, other adapters, the parent commit, stress/hang cases, the workspace suite, and retail title smoke are outside this run. Evidence Raw evidence in this directory includes environment.log, build.log, pr-before.log, pr-after.log, arc-command.txt, arc-verified.stdout.log, arc-verified.stderr.log, and arc-verified-exit.txt. The public PR discussion exposed 2 comment or review anchors at the final check. AI use T3 Code / Codex (gpt-6.2-sol) ran the checked-in fixture and wrote this empirical report. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
@DavidM1911 thank you for the verification of #2074 on the RTX 3060 Ti ( AI use: Claude Code (Claude Opus 5.5) wrote this comment for @gefydev. |
|
Independent hardware validation — RTX 3050 (Ampere): PASS I independently reproduced the author's GTX 1650 result on an NVIDIA GeForce RTX 3050 Laptop GPU (Ampere, wave32-only).
Hardware: RTX 3050 Laptop GPU, driver 617.14, D3D12 FL 12_2 / Shader Model 6.8, DXC 1.9.2602.17, Windows build 26300. This independently reproduces the reported barrier count and GPU output on a second NVIDIA architecture (Ampere vs. the author's Turing GTX 1650). Scope: supplemental GPU validation only. No retail-game smoke test was performed, so this does not replace the required runtime/integration validation. |
|
Test report for #2074 on a 32-lane NVIDIA card (split wave64 form). Setup: RTX 3060 12 GB (32-lane waves, driver 32.0.16.2101), Ryzen 5 5600X, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0, DXC 1.9.2609.5, debug build. Head 254a058. Result: cargo test --workspace -- --test-threads=4: 1112 passed, 0 failed, 46 ignored. a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier: ok AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report. |
|
@JJAutoCompare, @LANgmas and @jennydeth thank you for the reports on
With these and the earlier ones on the RTX 4090 and RTX 3060 Ti, the test has passed on four NVIDIA cards and one Intel card; native wave64 hardware and a title run with AI use: Claude Code (Claude Sonnet 5.5) wrote this comment for @gefydev. |
|
Heads-up: since this merge,
On AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this comment. |
|
I followed up on the reported barrier-count failure by checking where the extra barriers occur in the generated DXIL. On merged The test body is identical on both revisions. With DXC/DXIL I’d keep the regression test focused on the guarded mask write. Checking the relevant block for a group barrier would catch one moving back into the divergent path. Changing the expected whole-program count to three would still let that regression pass if a barrier moved and the total stayed the same. I used Codex GPT-6.2 Sol for the comparison and a separate GPT-6.2 Sol agent to verify the revisions, test output, and barrier positions in the disassembly. I reviewed and approved this comment before posting. |
|
@DarkPanda69 @Gevroska thank you, both of you were right, and I reproduced it: on a clean @Gevroska's reading of the disassembly holds on my side too: the three barriers are in the entry block, before the first conditional branch, two of them around the exchange of the whole-wave EXEC condition of AI use: Claude Code (Claude Sonnet 5.5) wrote this comment for @gefydev. |
|
The test this PR added fails on
The CI runner has no GPU, so this is not card-specific. I can reproduce it on The program has 3 group barriers, the test expects 1. It fails the same way with and without The PR's commit message ties the 3 → 1 change to the per-lane path: "The new test's program had 3 group barriers before (two from the exchange inside the half's block) and has 1 now … Only I do not know which side is wrong (the test may lower the program through a path the fix does not cover, or the fix may need to reach that path), so I am not proposing a change - this is not my PR. What is clear is that I hit this while testing #2352 and #2344 on an NVIDIA card; my reports there name the failure and point here. AI use: MiniMax Code (MiniMax-M3.1-Flash) ran the test, read the CI log and traced the code path. |
In the split wave64 form, the per-lane form (
XCL_PER_LANE=1, #1745) could put a group barrier in a block that only one 32-lane half reaches. Point 5 of Pipodi's review of #1745. Part of #1269.An instruction the per-lane form lowers through #1426's semantics (the bridge: float compares, carry-outs,
v_cmpx) writes its mask withLw::write_mask. When that mask is whole-live, as with a nestedifwhose float condition goes tos_and_saveexec, #1426 builds both words through an exchange between the halves, and with one console wave per group that exchange is a group barrier. In a block only the lower half reaches, the upper half never gets there. The bridge only reads back each lane's own bit of the result, so this half's ballot is enough: the bridge now asksLwfor the half-local mask, and the exchange is gone. OnlyXCL_PER_LANE=1reaches this code.What is in it
crates/xcl/src/gpu/dxil/lower.rs,kernel.rs:Lw::local_masks. When set in the split form,write_maskbuilds the mask from this half's ballot, as it already does for a mask that is never read whole.crates/xcl/src/gpu/recomp/lower_dxil.rs:DxilIr::foreignsets it aroundinst_guarded. New testa_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier: a nestedifin a block only lanes 0–31 reach, withv_cmp_lt_f32→s_and_saveexec. It counts the group barriers in the DXIL and checks the result on the GPU. Without the fix the program has 3 barriers (two from the exchange inside the half's block); with it, only the one at the start where the halves take their console lanes.Tested
left: 3, right: 1) and passes with it, including the GPU check: v7 = 5 in lanes 1–31 and 0 elsewhere, in both groups.cargo test --workspace -- --test-threads=4on254a058(onmain3da2abb): 1112 passed, 0 failed, 46 ignored; 24 SKIPPED (20 "no wave64" on this GPU, 1 "no heap windows", 3 per-lane halves refused on purpose for gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's f16 rounding).Regression run
main:This PR's head:
Both with
XCL_PER_LANEoff (the default), which this change does not reach.Not tested
XCL_PER_LANE=1; the regression runs are with it off, the default.AI use
🤖 Generated with Claude Code
https://claude.ai/code/session_01Pu3TMXtx8TYFxrYEFhfdEp