Repository navigation
Conversation
Structured code skips the code up to the target of a forward jump it cannot nest (loop breaks, jumps past a join, s_endpgm before the end) with a flag per target. Every guard tested each flag that could be set at that point: `if (!(xcl_skip_a || xcl_skip_b || ...))`, reopened with the whole set each time a jump was added or resolved. With many crossing jumps that is quadratic: one compute program of a retail pack had 12 804 guards of up to 10 700 characters, 100 MB of its 155 MB of HLSL. Nothing runs while a jump is pending, so no second one can be set: one `uint xcl_skip` (the pending target, 0xFFFFFFFF for none) holds them all and a guard is `xcl_skip == none`, plus the targets of jumps into the loop that follows, which run it. The reset at a target now comes before the guard of the jumps still pending, which would otherwise skip it. Retail pack (26 698 programs, 4 memory windows): that program 154.6 MB of HLSL -> 54.0 MB, the pack 10 759 MB -> 10 661 MB, all still translated. Assisted-by: Capy (Claude Opus 5.5) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
AMD run with 64-lane waves, which this PR lists as not tested, so the GPU part of Tested: pass, head
Not tested: DXC and driver build time of the 54 MB program; Intel; the whole workspace suite; a title. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report. |
Author
Contributor
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
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.
Structured code keeps a forward jump it cannot nest – a loop break, a jump past a join,
s_endpgmbefore the end – pending until its target, and every level skips its code meanwhile. Each target had its ownbool xcl_skip_<pc>, and every guard tested all the flags that could be set at that point:if (!(xcl_skip_a || xcl_skip_b || …)), written out again with the whole set each time a jump was added or reached. With many crossing jumps that is quadratic. In one retail compute program it is 12 804 guards of up to 10 700 characters: 100 MB of its 155 MB of HLSL.Nothing runs while a jump is pending, so no second one can be set. One
uint xcl_skip(the pending target,0xFFFFFFFFfor none) now holds them all, and a guard is one comparison. Part of #1269.What is in it
crates/xcl/src/gpu/recomp/mod.rs:xcl_skipreplaces the per-target flags. Each guard isxcl_skip == none, plus the targets of jumps into the loop that follows (those jumps run the loop). The reset at a target now comes before the guard of the jumps still pending, which would otherwise skip it.crates/xcl/src/gpu/recomp/tests.rs:crossing_jumps_keep_guards_small, 32 crossing jumps. Onmainthey translate to 1 085 uses ofxcl_skipand the test fails; with this change there are 156. The test runs the program on the GPU for six patterns of taken jumps and checks that each one skips exactly the blocks up to its target.Tested
cargo test --workspace -- --test-threads=4: 756 passed, 0 failed, 41 ignored (SKIPPED:gpu_wave32_program_in_wave64_hardware,gpu_geometry_wave32_prefix_count_over_a_mask, both "no wave64")mainthe new test fails (1 085 uses); with the change it passes, GPU part included.jumps_to_outer_loop_heads_are_structured, as wave32 programs (the test runs its GPU part only with wave64), ran on the GPU translated bymainand by this change, with the same register state in all 1 000.xcl shaders shaders.rpf --recompon a retail pack (26 698 programs,XCL_RECOMP_WINDOWS=4): all 26 698 still translated. The largest CS goes from 154.6 MB of HLSL to 54.0 MB, the pack from 10 759 MB to 10 661 MB, and the other programs barely change size (the next largest, 31.0 MB, by 60 bytes).Regression run
The PR's run came after main's, with the shader cache main's run had filled. That probably explains its higher frame count.
main:
PR:
Not tested
jumps_to_outer_loop_heads_are_structured(wave64 only) and any wave64 GPU: no AMD or Intel hardware.-O0.HANDOFF.md(line 1281) still describes thexcl_skip_<target>flags.AI use