Tests: generate RDNA2 programs for compile-time measurements (#1269) #1763
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1763
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1763"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@BetterJdue on GitHub · 2026-11-24 20:22 UTC · original
BetterJdue:compile-bench-gen→main· +374 −0 · 2 files · 2 commits · openA generator of deterministic RDNA2 programs for the synthetic compile-time benchmark of #1269: no game data, so it runs anywhere, CI included. Test-only: one commit in
crates/xcl/tests/compile_bench/, nothing incrates/xcl/src. Nothing is timed yet; the DXC measurement is the next PR, stacked on this one.Part of #1269
What is in it
crates/xcl/tests/compile_bench/gen.rs:program(&Knobs)assembles a program withrdna2::encodefrom a seed and knobs: the number of operations, divergentifs (v_cmp→s_and_saveexec→s_cbranch_execz) and how deep they nest, uniform loops (SGPR counter, backwards_cbranch_scc1) and how deep they nest, wave32 or wave64, the VGPR and SGPR pools, and the share of LDS and memory accesses. Knobs that would give more operations than asked for are refused.crates/xcl/tests/compile_bench/main.rs: 7 tests, CPU only. They check in the disassembly, not in the generator: the operation count, how deep theifs and loops nest, where every branch lands, the EXEC instructions of each wave size, the LDS and memory shares and the VGPR pool; 24 knob combinations translate completely with structured control flow on and off.Tested
cargo test -p xcl --test compile_bench: 7 passed, 0 failed, 0 ignored.cargo test --workspace --no-fail-fast -- --test-threads=4on5ae62c5: 755 passed, 3 failed, 41 ignored (20 binaries); no SKIPPED tests. The failures areplaced_title_textures_share_vram_and_preserve_pixels("3D 64x64x64 4 mips: subresource 2 mismatch") and two tests that then fail on the lock it poisons; the first fails alone onmain930e8b4too (4 of 4 runs). The same failure (same message, RDNA2, same driver) is reported fixed by #1028 on an RX 6600, RX 6750 XT and RX 6900 XT; #1028 was not run here.execzbranch offsets off by one, wrong EXEC width,ifdepth ignored, VGPR pool too large, LDS share ignored, operations miscounted, the operation-count check removed); each makes at least one test fail.Regression run
crates/xcl/src.Not tested
scripts/smoke.ps1or any retail title (no game data here; the change does not touch the runtime).AI use
🤖 Generated with Claude Code
@DavidM1911 on GitHub · 2026-11-24 23:14 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
@raylitebull on GitHub · 2026-11-25 02:03 UTC · original
\CI\ workflow approved for \
5ae62c5\ (\crates/xcl/tests/compile_bench/{gen.rs,main.rs}). Note @anes66's finding above onested_loop\ (\ack as i16\ silently wrapping if \ops\ is large enough to exceed SOPP's signed 16-bit dword range); using \i16::try_from\ + obtaining an independent NVIDIA check on \
5ae62c5\ (plus \Build and test\ green) will make this ready.@BetterJdue on GitHub · 2026-11-25 03:53 UTC · original
Thanks @anes66: your commit is pulled into this PR unchanged, so the head is now
0f257d1(a fast-forward on5ae62c5, author kept).Tested on
0f257d1: AMD Radeon RX 6700 (RDNA2), driver 32.0.21045.29003; Ryzen 5 3600; 32 GB RAM; Windows 11 Pro 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17; debug.cargo test --workspace --no-fail-fast -- --test-threads=4: 757 passed, 3 failed, 41 ignored, no SKIPPED. The 3 failures are the RDNA2 texture test (placed_title_textures_share_vram_and_preserve_pixels, "subresource 2 mismatch", also failing alone onmainb9b6ea6) and the two tests that fail on the lock it poisons; none is in this PR's files.cargo test -p xcl --test compile_bench: 9 passed, 0 failed.back as i16put back,oversized_loop_branches_are_refusedfails; with the fix it passes.An independent run on NVIDIA on the new head would still help: DavidM1911's RTX 3060 Ti report above was on
5ae62c5merged withmain.AI use: Claude Code (Claude Opus 5.5) ran these tests and wrote this comment.
AI-assisted verification using synthetic inputs.
@upipibi on GitHub · 2026-11-25 05:49 UTC · original
The independent NVIDIA run asked for above, on the new head
0f257d1: RTX 3070 (Ampere, driver 616.56), Windows 11, debug.cargo test -p xcl --test compile_bench: 9 passed, 0 failed (oversized_loop_branches_are_refusedincluded).cargo test -p xcl --lib -- --test-threads=4: 706 passed, 1 failed, 21 ignored. The failure ishle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime(0 samples played where 28679 were expected, xaudio2.rs:1611). That test waits a fixed time for audio playback, and the machine was under heavy parallel load during this run. This PR doesn't touch XAudio2. #1600 gives those voice tests a longer wait.Not run: the whole workspace.
AI-assisted (Claude Code). Synthetic tests only.
@vakaobr on GitHub · 2026-11-25 09:29 UTC · original
@BetterJdue one knob I needed for running the programs rather than only compiling them:
race_free. Suggesting it here so the harness keeps using this generator instead of a fork of it.Why. The programs let lanes race: a
global_store_dwordtolane * 4 + o1and a laterglobal_load_dwordoflane * 4 + o2by another lane,s_load_dwordof addresses a vector store just wrote, andds_read_b32of a lane's LDS dword before anything wrote it. On the console a wave runs those in program order; translated to one GPU thread per lane, D3D12 gives no such order. With data in memory, 59 of 1000 seeds gave different results on two runs of the HLSL path on D3DMetal, and 48 more differed between the HLSL path and #1426's direct path for the same reason. With the knob on: 1000 tested, 0 differences, 0 unstable (details on #1269).What it does (off by default):
lane * 4 + offset≤ 63 × 4 + 192 × 4 = 1020),1024 + lane * 4,ds_write_b32 v1, v0, so each lane's LDS dword is set before it is read.With the knob off the programs are byte for byte the same as
5ae62c5: the store still draws its data register before its offset, as the array literal did.It's commit
5fa8e36onvakaobr/xcltests/diff-harness, on top of your5ae62c5(kept as is; that branch is onmainc4d37be). Take it into #1763 if you agree, or I'll stack it as its own PR after #1763; either is fine with me.Tested:
cargo test -p xcl --test compile_benchwith the knob in: 7 passed, 0 failed, on the Mac (M5 Pro, CrossOver 26.3 / D3DMetal, Rust 1.100.0x86_64-pc-windows-gnu, debug). Not tested: Windows.AI use: Claude Code (Claude Opus 5.5) wrote the knob and this comment.
@anes66 on GitHub · 2026-11-25 00:26 UTC · original · edited 2026-11-25 15:37 UTC
Large loop bodies silently wrap their SOPP back edge on exact head
5ae62c52c218f2ee7ba36e18a83769b5d5ae13a9.nested_loopnarrows the negative dword displacement withback as i16, so benchmark knobs can produce a different control-flow graph instead of rejecting an unencodable loop.Patch: 0f257d1, directly on that head. It uses
i16::try_frombefore encoding, following the generator's existing panic-on-invalid-knobs contract. Two test files only; no runtime changes or competing PR.Tested
ops=100000, one loop, no divergent regions/LDS/memory operations. Before the check: 0 passed / 1 failed, because the generator did not reject the out-of-range branch. After: it rejects withloop body exceeds SOPP branch range.cargo test --locked -p xcl --test compile_bench -- --nocapture --test-threads=1: 9 passed / 0 failed / 0 ignored, no skips. This also runs the existing 24 knob combinations through both structured and unstructured CPU translation.Not tested
The full workspace/GPU suite, release, retail inputs, or integration onto newer main. Oversized loops are rejected rather than expanded into far jumps; the encoded loop range remains the ISA's signed 16-bit dword range.
AI use
Codex (GPT-6; exact variant unavailable) found the narrowing issue, wrote the check and regression tests, ran CPU validation and prepared this report.
CPU integration follow-up
The generator at
0f257d19e5b3950ebf00b61090ab78d25fc45ea4, including the accepted branch-range fix, was also checked in an integration tree based on main06c9f55with #1906, #1860, the proposed #2076 rebase, #1972, #2322 and #2124. Test-only addition 0f733a4 is on that integration tree, not directly on this PR's head.Windows 10 Pro 19045, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, debug, SDK DXC/DXIL 1.9.2602.17:
xcl_blockstable and 0 switches in plain form, the table and 1 switch flat, and the table and 8 switches nested. The parent requires a larger switch count for nested dispatch, so merely ignoring the mode is insufficient.cargo test --locked -p xcl --test compile_bench -j 2 -- --nocapture --test-threads=1: 10 passed / 0 failed / 0 ignored / 0 runtime skips, including the original nine generator tests. The twoshould_panicrejection tests pass as intended.[0, 1, 1]. Restored before the final passing run and commit.No GPU capability query, pipeline build or shader execution; these generated memory accesses were never run. Not tested: output parity, timings, release, full workspace suite, a title or this added matrix on the standalone old PR head. This checks compiler/validator coverage, not compilation-speed improvement.
github-bot referenced this pull request2026-11-26 06:18:31 +00:00
@DavidM1911 on GitHub · 2026-11-26 06:17 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
@futurepro62 on GitHub · 2026-11-26 08:46 UTC · original
NVIDIA and AMD full-suite run, to go with the reports above by anes66, upipibi, vakaobr, since none of them covers AMD. Tested exact head
0f257d19(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 760 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.same_knobs_and_seed_give_the_same_program,operations_and_control_flow_follow_the_knobs,knobs_with_fewer_operations_than_loop_levels_are_refused,wave_size_picks_the_exec_instructions,oversized_loop_branches_are_refused,large_representable_loop_still_targets_its_body,lds_and_memory_shares_follow_the_knobs,vgprs_stay_in_the_pool,every_program_translates_completely.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 760 passed, 0 failed, 41 ignored, no skips.--skipleaves out tests that fail on mainb49be183too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.