Skip to content

Recompiler: skip split-wave64 v_readfirstlane_b32 exchanges for wave-uniform VGPRs - #1193

Open
zondy1i wants to merge 1 commit into
xcl-dev:mainfrom
zondy1i:recomp/x64-uniform-readfirstlane
Open

zondy1i wants to merge 1 commit into
xcl-dev:mainfrom
zondy1i:recomp/x64-uniform-readfirstlane

Conversation

@zondy1i

@zondy1i zondy1i commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

��Eliminates split-wave64 xcl_x_rla_uniform() (xcl_x_meet()) cross-half exchanges for v_readfirstlane_b32 when the source VGPR holds a wave-uniform value under guaranteed EXEC != 0.

Why

  • RDNA2 has no scalar floating-point or scalar integer-division instructions, so console shaders evaluate uniform float math and scalar udiv chains (v_cvt_f32_u32 �! v_rcp_iflag_f32 �! v_mul_legacy_f32 �! v_cvt_u32_f32) on VALU with scalar inputs and move the result back to an SGPR via v_readfirstlane_b32.
  • In split-wave64 (docs/wave64-on-wave32.md), every such v_readfirstlane_b32 currently emits xcl_x_rla_uniform() (a groupshared xcl_x_meet() barrier) even though every active lane computed the exact same scalar value.
  • When EXEC != 0 is statically guaranteed (so first_lane(exec) always selects an active lane, never falling back to inactive lane 0) and the source VGPR was produced in the same basic block (with unchanged EXEC) by a chain of plain, full-32-bit-overwrite, lane-independent VALU ops over uniform inputs, we capture each producer in that chain into an immutable scalar temporary (uint tN = ...;) evaluated from uniform operands. Both 32-lane halves compute the exact same tN even if one half has no active lanes (exec_lo == 0 or exec_hi == 0), and v_readfirstlane_b32 copies tN directly without xcl_x_meet().

What is in it

  • crates/xcl/src/gpu/recomp/x64_uniform.rs: forward must-analysis exec_nonzero() tracking non-zero 64-bit SGPR pairs (EXEC, saved EXEC via s_mov_b64 / s_*_saveexec_b64 / s_or_b64, s_cbranch_execz/execnz, saveexec + scc, LOOP_GUARD exits; bails out on unresolved indirect jumps; conservative entry_nonzero = false in kernel mode), in-block wave-uniform VALU chain analysis (analyze()), and 3 unit tests.
  • crates/xcl/src/gpu/recomp/mod.rs: run x64_uniform::analyze in split-wave64 mode for Kernel / Compute / Mesh.
  • crates/xcl/src/gpu/recomp/emit.rs: capture uniform temporaries only for PCs in x64_uniform.capture_pcs (zero extra locals elsewhere), substitute uniform VGPR inputs while evaluating captured producers, copy directly in v_readfirstlane_b32 for PCs in x64_uniform.rfl_pcs, and clear live temporaries on block boundaries / EXEC writes / VGPR overwrites.
  • crates/xcl/src/gpu/recomp/tests.rs: add GPU test gpu_split_wave64_uniform_readfirstlane verifying 0-exchange scalar udiv and float-add chains with only upper-half lane 40 active (exec_lo == 0, garbage in lower-half VGPRs) as well as the conservative EXEC == 0 fallback reading unmodified lane 0.

Measured impact (RTX 3060 Ti, split-wave64)

  • Across 10,490 translated wave64 compute/mesh programs from a retail shader corpus: xcl_x_rla_uniform() calls drop from 80,310 �! 64,658 (�"15,652 exchanges, �"19.5%).
  • Cold DXC (cs_6_6) and NVIDIA D3D12 PSO compile benchmarks on three retail compute shaders (before 47efa2e �! after 0d8bcd5):
    • Compute shader Implement XSystemGetDeviceType/PLS thunks and Opus audio carrier parsing #1: xcl_x_rla_uniform 57 �! 12 (�"78.9%), DXIL 57,328 �! 41,168 B (�"28.2%), DXC 347.8 �! 239.7 ms (�"31.1%), cold PSO 323.6 �! 218.7 ms (�"32.4%).
    • Compute shader #2 (3.1 MB HLSL): xcl_x_rla_uniform 505 �! 463 (�"8.3%), DXIL 1,200,072 �! 1,179,728 B (�"1.7%), DXC 26,612 �! 24,784 ms (�"6.9%), cold PSO 28,313 �! 29,146 ms (noise within 3%).
    • Compute shader XAudio2: real Opus decoder via Windows MSOpusDecoder MFT #3: xcl_x_rla_uniform 43 �! 13 (�"69.8%), DXIL 144,708 �! 133,000 B (�"8.1%), DXC 1,343 �! 1,148 ms (�"14.6%), cold PSO 1,859 �! 1,696 ms (�"8.8%).

Tested

  • Hardware: NVIDIA GeForce RTX 3060 Ti 8 GB (driver 32.0.16.2101), Ryzen 5 7500F, 64 GB RAM, Windows 11 Build 26300, DXC 1.9.2609.5, Rust 1.100.0 (x86_64-pc-windows-msvc), debug + release.
  • cargo test -p xcl --lib x64_uniform -- --test-threads=1: 3 passed, 0 failed.
  • cargo test -p xcl --lib gpu_split_wave64 -- --test-threads=1: 6 passed, 0 failed (including new gpu_split_wave64_uniform_readfirstlane).
  • cargo test --workspace -- --test-threads=1: 745 passed, 0 failed, 41 ignored (1 SKIPPED GPU test: gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64)).

Regression run

main:

xcl-smoke v1
commit: 80f4819098e921f2e1ab371144d4832f68ffedd6
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1622 (PresentX 1622)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16539 MB

PR:

xcl-smoke v1
commit: 5ae60ad0a9baefd8baa244f36f9e5712f83b37d4
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1652 (PresentX 1652)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15371 MB

Not tested

  • AMD native wave64 GPUs (x64_uniform only runs when split_wave64 is active on wave32-only GPUs or forced via XCL_SPLIT_WAVE64=1).
  • Linux / Wine.

AI use

  • Antigravity (Gemini 4 Carbon): scanned v_readfirstlane_b32 producers across the shader corpus, designed and implemented x64_uniform.rs + emitter integration, wrote unit and GPU tests, ran the DXC/PSO benchmarks, and drafted the PR description; all tests, benchmarks, and paired smoke runs were executed locally on the hardware above and the diff was reviewed line by line.

@Aniseto

Aniseto commented Nov 24, 2026

Copy link
Copy Markdown

Ran the new uniform tests on an NVIDIA Blackwell part at 0d8bcd5:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=nvidia cargo test -p xcl --lib x64_uniform -- --test-threads=1
3 passed; 0 failed; 0 ignored      (exit 0)

XCL_ADAPTER=nvidia cargo test -p xcl --lib gpu_split_wave64 -- --test-threads=1
6 passed; 0 failed; 0 ignored      (exit 0)

All six split-wave64 GPU tests pass here, including the new gpu_split_wave64_uniform_readfirstlane. This adapter has no native wave64, so the split form is the only path it runs. The author's run was an Ampere RTX 3060 Ti; this adds a Blackwell part with driver 32.0.16.2124 on Windows 11 build 26200.

Not tested: native wave64 (not available here), RDNA2/RDNA4 and Intel GPUs, Wine, release profile, retail titles.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash 1017 - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified.

@juniorteixeiradev

Copy link
Copy Markdown

Ran the PR on NVIDIA Ampere (wave32 only, so split wave64 is the path in use) at head 0d8bcd5, whose base is main 47efa2e.

Tested

  • Hardware: NVIDIA GeForce RTX 3070 Ti (Ampere, 8 GB), driver 610.88. CPU AMD Ryzen 5 5600G (its Radeon iGPU is also present; the tests used the NVIDIA adapter), 16 GB RAM.
  • Windows 11 Pro build 26200, Rust 1.100.0 stable MSVC, debug.
  • DXC 1.9.2602.17 from Windows SDK 10.0.26100.0.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 on this PR's head: 745 passed, 0 failed, 41 ignored.
  • The same command on main 47efa2e, same machine: 741 passed, 0 failed, 41 ignored. The 4 extra tests are this PR's, and nothing else changed.
  • SKIPPED on both, as expected on a wave32-only adapter:
    • gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
    • gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
  • This PR's tests all pass:
    • gpu::recomp::tests::gpu_split_wave64_uniform_readfirstlane. It ran on the GPU with --nocapture and DXC loaded, and it was not skipped.
    • gpu::recomp::x64_uniform::tests::scalar_div_chain_with_nonzero_exec_is_captured
    • gpu::recomp::x64_uniform::tests::cbranch_execz_and_saved_exec_restore_prove_exec_nonzero
    • gpu::recomp::x64_uniform::tests::non_uniform_exec_maybe_zero_and_loop_exit_stay_conservative

Not tested

  • No retail title and no scripts/smoke.ps1 run: no game files on this machine.
  • Release build.
  • No measurement of the exchanges or barriers saved.

AI use

  • Claude Code (Claude Opus 5.5) fetched the branch, ran the tests and drafted this comment. The counts come from the test logs of those runs.

@DavidM1911

Copy link
Copy Markdown
Contributor

Independent verification on current main 384f7f7 (branch already contains it — clean).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug; DXC 1.8.2502.11.

  • cargo test -p xcl --lib readfirstlane: 1 passed, 0 failed — gpu_split_wave64_uniform_readfirstlane on real hardware (the new x64_uniform analysis skips wave-uniform VGPR exchanges correctly).

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

@0xTehuti

Copy link
Copy Markdown

Test report on NVIDIA GeForce RTX 2070 SUPER (Turing, wave32)

Commit tested
0d8bcd58626ed825a860cc43664c238f00e02a0c (PR #1193 head)

Tested

  • Hardware:
    • GPU: NVIDIA GeForce RTX 2070 SUPER (Driver 595.79 / 32.0.15.9579, 7989 MiB VRAM)
    • CPU: Intel Core i7-10700K CPU @ 3.80GHz
    • OS: Windows 11 x64, Rust 1.99.0, DXC 1.8.2502.11
  • Commands run and results:
    • cargo test -p xcl --lib x64_uniform:
      3 passed; 0 failed; finished in 0.00s
    • cargo test -p xcl --lib gpu_split_wave64_uniform_readfirstlane:
      1 passed; 0 failed; finished in 0.29s
  • Findings:
    • Verified that skipping xcl_x_rla_uniform() cross-half exchanges for wave-uniform VGPRs in split-wave64 executes cleanly on native wave32 Turing hardware.
    • Confirmed that with only upper-half lane 40 active (exec_lo == 0, garbage in lower half), the scalar value is preserved accurately across both halves, and the conservative EXEC == 0 fallback reads unmodified lane 0 as expected.

Not tested

  • Retail title smoke run (retail game assets unset).
  • AMD native wave64 hardware (optimization applies to split-wave64).

AI use

  • Tool: Antigravity / T3 Code
  • Model: Gemini 3.8 Flash
  • Details: Checked out PR commit in isolated worktree, compiled with DXC, and verified unit and GPU split-wave64 tests on local hardware.

@JoaoPauluu

Copy link
Copy Markdown

A run on Linux with vkd3d-proton, where the shaders go through dxil-spirv to Vulkan instead of a Windows driver's DXIL compiler.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257 (DXIL → SPIR-V through dxil-spirv), DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. 0d8bcd5 as it is (based on 47efa2e), no uncommitted changes. The lib test binary runs under Wine, one test per process (--exact).
  • gpu::recomp::tests::gpu_split_wave64_uniform_readfirstlane: ok, no SKIPPED.
  • gpu::recomp::x64_uniform::tests::cbranch_execz_and_saved_exec_restore_prove_exec_nonzero: ok, no SKIPPED.
  • gpu::recomp::x64_uniform::tests::non_uniform_exec_maybe_zero_and_loop_exit_stay_conservative: ok, no SKIPPED.
  • gpu::recomp::x64_uniform::tests::scalar_div_chain_with_nonzero_exec_is_captured: ok, no SKIPPED.

Not tested

  • whether the new test fails without the fix on this stack; the rest of the suite on this head; native Windows; AMD / native wave64.

AI use

  • Claude Code (Claude Opus 5.5) built the head, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@SlopTart

Copy link
Copy Markdown

Counter-datapoint from the axis every report above skips: native wave64 hardware (AMD RDNA3) with the split path forced. All five runs so far are NVIDIA wave32 parts where split-wave64 emulation is the only path; here it has to coexist with real 64-lane waves, so I ran it with XCL_SPLIT_WAVE64=1.

Lane: main b8b1f49 + this PR's head 0d8bcd5 (merge f3cb238). Control: plain b8b1f49. Both XCL_SPLIT_WAVE64=1 --test-threads=1, same session, 3 reps each. Counts only:

  • Control (plain main): gpu_split_wave64_waves_diverge 3/3 ok, gpu_split_wave64_lane_local_masks 3/3 ok, gpu_split_wave64_local_and_exchanged_masks and masks_read_whole_after_partial_writes 3/3 FAILED (the documented split cluster on this rig, gpu_geometry_wave32_prefix_count_over_a_mask: flaky on AMD (load-sensitive) - NVIDIA wave32 rigs skip it, so AMD is the only place it runs #847).
  • PR lane: lane_local_masks still ok, but waves_diverge flips to 3/3 FAILED (signature: ds_bpermute assertion at group 0 thread 96, got 0 expected 65 - exchange value loss), and this PR's own new test gpu_split_wave64_uniform_readfirstlane fails 3/3. The new test passes its static check (the HLSL really does drop all but the definition of xcl_x_rla_uniform) and fails the GPU value check at tests.rs:5834: s6=613566656 expected~=613566720, so the uniform-skip path yields a 64-ulp-wrong readfirstlane result when only upper-half lane 40 is active. It also failed in a full-suite run on an earlier head of this PR.
  • One more angle: waves_diverge fails on this rig at 47efa2e (this PR's base; 3/3 red this morning and 3/3 red again this afternoon) but passes 3/3 on current main b8b1f49, and goes red again with this PR merged on top. So on RDNA3 this head re-introduces an exchange corruption current main does not have.

Net on this axis: strictly worse - two tests that pass on the control go red, none go green, and the PR's own test fails its numeric assert. Caveat kept honest: this rig's split cluster is finicky (#847), so single green runs prove nothing; the pattern above is consistent 3/3 both directions in one session. Happy to re-check a future head with the same 3x fix-vs-control combo.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

@zondy1i

zondy1i commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for testing the forced-split RDNA3/RADV path — super useful catch on the test assertion!

Regarding gpu_split_wave64_uniform_readfirstlane:
s6 = 613566656 vs expected = 613566720 is not a uniform-skip bug — it is a 1-ULP float32 rounding difference in hardware rcp(7.0f) where our test tolerance (<= 2) was too tight for AMD RDNA3:

  • The test computes (uint)(rcp(7.0f) * 4294967040.0f) (~6.135e8, exponent 2^29).
  • At 2^29, 1 single float32 ULP is 2^(29 - 23) = 64.
  • NVIDIA computes rcp(7.0f) as 0x3e124925 (613566720), whereas AMD hardware v_rcp_f32(7.0f) returns 0x3e124924 (1 ULP lower, legal per HLSL rcp), which scales to 613566720 - 64 = 613566656.
  • Notably, getting 613566656 instead of the 0xDEAD_0000 garbage preloaded in lane 0 confirms the upper-half-only (exec_lo == 0) uniform capture path computed and returned the exact RDNA3 scalar value without an exchange.

I pushed 7c16823 relaxing only that test's rcp assertion from <= 2 to <= 128 (2 float32 ULPs at 2^29), with no changes to the recompiler or analysis. Regarding waves_diverge, note that this PR's x64_uniform pass only touches v_readfirstlane_b32 and does not touch ds_bpermute or the exchange protocol (#847). If you re-run gpu_split_wave64_uniform_readfirstlane on 7c16823, it should now pass cleanly on RADV too!

AI use: Antigravity (Gemini 4 Neon) analyzed the float32 ULP arithmetic, pushed the 1-line test tolerance fix (7c16823), and helped draft this reply.

@mastrr9

mastrr9 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Verified head 7c16823287be1058d6cf89fe0603b9d5005b2f2a on Windows 11 / NVIDIA RTX 5080 (wave32 / split-wave64, DXC 1.9.2602.17, Rust MSVC, debug build, clean worktree):

  • cargo test -p xcl --lib -- gpu::recomp --test-threads=4: 192 passed, 0 failed, 18 ignored (0 new compiler warnings).

Not tested: AMD native wave64, full workspace, retail smoke (scripts/smoke.ps1).
AI use: T3 Code (Antigravity / Claude Sonnet 5.5) ran the build and tests on our RTX 5080 and drafted this report.

@Mykolas009

Copy link
Copy Markdown

Tested on NVIDIA Blackwell: head 7c16823 merged onto main 930e8b4 (clean merge, not pushed).

  • NVIDIA GeForce RTX 5060 8 GB (32-lane waves, so the split form), driver 610.88; Ryzen 5 7500F;
    Windows 11 Pro 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17.
  • cargo build --workspace + cargo test --workspace --no-fail-fast -- --test-threads=4 (debug):
    755 passed, 0 failed, 41 ignored (main alone: 751 / 0 / 41). SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask,
    gpu_wave32_program_in_wave64_hardware (no wave64). The 4 new tests pass.

Speed, since no report has timings yet. A local benchmark (not for a PR, built like bench_split_wave64:
2^18 threads, 32,768 loop iterations, GPU timestamps, median of 9, release), 2 runs each:

loop body main + #1193
v_cvt_f32_u32 of an SGPR, v_cvt_u32_f32, v_readfirstlane (uniform) 127.5–130.6 ms, 1 exchange 13.9–14.1 ms, 0 exchanges
v_readfirstlane of a lane value 127–129 ms 127–129 ms (kept, as it should be)
4 v_readfirstlane of lane values 513–517 ms 513–517 ms (kept)

About 9x faster in the uniform case, the same for 64- and 256-thread groups, and no change where the value is
not uniform. The wave64 output of every case is identical with and without the PR.

Not tested

  • Real shaders or a retail title. AMD. A negative control: with emit.rs from main the tree does not build
    (no field x64_uniform), so I did not separate it further; the benchmark shows the exchange removed.

AI use

  • Claude Code (Claude Opus 5.5) wrote the local benchmark, ran it and the tests, and drafted this; I checked the numbers.

@SlopTart

Copy link
Copy Markdown

AMD side of the new head 7c16823, and a correction to my earlier regression claim.

Same rig and forced split mode (XCL_SPLIT_WAVE64=1, native wave64 card forced to the split path, --test-threads=1):

  • My earlier report (head 0d8bcd5): this PR's own test failed 3/3 here and waves_diverge went red vs the control. Both are fixed now: gpu_split_wave64_uniform_readfirstlane passes 1/1 in forced mode, and gpu_split_wave64_waves_diverge passes with and without this PR. I withdraw the regression claim.
  • What is still broken is on main b7aa9f3b, not this PR: forced split mode on current main fails 3 of the renamed family:

Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile; control run taken in the same session at the same main tip. See my Linux rows in #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

@JJAutoCompare

Copy link
Copy Markdown

Tested

PR #1193 was open at 5ae60ad0a9baefd8baa244f36f9e5712f83b37d4 before and after the run. The detached checkout was clean at that SHA. The PR description includes NVIDIA results, and the discussion covers earlier NVIDIA and forced-split AMD runs. I found no equivalent same-head Intel Arc result in the PR discussion or issue #42.

STOR-WINLAB ran Windows 11 Enterprise Evaluation 25H2 x64 build 26200.9974, AMD Ryzen 7 3800X, and Intel Arc A770 driver 32.0.101.9175. Rust 1.100.0 (0ef1bc386 2026-11-09) targeted x86_64-pc-windows-msvc. DXC and DXIL were 1.9.2609.5 from %LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64.

cargo test --locked -p xcl --lib --no-run --message-format=json-render-diagnostics
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
    & 'L:/XclTooling/pr1975-b62e6e3/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe' `
        'gpu::recomp::tests::gpu_split_wave64_uniform_readfirstlane' --exact --test-threads=1 --nocapture
}

The prebuild ran outside the Arc mutex, with CARGO_TARGET_DIR=L:/XclTooling/pr1975-b62e6e3/target, private TEMP and TMP at L:/XclTooling/pr1193/temp, CARGO_BUILD_JOBS=2, CARGO_INCREMENTAL=0, and CARGO_PROFILE_DEV_DEBUG=CARGO_PROFILE_TEST_DEBUG=0 (both variables set individually). The target stayed exclusive through test exit. Process-scoped RemoteSigned allowed the trusted wrapper to run. The test used XCL_ADAPTER=A770, the DXC folder above via XCL_DXC_DIR, and XCL_REQUIRE_GPU=wave64. XCL_SPLIT_WAVE64 and XCL_DIRECT_DXIL were unset.

The executable SHA-256 was 1A18DA96CE234223C8CB000AF410EA2FD15DE937B44272102FD202A4C1D2FD13 both before waiting and after acquiring the mutex. The earlier same-host D3D12 capability log reports Arc A770 hardware waves of 8–32 lanes. The checked-in runner therefore selected stock split-wave64, compiled both synthetic kernels via HLSL/DXC, and dispatched them on D3D12.

1 passed, 0 failed, 0 ignored, 0 GPU skips, 1,082 filtered out, 0.31 s, wrapper exit 0. The build completed with two Rust deprecation warnings. PowerShell formatted the fixture's DXC version message as NativeCommandError because it came from stderr. The fixture completed successfully.

  • With only lane 40 active, the HLSL had zero xcl_x_rla_uniform calls. The GPU readback satisfied s6 within 128 of the scaled reciprocal reference and s7 == 3. Lane 40's v3 became 3, and inactive lane 0's v3 retained 0xBEEF0000.
  • With empty EXEC, the HLSL retained one exchange and the GPU readback satisfied s6 == 0x12345678, the value seeded in lane 0's v1.
  • The runner checks SGPR agreement between the two split halves on readback. The fixture reports assertions as a single test result and does not print the observed reciprocal value.

Not tested

Native wave64, forced split on a native-wave64 adapter, Direct DXIL, other GPUs, other fixtures, the full workspace suite, retail smoke, and performance.

AI use

T3 Code / Codex (gpt-6.2-sol) verified the PR and fixture, ran the focused test, checked the logs, and wrote this report.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@thehollowedone

Copy link
Copy Markdown
Contributor

Independent Windows run on 5ae60ad. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, DXC 1.8.2502.11, debug.

cargo build --offline --locked --workspace passed. cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture reported 1,106 passed, 0 failed, 46 ignored, with 24 runtime skips included in Cargo's pass count. The stock uniform readfirstlane test passed.

For a separate synthetic check, LLVM MC 23.1.6 assembled a gfx1030 kernel with a branch on empty EXEC and a uniform float-add and conversion feeding v_readfirstlane_b32. I fed its 24-byte .text directly to XCL's HLSL/DXC runner. The RTX matched 3 scalar results and all 192 lane values across lower-half-only, mixed-half and empty EXEC. The optimized HLSL emitted zero cross-half exchange calls. With the optimization disabled in the same scratch checkout, it emitted one exchange call and returned the same values.

XCL_REQUIRE_GPU=wave64 with cargo test --offline --locked -p xcl --lib gpu_split_wave64_llvm_uniform_mask_edges -- --nocapture --test-threads=1 passed 1/0/0 with zero fixture skips in each run. This covers HLSL split-wave64 on wave32 hardware. Retail, native wave64, Direct DXIL and performance were outside this check. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote the scratch fixture, ran the tests, and drafted this report.

@raylitebull

Copy link
Copy Markdown
Member

Diff review on 5ae60ad (x64_uniform.rs + emit.rs + tests.rs) looks clean, CI is green, and RTX 3060 Ti, RTX 3080 Ti, and Arc A770 checks all pass on 5ae60ad.

Only item remaining before merge is a quick XCL_SPLIT_WAVE64=1 AMD check (gpu_split_wave64_uniform_readfirstlane) on exact head 5ae60ad (the earlier RADV run was on pre-rebase 7c16823).

Osanchez pushed a commit to Osanchez/xcl that referenced this pull request Nov 25, 2026
Reading a diff is safe; building one is not. `cargo build` runs a pull
request's build.rs and procedural macros as the user, `cargo test` runs its
test code, and anything under scripts/ runs as the user during build, test
and the smoke run. So the decision to trust a branch has to be made before
the first build, not after it.

- scripts/dev/pr-gate.py classifies a pull request's changed files from the
  GitHub API only - no checkout, nothing executed - against eight high-risk
  buckets (build.rs, .github, .cargo, Cargo.toml/lock, scripts, generated
  tables, stubdb.toml, binaries) plus a short content scan of added lines for
  network fetches, base64/eval, process spawning, link-section tricks and
  credential access. Fail-closed: an API error exits 3, never 0. A CLEAR
  verdict writes a receipt keyed by the pull request's head commit, so a
  force-push has to pass the gate again.
- scripts/dev/merge-pr.py is the only sanctioned merge path: gate, require a
  receipt for that exact commit, fetch pull/<N>/head, verify what arrived is
  what was reviewed (the window a push could otherwise slip through), then
  merge --no-ff.
- scripts/dev/merge-guard.py, wired as a PreToolUse hook, refuses git merge,
  cherry-pick, pull without --ff-only, am, apply, revert and gh pr merge
  unless they go through the wrapper. Recovery and read-only forms stay
  allowed.
- .githooks/pre-merge-commit backstops a merge made by hand, allowing commits
  already in our own history through.

Verified on xcl-dev#1193 (clean: exit 0, fetch matched the reviewed
commit), xcl-dev#282 (scripts/ touched: exit 2, nothing fetched), and xcl-dev#282 with
--ack (exit 0, acknowledgement recorded in the receipt). merge-guard decided
13 command forms correctly. pre-merge-commit tested in a throwaway repo for
own-history, no-receipt and receipted cases.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018RbZXznytQeB5KoWdhtdy5
@oni-swr

oni-swr commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Test report: Windows AMD RX 7800 XT, forced split wave64, exact head 5ae60ad

Commit tested: 5ae60ad0a9baefd8baa244f36f9e5712f83b37d4 (PR head, detached clean checkout). Control: exact parent 8f5fca5bb9ad6e695093d75294ad2cec023bba60.

Hardware / toolchain: AMD Radeon RX 7800 XT (RDNA3, physical; driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 Pro build 26200, Rust 1.100.0 MSVC, debug, DXC from Windows Kits 10.0.26100.0.

Adapter and path: a temporary probe test (not committed, removed afterwards) printed adapter=AMD Radeon RX 7800 XT wave64=true wave32=true. With XCL_SPLIT_WAVE64=1 it showed split_wave64_forced()=true runner::split_wave64()=true, and with the variable unset false/false. So the HLSL exchange-count assertions in the new test were active in the forced runs.

Head 5ae60ad, XCL_SPLIT_WAVE64=1

  • cargo test -p xcl --lib -j 4 -- x64_uniform gpu_split_wave64 readfirstlane gpu_bench_really_runs --test-threads=1: 11 passed, 0 failed, 0 ignored. Coverage:
    • gpu_split_wave64_uniform_readfirstlane: the uniform chains under a proven non-zero EXEC with only lane 40 active (exec_lo == 0), and the EXEC-may-be-0 case.
    • Divergent / read-first-lane: gpu_split_wave64_cross_half_operations, _waves_diverge, _local_and_exchanged_masks_in_diverging_waves.
    • _lane_local_masks, _masks_read_whole_after_partial_writes, _reduction_tails.
    • The 3 x64_uniform unit tests.
  • gpu_split_wave64_uniform_readfirstlane alone, run 5 times: 5/5 passed.
  • cargo test -p xcl --lib -j 4 -- gpu::recomp --test-threads=4: 345 passed, 0 failed, 19 ignored.

Head 5ae60ad, native wave64 (variable unset): -- gpu_split_wave64 x64_uniform --test-threads=1: 10 passed, 0 failed, 0 ignored.

Exact parent 8f5fca5, XCL_SPLIT_WAVE64=1

  • Same focused filter: 6 passed, 0 failed (all 6 existing gpu_split_wave64_* tests).
  • -- gpu::recomp --test-threads=4: 341 passed, 0 failed, 19 ignored. The 4 tests the head adds account for the difference.
  • I also copied the PR's new test unchanged into the parent as a temporary control:
    • It fails at only definition, 0 calls with left: 3, right: 1: the parent emits 2 xcl_x_rla_uniform exchanges where the head emits none.
    • With that count assertion turned into a print, every GPU value assertion passes on the parent: s6, s7 == 3, lane 40 / lane 0 v3, and EXEC == 0 reading the old lane 0 (whose "definition + 1 exchange kept" count also holds).
    • So on this card the head drops the exchanges and returns the same values as the parent.
    • The copied test passes on the parent with the variable unset (count assertions inactive).

SKIPPED: none from the filtered tests. The gpu::recomp runs print 6 SKIPPED sub-case lines inside the passing lower_dxil::tests::f16_programs_on_the_gpu and f32_programs_on_the_gpu: per-lane form refusals of V_MUL_F16, V_PK_MUL_F16 and V_CVT_F16_F32. Head and parent print the same lines.

Not tested: the whole workspace suite, NVIDIA / Intel, RDNA2 / RDNA4, release builds, a retail title or scripts/smoke.ps1.

AI use: Claude Code (Claude Opus 5.5) ran the commands on this machine and wrote this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

@Prime1997 Prime1997 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs changes: exhausted shared loop budget can produce a false EXEC-nonzero proof. Exact PR head 5ae60ad0a9baefd8baa244f36f9e5712f83b37d4.

The runtime loop guard runs before a loop's first instruction, and its budget is shared across loops. x64_uniform::exec_nonzero adds guard-exit edges using only post-instruction facts. If an earlier loop exhausts the budget, a later loop beginning with s_mov_b64 exec, -1 is skipped. The analysis nevertheless propagates that nonzero EXEC fact past the second loop. A following predicated VGPR move must preserve the old value with EXEC zero, while the optimized readfirstlane can return its unconditional captured scalar instead.

Measured CPU regression: an isolated checkout with production code unchanged and one seven-instruction analysis fixture added produced 0 passed, 1 failed, 0 ignored, 0 skipped, at the false nonzero proof. The positive nonzero control ran before that assertion. Test-only source patch SHA-256: 642ab6d8895c86a270727dfb0f565707565204e1e7a5a0f898e6a61787db2a52.

A separate, uncommitted local repair makes guard-exit facts conservative over both pre- and post-instruction states, including the SCC relation. The identical regression plus all three original CPU analysis fixtures produced 4 passed, 0 failed, 0 ignored, 0 skipped. Repair source patch SHA-256: c51b1a9f9ad4547389f675ba3962945fab021d869d403ebdf5e4e1b55381d5fc. This repair is local and has not been pushed into the PR.

Exact filters:

  • gpu::recomp::x64_uniform::tests::exhausted_shared_loop_budget_does_not_prove_exec_nonzero
  • gpu::recomp::x64_uniform::tests::scalar_div_chain_with_nonzero_exec_is_captured
  • gpu::recomp::x64_uniform::tests::cbranch_execz_and_saved_exec_restore_prove_exec_nonzero
  • gpu::recomp::x64_uniform::tests::non_uniform_exec_maybe_zero_and_loop_exit_stay_conservative

Build each isolated worktree: cargo test --locked --offline -p xcl --lib --no-run --message-format=json --target-dir <isolated-target>. Run each filter in a fresh process: <test-exe> <exact-filter> --exact --test-threads=1 --nocapture. Windows 11 Pro26200, i5-10400, 32GiB, Rust1.100.0 MSVC debug; private paths are placeholders.

Not tested: no shader loop was dispatched, no DXC/device call occurs in these finite analysis fixtures, and no GPU/title correctness or whole-suite result is claimed. Latest main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 has the same shared guard but not this optimization; the local repair was tested on the PR head, not a rebased integration. Source locations: x64_uniform.rs:115–120,147–149; mod.rs:638,1017,1138; emit.rs:6077.

AI use: Codex (GPT-6) reviewed the source and checked the stated evidence. Optional temporary Discord for coordinating contributor work, testing and comparing results.

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 5ae60ad

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 753e8b1
head: 5ae60ad
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1516 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1512 passed, 0 failed, 47 ignored
review: one thing to fix before merging: the new file gpu/recomp/x64_uniform.rs is not added to TRANSLATOR_SOURCES in crates/xcl/build.rs (the list has x64_masks.rs; the diff does not touch build.rs), so a later edit to that file alone would keep serving stale cached translations. One line. Minor: exec_nonzero takes the entry state for instruction 0 even when a branch jumps back to it. Checked and fine: every listed op reaches the final register write; the emission blocks never split a chain the analysis assumed whole; wherever the analysis kills a register the reuse is off; an empty EXEC in one half is safe because the temporary is computed from scalar registers and constants in both halves. For whoever merges: textual conflict with #944 (tests inserted at the same place) and with #2781 (struct fields in emit.rs); with #944 merged, a readfirstlane inside a batch skips this PR's shortcut (still correct, part of the saving is lost).
performance: fewer exchanges; every tester re-translates once (reasoned).
verdict: not yet: add the new file to TRANSLATOR_SOURCES; I will rerun on the new head.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 5ae60ad

#900 also targets split wave64, but it makes the half / console wave / other-half size wave-uniform through WaveReadLaneFirst at entry; this PR instead skips the v_readfirstlane_b32 exchange for VGPR chains computed from uniform operands. #944 / #2343 batch exchanges rather than remove them. None makes the same change, and main has no x64_uniform analysis.
No concrete problems found in the diff. The analysis treats VCC / EXEC SGPR operands (106/107, 126/127) as wave-uniform sources; in the split form a mask that is only read lane by lane stays half-local (mask_whole_live), so a producer reading vcc_lo as a scalar operand would be worth a test.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.