Tests: generate RDNA2 programs for compile-time measurements (#1269) #1753

Open
BetterJdue wants to merge 2 commits from upstream-pr/1763 into main
BetterJdue commented 2026-11-24 20:22:28 +00:00 (Migrated from github.com)

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 in crates/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 with rdna2::encode from a seed and knobs: the number of operations, divergent ifs (v_cmp → s_and_saveexec → s_cbranch_execz) and how deep they nest, uniform loops (SGPR counter, backward s_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 the ifs 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

  • AMD Radeon RX 6700 (RDNA2), driver 32.0.21045.29003, Ryzen 5 3600, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug.
  • cargo test -p xcl --test compile_bench: 7 passed, 0 failed, 0 ignored.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on 5ae62c5: 755 passed, 3 failed, 41 ignored (20 binaries); no SKIPPED tests. The failures are placed_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 on main 930e8b4 too (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.
  • Negative control: 10 mutations of the generator (seed ignored, loops not nested, loop and execz branch offsets off by one, wrong EXEC width, if depth ignored, VGPR pool too large, LDS share ignored, operations miscounted, the operation-count check removed); each makes at least one test fail.

Regression run

  • Not needed: test-only change, nothing in crates/xcl/src.

Not tested

  • scripts/smoke.ps1 or any retail title (no game data here; the change does not touch the runtime).
  • NVIDIA, wave32-only GPUs; release build.

AI use

  • Claude Code with Claude Opus 5.5: wrote the generator, the tests and this description, and ran the tests on the machine above; reviewed by an independent Claude Code agent before posting.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5479708212 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763). Originally posted by [BetterJdue](https://github.com/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 in `crates/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 with `rdna2::encode` from a seed and knobs: the number of operations, divergent `if`s (`v_cmp` → `s_and_saveexec` → `s_cbranch_execz`) and how deep they nest, uniform loops (SGPR counter, backward `s_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 the `if`s 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** - AMD Radeon RX 6700 (RDNA2), driver 32.0.21045.29003, Ryzen 5 3600, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug. - `cargo test -p xcl --test compile_bench`: 7 passed, 0 failed, 0 ignored. - `cargo test --workspace --no-fail-fast -- --test-threads=4` on `5ae62c5`: 755 passed, 3 failed, 41 ignored (20 binaries); no SKIPPED tests. The failures are `placed_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 on `main` `930e8b4` too (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. - Negative control: 10 mutations of the generator (seed ignored, loops not nested, loop and `execz` branch offsets off by one, wrong EXEC width, `if` depth ignored, VGPR pool too large, LDS share ignored, operations miscounted, the operation-count check removed); each makes at least one test fail. **Regression run** - Not needed: test-only change, nothing in `crates/xcl/src`. **Not tested** - `scripts/smoke.ps1` or any retail title (no game data here; the change does not touch the runtime). - NVIDIA, wave32-only GPUs; release build. **AI use** - Claude Code with Claude Opus 5.5: wrote the generator, the tests and this description, and ran the tests on the machine above; reviewed by an independent Claude Code agent before posting. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DavidM1911 commented 2026-11-25 00:08:49 +00:00 (Migrated from github.com)

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 unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7147173636 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763#issuecomment-7147173636). Originally posted by [DavidM1911](https://github.com/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 unmodified `main`.) Thanks!
anes66 commented 2026-11-25 01:10:41 +00:00 (Migrated from github.com)

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_loop narrows the negative dword displacement with back 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_from before encoding, following the generator's existing panic-on-invalid-knobs contract. Two test files only; no runtime changes or competing PR.

Tested

  • Windows 10 Pro 19045, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, debug. CPU-only, no DXC or GPU execution.
  • The new rejection test uses 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 with loop body exceeds SOPP branch range.
  • A second test disassembles a representable 10000-operation program, verifies the backward branch lands immediately after its counter initialization, and checks operation count and loop shape.
  • 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 main 06c9f55 with #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:

  • 64 generated programs / 288 validated direct-DXIL variants: eight seeds, four 300-operation profiles (straight ALU, divergent branches, nested loops, mixed LDS/global memory), wave32/native wave64/split wave64, and plain/flat-compact/nested-compact emission. Three isolated children each validate 96 variants.
  • SDK disassembly verifies the requested forms. A representative wave32 case has no xcl_blocks table 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 two should_panic rejection tests pass as intended.
  • Negative control: asking the nested child for flat dispatch still validates its 96 containers but fails the parent with switch counts [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.

<!-- greyfinch-sync:ivall/xcl:comment:7148520759 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763#issuecomment-7148520759). Originally posted by [anes66](https://github.com/anes66) on 2026-11-25T00:26:57Z. --- Large loop bodies silently wrap their SOPP back edge on exact head `5ae62c52c218f2ee7ba36e18a83769b5d5ae13a9`. `nested_loop` narrows the negative dword displacement with `back as i16`, so benchmark knobs can produce a different control-flow graph instead of rejecting an unencodable loop. Patch: [0f257d1](https://github.com/anes66/xcl/commit/0f257d19e5b3950ebf00b61090ab78d25fc45ea4), directly on that head. It uses `i16::try_from` before encoding, following the generator's existing panic-on-invalid-knobs contract. Two test files only; no runtime changes or competing PR. **Tested** - Windows 10 Pro 19045, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, debug. CPU-only, no DXC or GPU execution. - The new rejection test uses `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 with `loop body exceeds SOPP branch range`. - A second test disassembles a representable 10000-operation program, verifies the backward branch lands immediately after its counter initialization, and checks operation count and loop shape. - `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 main `06c9f55` with #1906, #1860, the proposed #2076 rebase, #1972, #2322 and #2124. Test-only addition [0f733a4](https://github.com/anes66/xcl/commit/0f733a40b60b7d74bbee82be9d3bbab76c8c80f0) 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: - **64 generated programs / 288 validated direct-DXIL variants**: eight seeds, four 300-operation profiles (straight ALU, divergent branches, nested loops, mixed LDS/global memory), wave32/native wave64/split wave64, and plain/flat-compact/nested-compact emission. Three isolated children each validate 96 variants. - SDK disassembly verifies the requested forms. A representative wave32 case has no `xcl_blocks` table 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 two `should_panic` rejection tests pass as intended. - Negative control: asking the nested child for flat dispatch still validates its 96 containers but fails the parent with switch counts `[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.
raylitebull commented 2026-11-25 02:09:07 +00:00 (Migrated from github.com)

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 on
ested_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.

<!-- greyfinch-sync:ivall/xcl:comment:7150264613 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763#issuecomment-7150264613). Originally posted by [raylitebull](https://github.com/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 on \ ested_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 commented 2026-11-25 04:10:42 +00:00 (Migrated from github.com)

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 on 5ae62c5, 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 on main b9b6ea6) 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.
  • With back as i16 put back, oversized_loop_branches_are_refused fails; 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 5ae62c5 merged with main.

AI use: Claude Code (Claude Opus 5.5) ran these tests and wrote this comment.

AI-assisted verification using synthetic inputs.

<!-- greyfinch-sync:ivall/xcl:comment:7152339855 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763#issuecomment-7152339855). Originally posted by [BetterJdue](https://github.com/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 on `5ae62c5`, 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 on `main` `b9b6ea6`) 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. - With `back as i16` put back, `oversized_loop_branches_are_refused` fails; 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 `5ae62c5` merged with `main`. AI use: Claude Code (Claude Opus 5.5) ran these tests and wrote this comment. AI-assisted verification using synthetic inputs.
upipibi commented 2026-11-25 06:05:59 +00:00 (Migrated from github.com)

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_refused included).
  • cargo test -p xcl --lib -- --test-threads=4: 706 passed, 1 failed, 21 ignored. The failure is hle::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.

<!-- greyfinch-sync:ivall/xcl:comment:7154176319 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763#issuecomment-7154176319). Originally posted by [upipibi](https://github.com/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_refused` included). - `cargo test -p xcl --lib -- --test-threads=4`: 706 passed, 1 failed, 21 ignored. The failure is `hle::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 commented 2026-11-25 10:10:30 +00:00 (Migrated from github.com)

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_dword to lane * 4 + o1 and a later global_load_dword of lane * 4 + o2 by another lane, s_load_dword of addresses a vector store just wrote, and ds_read_b32 of 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):

  • global and scalar loads read only bytes 0..1024 (lane * 4 + offset ≤ 63 × 4 + 192 × 4 = 1020),
  • every global store writes the lane's own dword at byte 1024 + lane * 4,
  • the program starts with 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.

@@ pub struct Knobs {
     pub lds_pct: u32,
     pub mem_pct: u32,
+    /// programs whose result does not depend on the order lanes see each other's memory
+    /// accesses, for running and comparing them: global loads and scalar loads read only bytes
+    /// 0..1024, every global store writes the lane's own dword at byte 1024 + lane * 4, and the
+    /// lane's LDS dword is written before anything reads it
+    pub race_free: bool,
 }
@@ impl Default for Knobs {
-        Knobs { seed: 1, ops: 200, if_depth: 2, divergent_pct: 10, loops: 0, loop_depth: 1, loop_trips: 4, wave64: true, vgprs: 16, sgprs: 8, lds_pct: 5, mem_pct: 10 }
+        Knobs { seed: 1, ops: 200, if_depth: 2, divergent_pct: 10, loops: 0, loop_depth: 1, loop_trips: 4, wave64: true, vgprs: 16, sgprs: 8, lds_pct: 5, mem_pct: 10, race_free: false }
@@ fn op(&mut self) -> Vec<u8> {
-                0 => inst("GLOBAL_LOAD_DWORD", "ENC_FLAT_GLBL", &[("VDST", self.vgpr()), ("ADDR", 1), ("SADDR", 2), ("OFFSET", 4 * self.rng.below(256))], None),
-                1 => inst("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 1), ("DATA", self.vgpr()), ("SADDR", 2), ("OFFSET", 4 * self.rng.below(256))], None),
+                // race-free: lane * 4 + offset stays below byte 1024 (63 * 4 + 192 * 4 = 1020)
+                0 => inst("GLOBAL_LOAD_DWORD", "ENC_FLAT_GLBL", &[("VDST", self.vgpr()), ("ADDR", 1), ("SADDR", 2), ("OFFSET", 4 * self.rng.below(if self.k.race_free { 193 } else { 256 }))], None),
+                1 => {
+                    // the data register is drawn before the offset, as before, so programs without
+                    // race_free stay the same
+                    let data = self.vgpr();
+                    let offset = if self.k.race_free { 1024 } else { 4 * self.rng.below(256) };
+                    inst("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 1), ("DATA", data), ("SADDR", 2), ("OFFSET", offset)], None)
+                }
@@ pub fn program(k: &Knobs) -> Vec<u8> {
     let mut v = inst("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 130), ("VSRC1", 0)], None); // v1 = lane * 4
+    if k.race_free {
+        v.extend(inst("DS_WRITE_B32", "ENC_DS", &[("ADDR", 1), ("DATA0", 0)], None)); // the lane's LDS dword = lane id
+    }

It's commit 5fa8e36 on vakaobr/xcl tests/diff-harness, on top of your 5ae62c5 (kept as is; that branch is on main c4d37be). 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_bench with the knob in: 7 passed, 0 failed, on the Mac (M5 Pro, CrossOver 26.3 / D3DMetal, Rust 1.100.0 x86_64-pc-windows-gnu, debug). Not tested: Windows.

AI use: Claude Code (Claude Opus 5.5) wrote the knob and this comment.

<!-- greyfinch-sync:ivall/xcl:comment:7158391359 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763#issuecomment-7158391359). Originally posted by [vakaobr](https://github.com/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_dword` to `lane * 4 + o1` and a later `global_load_dword` of `lane * 4 + o2` by another lane, `s_load_dword` of addresses a vector store just wrote, and `ds_read_b32` of 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): - global and scalar loads read only bytes 0..1024 (`lane * 4 + offset` ≤ 63 × 4 + 192 × 4 = 1020), - every global store writes the lane's own dword at byte `1024 + lane * 4`, - the program starts with `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. ```diff @@ pub struct Knobs { pub lds_pct: u32, pub mem_pct: u32, + /// programs whose result does not depend on the order lanes see each other's memory + /// accesses, for running and comparing them: global loads and scalar loads read only bytes + /// 0..1024, every global store writes the lane's own dword at byte 1024 + lane * 4, and the + /// lane's LDS dword is written before anything reads it + pub race_free: bool, } @@ impl Default for Knobs { - Knobs { seed: 1, ops: 200, if_depth: 2, divergent_pct: 10, loops: 0, loop_depth: 1, loop_trips: 4, wave64: true, vgprs: 16, sgprs: 8, lds_pct: 5, mem_pct: 10 } + Knobs { seed: 1, ops: 200, if_depth: 2, divergent_pct: 10, loops: 0, loop_depth: 1, loop_trips: 4, wave64: true, vgprs: 16, sgprs: 8, lds_pct: 5, mem_pct: 10, race_free: false } @@ fn op(&mut self) -> Vec<u8> { - 0 => inst("GLOBAL_LOAD_DWORD", "ENC_FLAT_GLBL", &[("VDST", self.vgpr()), ("ADDR", 1), ("SADDR", 2), ("OFFSET", 4 * self.rng.below(256))], None), - 1 => inst("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 1), ("DATA", self.vgpr()), ("SADDR", 2), ("OFFSET", 4 * self.rng.below(256))], None), + // race-free: lane * 4 + offset stays below byte 1024 (63 * 4 + 192 * 4 = 1020) + 0 => inst("GLOBAL_LOAD_DWORD", "ENC_FLAT_GLBL", &[("VDST", self.vgpr()), ("ADDR", 1), ("SADDR", 2), ("OFFSET", 4 * self.rng.below(if self.k.race_free { 193 } else { 256 }))], None), + 1 => { + // the data register is drawn before the offset, as before, so programs without + // race_free stay the same + let data = self.vgpr(); + let offset = if self.k.race_free { 1024 } else { 4 * self.rng.below(256) }; + inst("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 1), ("DATA", data), ("SADDR", 2), ("OFFSET", offset)], None) + } @@ pub fn program(k: &Knobs) -> Vec<u8> { let mut v = inst("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 130), ("VSRC1", 0)], None); // v1 = lane * 4 + if k.race_free { + v.extend(inst("DS_WRITE_B32", "ENC_DS", &[("ADDR", 1), ("DATA0", 0)], None)); // the lane's LDS dword = lane id + } ``` It's commit `5fa8e36` on [`vakaobr/xcl` `tests/diff-harness`](https://github.com/vakaobr/xcl/tree/tests/diff-harness), on top of your `5ae62c5` (kept as is; that branch is on `main` `c4d37be`). 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_bench` with the knob in: 7 passed, 0 failed, on the Mac (M5 Pro, CrossOver 26.3 / D3DMetal, Rust 1.100.0 `x86_64-pc-windows-gnu`, debug). **Not tested:** Windows. AI use: Claude Code (Claude Opus 5.5) wrote the knob and this comment.
DavidM1911 commented 2026-11-26 07:03:31 +00:00 (Migrated from github.com)

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

<!-- greyfinch-sync:ivall/xcl:comment:7184279239 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763#issuecomment-7184279239). Originally posted by [DavidM1911](https://github.com/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
futurepro62 commented 2026-11-26 09:07:45 +00:00 (Migrated from github.com)

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 base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_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.
  • The new tests ran and passed: 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.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, 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.
  • --skip leaves out tests that fail on main b49be183 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (#1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7186992526 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763#issuecomment-7186992526). Originally posted by [futurepro62](https://github.com/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 base `930e8b4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_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`. - The new tests ran and passed: `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`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `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. - `--skip` leaves out tests that fail on main `b49be183` too, not because of this PR. On NVIDIA: `heap_window_out_of_memory_falls_back_to_the_switch_form` (#1651), the four `gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu` tests, `const_and_null_mask_operands_agree_with_hlsl_on_the_gpu` and `mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu` ([follow-up on #1651](https://github.com/xcl-dev/xcl/issues/1651#issuecomment-7146069648)) fail because `runner::skip_test` turns their skips into failures under `XCL_REQUIRE_GPU=mesh`, and `gpu::dxil::fuzz_tests` seeds 70, 545, 1019 and 1507 fail `CreateComputePipelineState` with `E_OUTOFMEMORY` on this card (drivers 616.64 and 621.40). On AMD: `fuzz_validate_and_gpu_1` fails on seed 540 (`res[833]` 0x7 vs CPU 0x6). The AMD run does not set `XCL_REQUIRE_GPU`. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
saintwolf commented 2026-11-30 15:18:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T15:18:34Z.


merge-check claim
head: 0f257d19e5

<!-- greyfinch-sync:ivall/xcl:comment:7282781782 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763#issuecomment-7282781782). Originally posted by [saintwolf](https://github.com/saintwolf) on 2026-11-30T15:18:34Z. --- merge-check claim head: 0f257d19e5b3950ebf00b61090ab78d25fc45ea4
saintwolf commented 2026-11-30 15:23:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T15:23:13Z.


merge-check
base: 9dfbe3ea66
head: 0f257d19e5
merge: 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

<!-- greyfinch-sync:ivall/xcl:comment:7282910182 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763#issuecomment-7282910182). Originally posted by [saintwolf](https://github.com/saintwolf) on 2026-11-30T15:23:13Z. --- merge-check base: 9dfbe3ea6653a9c76ef3ea0d66187a4b5407483b head: 0f257d19e5b3950ebf00b61090ab78d25fc45ea4 merge: 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
tiagonleal commented 2026-11-30 15:29:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T15:29:24Z.


merge-check
base: 9dfbe3ea66
head: 0f257d19e5
merge: 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 conflicts
build: 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 new compile_bench test 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 of cargo test -p xcl --test compile_bench -- --test-threads=4 on 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 in crates/xcl/src, no Cargo change: the directory is picked up as a test target by its main.rs). Deterministic by construction: every program comes from Knobs.seed through a splitmix64 generator (gen.rs:58, gen.rs:174), with seed 1 by default (gen.rs:38) and seeds 0 to 47 in every_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), two should_panic refusals, 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_pct sum in tests/compile_bench/gen.rs (lines 98 and 173) can overflow, but only with knobs far out of range, for example u32::MAX and 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. A checked_add there would be a good small follow-up.

  • Tiago
<!-- greyfinch-sync:ivall/xcl:comment:7283081626 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763#issuecomment-7283081626). Originally posted by [tiagonleal](https://github.com/tiagonleal) on 2026-11-30T15:29:24Z. --- merge-check base: 9dfbe3ea6653a9c76ef3ea0d66187a4b5407483b head: 0f257d19e5b3950ebf00b61090ab78d25fc45ea4 merge: 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 conflicts build: 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 new `compile_bench` test 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 of `cargo test -p xcl --test compile_bench -- --test-threads=4` on 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 in `crates/xcl/src`, no Cargo change: the directory is picked up as a test target by its `main.rs`). Deterministic by construction: every program comes from `Knobs.seed` through a splitmix64 generator (`gen.rs:58`, `gen.rs:174`), with seed 1 by default (`gen.rs:38`) and seeds 0 to 47 in `every_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`), two `should_panic` refusals, 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_pct` sum in `tests/compile_bench/gen.rs` (lines 98 and 173) can overflow, but only with knobs far out of range, for example `u32::MAX` and 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. A `checked_add` there would be a good small follow-up. - Tiago
Pipodi commented 2026-11-30 15:31:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Pipodi on 2026-11-30T15:31:31Z.


merge-check claim
head: 0f257d19e5

<!-- greyfinch-sync:ivall/xcl:comment:7283139239 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763#issuecomment-7283139239). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-11-30T15:31:31Z. --- merge-check claim head: 0f257d19e5b3950ebf00b61090ab78d25fc45ea4
Pipodi commented 2026-11-30 15:31:48 +00:00 (Migrated from github.com)

Imported 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.

<!-- greyfinch-sync:ivall/xcl:comment:7283146710 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763#issuecomment-7283146710). Originally posted by [Pipodi](https://github.com/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.
thehollowedone commented 2026-11-30 16:48:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-30T16:48:46Z.


I found an input-validation overflow in the generator. program() checks lds_pct + mem_pct <= 100 using u32 addition. In release mode, u32::MAX + 1 wraps to zero, so invalid knobs pass validation; the per-operation threshold wraps too. The candidate uses checked addition and adds tests for the boundary and program() itself.

Tested locally: current main 9dfbe3ea plus 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
diff --git a/crates/xcl/tests/compile_bench/gen.rs b/crates/xcl/tests/compile_bench/gen.rs
@@
 const V: u64 = 256;
 
+pub(super) fn valid_access_shares(lds_pct: u32, mem_pct: u32) -> bool {
+    lds_pct.checked_add(mem_pct).is_some_and(|sum| sum <= 100)
+}
+
 fn inst(name: &str, enc: &str, fields: &[(&str, u64)], lit: Option<u32>) -> Vec<u8> {
@@
-    assert!(k.lds_pct + k.mem_pct <= 100 && k.divergent_pct <= 100, "{k:?}");
+    assert!(valid_access_shares(k.lds_pct, k.mem_pct) && k.divergent_pct <= 100, "{k:?}");

diff --git a/crates/xcl/tests/compile_bench/main.rs b/crates/xcl/tests/compile_bench/main.rs
@@
+#[test]
+fn memory_access_shares_reject_overflow_and_out_of_range_sums() {
+    assert!(gen::valid_access_shares(60, 40));
+    assert!(!gen::valid_access_shares(60, 41));
+    assert!(!gen::valid_access_shares(u32::MAX, 1));
+}
+
+#[test]
+#[should_panic]
+fn program_rejects_overflowing_memory_access_shares() {
+    program(&Knobs { lds_pct: u32::MAX, mem_pct: 1, ..Knobs::default() });
+}

AI use: OpenAI Codex (GPT-6.2 Sol) prepared and tested the candidate.

<!-- greyfinch-sync:ivall/xcl:comment:7285266768 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763#issuecomment-7285266768). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-30T16:48:46Z. --- I found an input-validation overflow in the generator. `program()` checks `lds_pct + mem_pct <= 100` using `u32` addition. In release mode, `u32::MAX + 1` wraps to zero, so invalid knobs pass validation; the per-operation threshold wraps too. The candidate uses checked addition and adds tests for the boundary and `program()` itself. **Tested locally:** current `main` `9dfbe3ea` plus 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. <details> <summary>Candidate fix and regression diff</summary> ```diff diff --git a/crates/xcl/tests/compile_bench/gen.rs b/crates/xcl/tests/compile_bench/gen.rs @@ const V: u64 = 256; +pub(super) fn valid_access_shares(lds_pct: u32, mem_pct: u32) -> bool { + lds_pct.checked_add(mem_pct).is_some_and(|sum| sum <= 100) +} + fn inst(name: &str, enc: &str, fields: &[(&str, u64)], lit: Option<u32>) -> Vec<u8> { @@ - assert!(k.lds_pct + k.mem_pct <= 100 && k.divergent_pct <= 100, "{k:?}"); + assert!(valid_access_shares(k.lds_pct, k.mem_pct) && k.divergent_pct <= 100, "{k:?}"); diff --git a/crates/xcl/tests/compile_bench/main.rs b/crates/xcl/tests/compile_bench/main.rs @@ +#[test] +fn memory_access_shares_reject_overflow_and_out_of_range_sums() { + assert!(gen::valid_access_shares(60, 40)); + assert!(!gen::valid_access_shares(60, 41)); + assert!(!gen::valid_access_shares(u32::MAX, 1)); +} + +#[test] +#[should_panic] +fn program_rejects_overflowing_memory_access_shares() { + program(&Knobs { lds_pct: u32::MAX, mem_pct: 1, ..Knobs::default() }); +} ``` </details> AI use: OpenAI Codex (GPT-6.2 Sol) prepared and tested the candidate.
Foniass commented 2026-12-01 06:42:14 +00:00 (Migrated from github.com)

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_execz and of the backward s_cbranch_scc1 and 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.

<!-- greyfinch-sync:ivall/xcl:comment:7303175839 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1763#issuecomment-7303175839). Originally posted by [Foniass](https://github.com/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_execz` and of the backward `s_cbranch_scc1` and 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.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1763:upstream-pr/1763'
git switch 'upstream-pr/1763'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/1763'
git switch 'upstream-pr/1763'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1763'
git switch 'upstream-pr/1763'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1763'
git switch 'main'
git merge --squash 'upstream-pr/1763'
git switch 'main'
git merge --ff-only 'upstream-pr/1763'
git switch 'main'
git merge 'upstream-pr/1763'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1753
No description provided.