Repository navigation
Conversation
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 #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>
…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>
Owner
Author
|
Upstream PR xcl-dev#953 was closed or merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on xcl-dev#517 (itself on #341); only the top commit (38992ed) belongs here. Part of #336.
xcl-dev#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. xcl-dev#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 xcl-dev#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
Mirror of xcl-dev#953 (auto-synced, do not edit).