Tests: generate RDNA2 programs for compile-time measurements (#1269) #1753
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by BetterJdue on 2026-11-24T20:22:28Z.
A 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
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T23:14:23Z.
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!
Imported from ivall/xcl. Originally posted by anes66 on 2026-11-25T00:26:57Z.
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.
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T02:03:22Z.
\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.Imported from ivall/xcl. Originally posted by BetterJdue on 2026-11-25T03:53:46Z.
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.
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-25T05:49:40Z.
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.
Imported from ivall/xcl. Originally posted by vakaobr on 2026-11-25T09:29:00Z.
@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.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T06:17:13Z.
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
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-26T08:46:01Z.
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
Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T15:18:34Z.
merge-check claim
head:
0f257d19e5Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T15:23:13Z.
merge-check
base:
9dfbe3ea66head:
0f257d19e5merge: clean (trial merge 0b9b76fbc61228231d8c20c08687488ef1dd6cec; git diff --check clean; +374/-0, two new files in crates/xcl/tests/compile_bench/)
build: cargo build --workspace -> ok (39 pre-existing warnings, none from the PR's files)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2894 passed, 1 failed, 51 ignored; SKIPPED: 27 (22 "no wave64" — wave32-only GPU, 2 "no heap windows", 1 "cannot disable the driver cache (Developer Mode)", 2 "no xgameruntime.dll"); failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, pre-existing on this machine (fails identically on base
9dfbe3ea, same "2D D16 resinfo clobbered v2/v3" assertion). All nine compile_bench tests pass: determinism per seed, knob-driven shape verified in the disassembly (op counts exact, if/loop nesting, every branch target checked, EXEC width per wave size, LDS/mem shares, VGPR pool), the two rejection should_panic tests, and 48 generated programs translating completely with structured on and off.review: read the whole diff. Test-only generator for the #1269 compile-time benchmark series: program(&Knobs) builds an RDNA2 instruction stream with the existing rdna2::encode (seeded splitmix64, same sequence on every platform), so no game data and CI-runnable. The tests do not trust the generator: they count and locate instructions in the disassembly and check each s_cbranch_execz lands on its EXEC restore and each s_cbranch_scc1 back on the instruction after its counter init. The head includes anes66's i16::try_from fix for loop bodies exceeding the SOPP signed 16-bit dword range (previously a silent wrap), with a fail->pass regression pair in the thread. No unsafe, no new dependencies, nothing in crates/xcl/src. #2100/#2106 are the stacked follow-ups of the same series; no duplicates.
performance: none; test-only, CPU-only (the programs are meant to be translated and compiled, not run).
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T15:29:24Z.
merge-check
base:
9dfbe3ea66head:
0f257d19e5merge: clean, alone and together with #2814 (
15e88d74, which touches other files,gpu/dxil/lower.rs,lower_valu.rs,round_tests.rs): both heads merged onto the base in one tree (052f736e) without conflictsbuild: cargo build --workspace -> ok on the combined tree
tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 on the combined tree of this head and #2814's head on the base (one suite run for the two PRs, not one per PR) -> 2895 passed, 1 failed, 51 ignored; SKIPPED: 24 lines, the same as on the base; failing:
gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails the same way on the base alone (2885 passed, 1 failed, 51 ignored; #3513 fixes it). The nine tests of the newcompile_benchtest binary all ran and passed, none skipped and none#[ignore]d: they are always on. They need no GPU: the programs go through the CPU translator (recomp::translate,compile_bench/main.rs:176) and are never run. Time: the binary finished in 0.43 s in the suite and in 0.43, 0.43 and 0.44 s in three more runs ofcargo test -p xcl --test compile_bench -- --test-threads=4on their own, all 9 passing each time; the suite's added cost is that plus building one more test binary.review: whole diff read (+374/-0, two new files under
crates/xcl/tests/compile_bench/, nothing incrates/xcl/src, no Cargo change: the directory is picked up as a test target by itsmain.rs). Deterministic by construction: every program comes fromKnobs.seedthrough a splitmix64 generator (gen.rs:58,gen.rs:174), with seed 1 by default (gen.rs:38) and seeds 0 to 47 inevery_program_translates_completely(main.rs:172); nothing reads the clock or an OS random source. Nothing is timed and no assertion depends on wall-clock time, so it cannot be flaky that way (the PR body says the DXC timing comes in a later PR; a timing assertion there would need care). The assertions are structural: same seed gives the same bytes and another seed other bytes, instruction counts and branch targets read back from the disassembly, the VGPR pool, LDS and memory shares within a tolerance (main.rs:152), twoshould_panicrefusals, and full translation of 48 programs with structured control flow on and off.performance: no smoke run: the PR adds only test files, and nothing in the emulator binary.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5 ran the build, suite and tests, reviewed the diff against the merged source and wrote this)
Edit (30 Nov, after thehollowedone's report below): the
lds_pct + mem_pctsum intests/compile_bench/gen.rs(lines 98 and 173) can overflow, but only with knobs far out of range, for exampleu32::MAXand 1. The literal values in this PR are 0, 5 and 10. A debug test build panics on the addition; a release test build wraps and the assert passes. The file is the test-only benchmark generator and no runtime code uses it, so my verdict stays. Achecked_addthere would be a good small follow-up.Imported from ivall/xcl. Originally posted by Pipodi on 2026-11-30T15:31:31Z.
merge-check claim
head:
0f257d19e5Imported from ivall/xcl. Originally posted by Pipodi on 2026-11-30T15:31:48Z.
Withdrawing my merge-check claim above: saintwolf and tiagonleal already hold the two slots on this head, and the queue table I worked from was older than their posts. Sorry for the noise.
AI use: Claude Code (Claude Opus 5.5) posted the claim and this note.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-30T16:48:46Z.
I found an input-validation overflow in the generator.
program()checkslds_pct + mem_pct <= 100usingu32addition. In release mode,u32::MAX + 1wraps to zero, so invalid knobs pass validation; the per-operation threshold wraps too. The candidate uses checked addition and adds tests for the boundary andprogram()itself.Tested locally: current
main9dfbe3eaplus the two test files from this PR head and this candidate.cargo test --offline --locked -p xcl --test compile_bench: 11 passed, 0 failed, 0 ignored. In release mode, the overflow regression passes with the fix; reverting only the checked guard makes it fail with “test did not panic as expected.” Windows 11 build 26300, Ryzen 7 9800X3D, rustc 1.99.1 MSVC; CPU-only. Full workspace and a clean PR merge were not run.Candidate fix and regression diff
AI use: OpenAI Codex (GPT-6.2 Sol) prepared and tested the candidate.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:42:14Z.
Triage (#1607) – head
0f257d1#2100 and #2106 contain this PR's two commits because they are stacked on it, by the same author. They are not duplicates: this is the base of the stack.
No problems found in the diff. The branch offsets of
s_cbranch_execzand of the backwards_cbranch_scc1and the loop counters check out.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.