Repository navigation
Recompiler: a vote's side may narrow EXEC through a whole-quad copy (#336) - #953
Conversation
…ll#336) Preparation for classifying wave64 VS / PS by whether their result depends on how a 32-lane GPU cuts their waves: that needs to know which blocks run because of a wave-wide vote. No behaviour change: nothing calls it yet. cfg::Cfg builds a program's basic blocks from upper_lanes::successors (now shared), and gives each block's immediate post-dominator (Cooper, Harvey and Kennedy's iteration on the reversed graph, with one exit after every block that ends the program) and the branches it is control-dependent on (Ferrante, Ottenstein and Warren). A program with an indirect jump has no graph; a block from which no path ends the program has no post-dominator. Measured over all 26 698 programs of a retail shader pack (release, one thread): no panic, 195 with an indirect jump, at most 15 995 blocks in one program, at most 15 ms for one program's graph, post-dominators and control dependence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…them Part of xcl-dev#336. A GPU that runs a console wave64 VS / PS in 32-lane waves runs each half of the console wave on its own. upper_lanes follows what lanes >= 32 hold when they are read; this follows the other ways the cut shows: wave-wide votes are taken per half, and lane counts, ranks, first-lane indices, masks used as numbers and other lanes' values differ in a half. Classification only: nothing translates by it yet. partition::classify runs a forward data-flow pass over the program's blocks (cfg) with taint bits per register and reports Exact / MayDiffer with the reasons: - a tainted value reaching an export, a store (LDS / GDS ones included), a branch or EXEC; one word of EXEC or a number written to EXEC; - a vote (vccz/vccnz, execz/execnz, scc on a mask) unless the side taken with the mask empty is the join or ends the program writing nothing, and the other side starts by narrowing EXEC to the mask (for a mask other than EXEC) and does not widen it again before the join (a restore of a mask saved inside, an if/else flip, a restore right before the join are fine) – or the mask is all or none of the active lanes; - a scalar written in the blocks a vote decides and read after the join (a half that took the other side never wrote it). Values every lane has are followed (written under the launch EXEC by plain VALU ops of such values, through all-or-none selectors, or loaded at such addresses), so reading one from the first lane is exact. Register uses come from x64_masks::uses (read-modify-write destinations, SDWA scalar sources, SMEM offsets, src_vccz / src_execz) plus src_scc, NSA addresses and image loads by their DMASK (upper_lanes::vgpr_writes, now shared). Tests include the review's counter-examples (values written under a narrowed EXEC or selected per lane, a vote read as a number, mask words moved, read-modify-write taint, a side that widens EXEC again, an SCC vote whose mask is rewritten, EXEC's high word, image DMASK, DS writes) and one for every reason. Over the 13 210 wave64 VS / PS of a retail shader pack (local run): 7 208 Exact (5 118 of 10 974 PS, 2 090 of 2 236 VS), at most 159 ms a program. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cl-dev#336) The partition classifier accepted a mask vote only if the side the wave runs starts with an instruction that narrows EXEC by the vote's mask. The console compiler's pixel-shader discard early-out narrows it one step later: `s_wqm_b64 s, live; s_and_b64 exec, exec, s`, often with scalar loads in between. Such votes were reported as `vote-branch`. The side now only has to turn EXEC off, in a half whose mask is empty, before its first lane instruction. The zero flow of the vote's side checks it: wqm(0) and x & 0 are zero there. Before that only scalar ALU ops, scalar loads, s_waitcnt and s_nop are allowed; their writes are the wave's and are followed as stale where the sides join. s_setreg, s_sendmsg, PC writes and any lane instruction end the search. Every shape the old first-instruction check accepted passes the new one. Over the 13 210 wave64 VS / PS of a retail shader pack: 7 015 Exact instead of 6 057 (PS 4 912 of 10 974, from 3 954), `vote-branch` 5 186 programs instead of 6 375. A reference interpreter of a 64-lane wave and its two 32-lane halves (from the review of xcl-dev#517) shows no difference for the new exact form over 5 000 random cuts, and differs for an export placed before the narrowing, which stays `vote-branch`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
NVIDIA run, since Not tested lists NVIDIA. The classifier is CPU-side and nothing calls it yet, so this mainly covers the build and suite on a 32-lane card. Tested
Not tested
AI use
|
|
Test report for head Setup
Tested: no regressions on either GPU.
This PR adds no GPU test, so these runs only show that the existing recompiler GPU tests still pass with it, including native wave64 on AMD. They do not check the programs it makes |
|
Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on 51 more passing tests than the baseline — the whole-console-block EXEC narrowing change ships a lot of new fixtures and every one of them runs green here. Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it. |
|
Linux / AMD RDNA3 datapoint. Merged state: head Full suite, Not tested: retail titles (none here), Windows, RDNA4. Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
Stacked on #517 (itself on #341); only the top commit (38992ed) belongs here. Part of #336.
#517's classifier accepts a mask vote only if the side the wave runs starts with an instruction that narrows EXEC by the vote's mask. The console compiler's pixel-shader discard early-out narrows it one step later:
So these votes were reported as
vote-branch. In the retail shader pack, this shape is behind most of the 2 409 programs whose only reason wasvote-branch.The side now only has to turn EXEC off in a half whose mask is empty before its first lane instruction. #517's zero flow checks this:
wqm(0)andx & 0are zero there. Before that point only scalar ALU ops, scalar loads,s_waitcntands_nopare allowed. Their writes are the wave's, and #517 already follows them as stale where the sides join.s_setreg,s_sendmsg, PC writes and any lane instruction end the search. Every shape the old first-instruction check accepted passes the new one.What is in it
crates/xcl/src/gpu/recomp/partition.rs:narrows_before_lane_workreplacesnarrows_exec_byinvote.a_discard_early_out_that_narrows_through_a_whole_quad_copy_is_exact:s_setregbefore it all stayvote-branch.Tested
x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug for the suite, release for the runs.cargo test --workspace -- --test-threads=4at 38992ed: 727 passed, 0 failed, 41 ignored; noSKIPPEDlines.cargo test -p xcl --lib recomp::partition: 44 passed.p1's reason list.cut: one 64-lane wave against its two 32-lane halves), in a local test that is not committed:vote-branch.vote-branchin 5 186 programs instead of 6 375;Regression run
Nothing in the runtime calls the classifier yet, so this only shows the build is unchanged in use. The
gpu:line names a virtual display adapter of this machine (what #281 / #282 / #285 fix); XCL's log namesbackend 'real' – AMD Radeon RX 9060 XT (16188 MiB VRAM).main:
PR:
Not tested
Exactmatch on a 32-lane GPU: there is no 64-lane reference on the GPU yet; the interpreter covers the idiom's shape.AI use
🤖 Generated with Claude Code