Repository navigation
Recompiler: scalars written behind a vote and read after it are partition-dependent (#336) - #528
emirduran707 wants to merge 3 commits into
Conversation
…-dev#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 (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 way the cut shows: wave-wide votes are taken per half, and lane counts, ranks, first-lane indices, masks used as numbers and other lanes' varying 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, follows values every lane has (compares, loads at such addresses) and masks that are all or none of the active lanes, and reports a tier (Exact / MayDiffer) and the reasons: - a tainted value reaching an export, a store, a branch or EXEC; - a vote (vccz/vccnz, execz/execnz, scc on a mask) unless its side taken with the mask empty is the join or ends the program writing nothing (a pixel shader's all-discarded way out), and, for a mask other than EXEC, the other side starts by narrowing EXEC to it – or the mask is all or none of the active lanes. Scalars defined behind a vote (the next part of xcl-dev#336) and exact idioms (waterfall loops) are not followed yet; unknown counts as MayDiffer. Over the 13 210 wave64 VS / PS of a retail shader pack (local run): 9 424 Exact (7 248 of 10 974 PS, 2 176 of 2 236 VS), at most 25 ms a program. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion-dependent (xcl-dev#336) A half whose mask is empty takes the other side of a vote (or skips its lane-masked side) and so never runs the scalar code the wave runs there. A scalar that code writes (SGPR, VCC, M0, SCC; not EXEC, which the join restores) and that is read after the sides join holds something else in that half. partition::classify now runs its data-flow pass twice: the first finds the votes – branches on a mask, unless every half has lanes and votes as the wave does (the launch EXEC, or a mask that is all or none of its lanes) – and the scalars written in the blocks each one decides (control dependence, nested branches included); the second marks those scalars stale where the vote's sides join. A stale value reaching an export, a store, a branch or EXEC is the new reason `stale-scalar`. Over the 13 210 wave64 VS / PS of a retail shader pack (local run): 8 767 Exact (was 9 424): 2 468 programs read such a scalar; at most 99 ms a program. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
towiice
left a comment
There was a problem hiding this comment.
Tested PR head 741efd7 on NVIDIA GeForce GTX 1650 SUPER (Turing / TU116, wave32, driver 610.88), Windows 11 build 10.0.26300 (26H2), Rust 1.100.0 (stable-x86_64-pc-windows-gnullvm), DXC v1.9.2609:
cargo test -p xcl --lib a_scalar_ -- --test-threads=4: 5 passed, 0 failed (0.01 s), includinggpu::recomp::partition::tests::a_scalar_written_behind_a_vote_and_read_after_the_join_may_differanda_scalar_behind_a_vote_every_half_takes_as_the_wave_is_exact.
Builds and passes cleanly on gnullvm.
|
NVIDIA test report for 741efd7 (this PR's head, #517 and #341 included). Tested
Not tested
AI use
|
|
Same harness as the #517 census, run again on this stack, so the numbers below are a Machine: Windows 11 Pro 26300, Ryzen 7 9700X (8C/16T), Rust 1.98.0
Your 8 767 / 6 620 / 2 147 and What the 657 cost, attributed. 447 of them (68.0 %) are gated by Order of the remaining parts of #336 is now measurable the same way (programs whose Cost: 65.2 s of classify time over the 13 210 programs, against 24.6 s and 26.8 s in Suite: Not tested (same as you): whether the flagged programs actually differ on a 32-lane No game data in this comment – only counts printed by the tool. AI use: written with Cline; the runs are from my machine. |
…tion-dependent (#336) From xcl-dev/xcl#528 by @emirduran707, squashed.
Stacked on #517 (which is stacked on #341); only the top commit (741efd7) belongs here. Part of #336.
A half whose mask is empty takes the other side of a vote (or skips its lane-masked side), so it never runs the scalar code the wave runs there. A scalar that code writes and that is read after the sides join holds something else in that half – one of the ways #517 left to follow. Classification only: nothing translates by it yet.
What is in it
gpu/recomp/partition.rs:classifyruns its data-flow pass twice. The first finds the votes – branches on a mask, unless every half has lanes and votes as the wave does (the launch EXEC, or a mask that is all or none of its lanes) – and the scalars written in the blocks each one decides (SGPRs, VCC, M0, SCC; not EXEC, which the join restores), fromcfg's control dependence with nested branches' blocks included. The second marks those scalars stale where the vote's sides join; a stale value reaching an export, a store, a branch or EXEC is the new reasonstale-scalar.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 741efd7: 700 passed, 0 failed, 41 ignored; noSKIPPEDlines.stale-scalarin 2 468 programs; no panic; at most 99 ms for one program (two passes; nothing calls this on a title's path yet).Regression run
Nothing in the runtime calls the new code, 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
AI use