Repository navigation
Recompiler: a per-lane form for the direct DXIL backend (XCL_PER_LANE) - #1745
Conversation
|
DXC and cold driver times for the per-lane form against #1426 and the HLSL path, NVIDIA Windows (as asked on #1269, comment). Counts and timings only. Setup: RTX 4090 24 GB, driver 617.14, Windows 11, DXC 1.8.2502.11, release. Programs: the per-lane form takes 311 of 2 689 compute programs in the split form. 310 built in all four forms, 0 failures (first row dropped as driver warm-up). Median 212 B of console code, largest 2.6 KB.
Harness: AI use: Claude Code (Claude Opus 5.5) wrote the harness, ran the measurements and drafted this. |
|
@gefydev: the stale-value work is ready as a follow-up on this PR's head, not for #1745 itself. It is four commits on 43cb32c in Kalmarv/xcl
Recount:
The stale rule takes 114 more programs (321 to 435). Case A takes none in this sweep; it only renames 11 of the 151. Whatever the remaining stale values hit, it is not the single-write join that case A repairs. I'm classifying the 140 next (loops that lanes leave one by one, reads inside a region, or joins it skips) to decide what comes next. In a 60 s game run on 43cb32c, the stale value was the top fallback reason too: 17 of 73. Tested on an RTX 5070 Ti (wave32 only) under Windows 11, release builds:
The quadratic Not tested: the whole workspace suite, AMD, native wave64, a game run with these commits. AI use: Claude Code (Claude Opus 5.5) wrote the commits, ran the tests and the recount, and wrote this note. |
|
A fact about the follow-up, not a change to this PR. @Kalmarv has the stale-value work ready as a follow-up on top of this PR's head: four commits on AI use: Claude Code (Claude Opus 5.5) wrote this comment for @gefydev. |
|
Test report on NVIDIA GeForce RTX 5070 (12 GB)
|
|
@gefydev native wave64 and title results on AMD RDNA4 for Tested
Title A/B (retail title;
Top per-lane refusals in B (count of programs): "a value written while some lanes were elsewhere, read after they met again" 55, So on this card the per-lane form is correct on what it takes, and neutral on cost. The programs the world load waits on ( Not tested
AI use: Claude Code (Claude Opus 5.5) ran the tests and the two runs, matched the programs with a script and wrote this comment. |
|
Thank you both for the test reports on this PR.
AI use: Claude Code (Claude Opus 5.5) wrote this comment for @gefydev. |
|
Test report for Tested
Not tested
The VS / PS adapter half, which the description lists as missing: AI use: Claude Code (Claude Opus 5.5) ran the tests, rebased the commit and drafted this report. |
|
@teidenzero thank you: the report on AI use: Claude Code (Claude Opus 5.5) wrote this comment for @gefydev. |
|
Test report and review, on an RTX 5070 Ti (32-lane waves only). The suite passes on Tested
the 22 lines
This PR (
Review (the per-lane parts; line numbers at
In each of the first five rows the two paths differ in all of lanes 16–31 and agree in lanes 0–15 (the HLSL path has the same
The f16 side (
The three local tests behind this (split-form programs, the branch programs, the rounding programs; they print, they don't assert) are about 230 lines on Not tested
AI use: Claude Code (Claude Fable 5.2) ran the tests, read the diff and drafted this. Claude Code (Claude Opus 5.5) reviewed it before posting. |
|
Test report for #1745 on native wave64 (AMD RDNA3). The second part is with #1742 merged in, to check that the Tested
Not tested
AI use: Claude Code (Claude Opus 5.5) ran these tests on @oni-swr's machine and wrote this report. |
AI use: Claude Code (Claude Opus 5.5) wrote this comment for @gefydev. |
Diskuss
left a comment
There was a problem hiding this comment.
Tested on AMD Radeon RX 9070 XT (RDNA4, native wave64) at cf29f8a6a7e4e64cfaf17dd929e5334a7d5cf193, merged locally with main 4178e88
RX 9070 XT, driver 32.0.32015.7029; Ryzen 7 5700X3D; 32 GB RAM; Windows 11 Pro 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17; debug build.
Tested
- The head is 15 commits behind
main. The merge has one conflict, ingpu/dxil/kernel.rs, with #1748 (0b64aa0). #1748 added three fields to theLwliteral intranslate_on_this_thread, and this PR moves that literal intoLw::new. I resolved it locally by keepingLw::newand addingfmt_desc_cache: HashMap::new(),fmt_comp1_cache: HashMap::new()anduma_base_val: Noneto it. Everything below ran on that merge. It was not pushed. cargo test --workspace --no-fail-fast -- --test-threads=4:- PR +
main: 953 passed, 0 failed, 42 ignored main4178e88alone: 891 passed, 0 failed, 42 ignored- The +62 are this PR's tests. The lib goes from 864 to 926 tests.
- PR +
- SKIPPED, 8 lines:
- The 6 intentional per-lane refusals:
V_MUL_F16,V_PK_MUL_F16andV_CVT_F16_F32, each in wave32 and wave64. heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).pso_measurement_compiles_an_exact_synthetic_record(Developer Mode off).- On
main, only the last two skip. There are nono wave64skips, so every wave64 half ran natively. No device removal in any run.
- The 6 intentional per-lane refusals:
- The PR's tests, run 3 times by name (
recomp::lane_masks,recomp::lower(which includeslower_dxil),recomp::ssa,recomp::dxil::assemble,batched_replacements_match_one_at_a_time,--test-threads=1): 62 passed, 0 failed, 3 of 3 runs, with the same SKIPPED lines each time.f32_programs_on_the_gpupasses in both wave32 and native wave64, including the bit-exact-0in v10 under-Gis. That was the RDNA4 failure before 9109710.a_per_lane_program_with_four_memory_windows_runs_on_the_gpupasses with #1748's entry-blockuma_basehoist merged in. The per-lane form leavesBlock(0)without a terminator untilDxilIr::finish, and the hoist into it works.
Review (AMD-relevant semantics only; I did not repeat @Kalmarv's three points)
- Merge conflict with
main(above). This blocks CONTRIBUTING item 6. The rebase fix is the three-field addition toLw::new; nothing else conflicts.TRANSLATOR_VERSIONcomes in frommainas 6. The per-lane cache identity is derived from it (identity_for(.., "xcl-per-lane")), so it is invalidated too. - Sign of zero, denorms and fast-math: the per-lane lowering emits no float instructions of its own. Floats go through
Ir::foreignto #1426'sLw, so they take #1426's fast-math flags and denorm handling unchanged, and nothing AMD-specific is added. The other HLSL-reference comparisons (lower.rsagrees_with_hlsland related,coalesced_foreign_runs_agree_on_the_gpu,COALESCED_F32_RUN) still compile without-Gisand compare bit for bit. Their inputs produce no signed zero, though, and all pass here, so no change is needed today. This is only the place to look if a new float program is added to them. - wave32 / wave64 and EXEC: I read
lower/wave.rs, i.e.mask_words,exec_words,read_fromand thewave64 == falseupper word set to 0. It matches the module doc. The whole-wave forms refuse inpartialblocks, and a read of a lane outside EXEC returns this lane's own value, so it never usesWaveReadLaneAton an inactive lane, which is undefined on AMD. Native wave64 runs of the cross-lane, coalesced, 2-D / 3-D and split tests all pass here. - No other issues found that I could tie to a failing case on this card.
Not tested
- A retail title with
XCL_PER_LANE=1orscripts/smoke.ps1(no game files here). - A release build, and the pack sweep.
Review and test run by Claude Code (Claude Opus 5.5) on Diskuss's machine.
…odes it drops Two correctness gaps on programs the per-lane form took, found by Kalmarv's review of xcl-dev#1745 with GPU programs against the HLSL path: - A branch on whether any lane of a mask is set (`s_cbranch_vccz` / `vccnz`, `s_cbranch_scc*` after a mask op or `s_cmp_lg` of a mask) and a scalar read of such an SCC (`s_cselect`, `s_cmov`, `s_addc`, `s_subb`) decide for the whole wave on the console. The analysis took each lane's own bit, which differs in the lanes in EXEC that lack the bit (VCC = lanes 0-15, EXEC = all 32: 7 where the console gives 0). They are now taken only where the condition is the same in every lane that reaches with its EXEC bit (`s_and_saveexec` then `s_cbranch_execz`, or VCC equal to EXEC), and refused otherwise. The analysis test that stated the old assumption (a vccz branch is a lane branch) now states the rule. - `s_setreg` of MODE was a no-op, so a non-default rounding mode was dropped where xcl-dev#1426 and the HLSL path refuse the program. MODE writes now go to xcl-dev#1426's lowering, and the adapter sets `dyn_rm` / `has_f64_round_op` as xcl-dev#1426's translator does, so `s_round_mode` and `s_setreg` refuse what they cannot honour. Denormal-only writes are still taken. Tests: Kalmarv's five branch / select programs are refused, and a uniform one is taken; f32 by `s_setreg` and f64 by `s_round_mode` / `s_setreg` are refused (the f32 one was taken before the fix), and a denormal-only write is taken.
|
Review of #1745 at Correctness of the per-lane form
Runtime and caching
Tests
CONTRIBUTING
Nits
Checked and fine
AI use: Claude Code. Three Claude Opus 5.5 subagents reviewed the three parts. Claude Opus 5.5 (the main session) then read the code path of every numbered point itself, at |
|
Test report on NVIDIA GeForce RTX 5070 (12 GB)
|
|
Test report for the head Tested
Not tested: native wave64; a title run with AI use: Claude Code (Claude Opus 5.5) ran the suite and wrote this report. |
|
Retest on Confirmed the loop SCC fix on the same RTX 3080 Ti setup. The per-lane compiler now refuses the original loop at the scalar select. I dispatched the same shader separately through per-instruction direct DXIL and HLSL. Each returned Using Tested On Initialize s_mov_b32 s4, 2
v_cmp_gt_u32 vcc_lo, 16, v0
s_cmp_gt_u32 1, 0
loop:
s_cselect_b32 s1, 5, 7
v_mov_b32 v1, s1
s_sub_u32 s4, s4, 1
s_cmp_eq_u32 s4, 0
s_cbranch_scc1 done
s_and_b32 s0, vcc_lo, exec_lo
s_branch loop
done:
s_endpgmRTX 3080 Ti / 621.35, Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC debug, DXC 1.8.2502.11. Not tested This fixture covers wave32 kernel lowering. Retail behavior, native wave64 and runtime fallback were outside the run. AI-assisted. Codex (GPT-6 family, exact variant unavailable) wrote and ran the fixture and drafted this report. |
|
@thehollowedone thank you for the fixture and the readbacks on AI use: Claude Code (Claude Opus 5.5) wrote this comment for @gefydev. |
RX 7800 XT review of #1745I reviewed the shader sweep's validation and size reporting and ran the tests below on clean head Review findings
TestedRX 7800 XT (RDNA3), driver
Both runs logged the six documented f16 cases (arithmetic, packed multiply and conversion on wave32 and wave64). The full suite also skipped Not testedRetail startup on this PR, a release shader sweep, the whole-pack size result, compile speed, or opt-in game-data tests ( AI useCodex (GPT-6.2-sol) reviewed the relevant code, ran the tests on this PC, and drafted this report from the results. |
|
@moombathepilot thank you for the RX 7800 XT report on AI use: Claude Code (Claude Opus 5.5) wrote this comment for @gefydev. |
|
RTX 5070 Ti / Proton — per-lane retail run on With The earlier 150 s run on Tested
150 s smoke on The Wine smoke script generated the block. I abbreviated the local folder name in AI use — OpenAI Codex (GPT-6, exact variant unavailable) built and ran the checks, verified the logs, and drafted this report. |
A backend that writes DXIL itself keeps the console CFG, so each lane can branch on its own EXEC bit instead of every vector write being guarded and branchy programs going through the `pc` dispatcher. This is the analysis it needs: every lane mask is followed as a per-lane boolean function (a BDD over the lanes' compare / carry results, uniform SCCs and unresolved joins), mask branches are taken lane by lane, and a forward dataflow gives what holds in each lane reaching a block. A vector instruction keeps its guard only where reaching it does not imply the lane's EXEC bit. Loop heads are guessed from their forward edges and checked against the back edges; a wrong guess becomes an atom and only that head recomputes. Results too large for a per-step node budget are weakened to atoms, which only costs precision. Indirect jumps and irreducible loops are refused. Nothing translates with it yet: `xcl shaders --recomp` prints its counts. On the retail pack: 25 695 of 26 698 programs analysed (983 indirect jumps, 20 irreducible), 10.65 M of 28.71 M vector instructions still guarded (37.1 %), 9 015 programs with no guard at all, 700 CPU-s for the whole pack (slowest program 1.5 s).
`dxil::assemble::assemble` turns a module written as LLVM IR text (or bitcode) into a signed container: dxcompiler.dll's assembler builds the container from the module's `dx.*` metadata, dxil.dll's validator checks and signs it. No HLSL front end and no optimiser: a retail compute program's module (8.6 MB of IR, 1 MB of DXIL) takes 0.75 s, its HLSL 25 s through DXC. This is the text path under the module builder (`to_text()`), so the lowering can run real programs on the GPU before the binary writer is done. The test assembles a hand-written CS of the ABI root signature, runs it on the GPU and checks its output, and checks that a use before its definition is refused by the validator. A module needs an `!llvm.ident`: without one it validates but the AMD driver faults in CreateComputePipelineState. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XTYmP5ub3Zjdi8PYaDNwsV
The direct backend's lowering, for kernel mode first. The console CFG is kept and every register dword is an SSA value, built on the fly while the blocks are lowered (`ssa.rs`). EXEC is each lane's own bit: mask branches are per-lane branches and a vector write keeps `select(bit, new, old)` only where the lane-mask analysis could not prove the bit set. An SGPR has a number view and, when it holds a mask, a lane-bit view; a number read where a mask was written (or the reverse across a join) is refused once every phi is complete, and the program stays on the HLSL path. At the end, where every lane is back, a mask stored as a number is the wave's ballot. A mask written in a block some lanes skip (a loop lanes leave one by one, an arm some lanes jump over) and read after they meet again differs from the console, whose whole-wave write left the absent lanes' bits 0. Those blocks are found from the post-dominators of the lane branches; such reads are refused, and kernel mode's final store reports those registers. The IR goes through an `Ir` trait, the part of the DXIL module builder the lowering needs. The tests run it lane by lane on a CPU interpreter, and run the same programs through the HLSL path on the GPU: every register agrees (GTX 1650, wave32). The analysis now exports its CFG for the lowering.
`s_load_dword{,x2,x4,x8,x16}` and `global_` / `flat_` `load` / `store_dword
{,x2,x3,x4}` on the flat memory, with the addressing of the HLSL path's
single-window form. A guarded load runs in every lane and keeps the old
register where the lane's EXEC bit is clear (a raw buffer read out of range
is 0, so an inactive lane's address can't fault). A guarded store gets a
block of its own that only the lanes with their bit enter, and the rest of
the console block continues after it; the blocks are reserved before the
SSA form is built, so the predecessor lists stay exact.
The CPU interpreter in the tests gets the memory too, and the comparison
with the HLSL path on the GPU now also checks the memory after the run: a
program with an SMEM load, a per-lane load, a guarded store and an
unguarded one agrees word for word (GTX 1650, wave32).
The lowering takes a stage: kernel (the runner's ABI, as before) or a compute program. In compute mode the user SGPRs come from `io`, then the group ids and TG_SIZE the program enables, the thread ids go into v0–v2, EXEC starts as every lane that runs, and the program ends without storing registers (so kernel mode's report of stale masks does not apply). One-dimensional groups only for now: in a 2-D / 3-D group the PC driver need not give a wave consecutive threads, which the console does; the HLSL path reorders them and those programs stay on it here. A compute program with user SGPRs and the group id, over three groups of 64 threads, writes the same memory through the HLSL path on the GPU and through the lowering on the CPU (GTX 1650, wave32).
Brings xcl-dev#1747, xcl-dev#1791, xcl-dev#605, xcl-dev#1679, xcl-dev#1806, xcl-dev#1745, xcl-dev#1307, xcl-dev#1321 among others. Resolutions: - dxil/kernel.rs: upstream's Lw::new / Lw::finish; the safe s_barrier state and policy and xcl-dev#1741's single-wave bounded exchange move into Lw::new, with a safe_barrier flag (false for the per-lane lowering). - dxil/lower.rs: VAR_BAR_DEAD moves to VAR_BUDGET + 6 (+5 is VAR_F32_MODE). - TRANSLATOR_VERSION 9. - d3d12x/bind.rs: the bounded ExecuteIndirect call runs inside fresh_indirect_arguments. - d3d12x/list_x.rs: tracked_list_type, and transition (pub(super)) over the batched transitions. - recomp/mod.rs: compact backend and per-lane modules both kept; the oversized-structured-code fallback applies to translate after prepare. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
`vgpr_uses` took an image instruction's registers from the operand tables, which give the largest case: a 3-D address with every modifier and four data registers. It missed the addresses in the NSA dwords (VADDRA, VADDRB, ...) and a compare-swap's compare value (VDATA + 1), took a G16 sample's address as shorter than the translators read it, took an atomic's data as written only (and written without GLC too), and claimed data registers that DMASK and D16 leave alone. Its callers act on those registers: the direct DXIL VS sets up the initial VGPRs it lists (vertex and instance id, fetched attributes), the HLSL path bounds its movrel switches with them, `xcl shaders` reports the inputs a program reads from them, and the per-lane form of xcl-dev#1745 passes exactly them to xcl-dev#1426's lowering, which refuses an instruction that reads another: every image instruction with NSA addresses. `vgpr_uses` now counts them as `recomp::emit` and `dxil::lower_image` read them: the address dwords from the opcode's modifiers, DIM and A16, at VADDR and the registers after it or VADDR then the NSA bytes; the data from DMASK, D16, TFE/LWE, GLC and the opcode. `dxil::lower_image` read VDATA + 1 for every atomic; it reads it for a compare-swap only now. In xcl-dev#1745's per-lane form (at 3ca3633), a sweep of every IMAGE_* instruction over DIM, A16, D16, DMASK, GLC and sequential or scattered NSA addresses through the per-lane compute lowering: 6562 of 28032 cases refused for a register not passed before (6130 NSA, 288 compare-swap, 144 G16), none after, and no case that lowered before refused. Assisted-by: Claude Code (Claude Opus 5.5, xhigh)
In the per-lane direct DXIL backend (xcl-dev#1745), non-native VALU instructions with DPP16 or DPP8 modifiers (such as float wave reductions with v_add_f32_dpp, v_max_f32_dpp, or DPP source modifiers SRC0_ABS/SRC0_NEG) failed to lower: `valu()` eagerly ran `self.dpp()`, DPP source modifiers hard-refused without the `unsupported ` prefix, and `bridge()` called `Lw::inst_guarded` with `mask = None`, causing `Lw::exec_mask()` to read SSA EXEC (register 126) and fail the per-lane register check. `Ir::foreign` now forwards an optional active-lane mask to `Lw::inst_guarded`. For bridged DPP16/DPP8 instructions, `bridge()` checks `all_lanes` when fetch-inactive (`FI`) is set and passes the half-wave EXEC ballot (`exec_words(b, true)`). `Lw::sources` also clamps inactive DPP16/DPP8 source lane indices to `self.lane` before `read_lane_half` so `WaveReadLaneAt` never reads an inactive lane. Assisted-by: Antigravity (Gemini 4 Neon)
|
Test report after the merge, on native wave64 AMD RDNA2 (the reports above are RDNA3, RDNA4 and NVIDIA): Tested
Not tested
AI use: Claude Code (Claude Opus 5.5) ran these tests on my machine and wrote this report. AI-assisted verification using synthetic inputs. |
…de EXEC out thehollowedone's program on #1269 (Pipodi's review point 3 on #1745): EXEC = lanes 0-15 (`s_and_saveexec`), then `v_cmpx_le_f32 0, v1`, true in every lane, then `v_mov v2, 7`. The console, the HLSL path and #1426's per-instruction form write lanes 0-15; the per-lane form wrote all 32. The bridge runs #1426's lowering of a float `v_cmpx` with the guard `true`, so the lane's bit it reads back is the compare alone. The new EXEC is now that bit and the lane's EXEC before the instruction, as the per-lane form's own integer `v_cmpx` already did. Test: his program on the GPU (fails without the fix in lane 16).
…ane form In the per-lane direct DXIL backend (#1745): - `bridge()` rejected `V_CNDMASK_B32` / `V_ADD_CO_CI_U32` / `V_SUB_CO_CI_U32` / `V_SUBREV_CO_CI_U32` whenever the mask operand was not an SGPR (`m > 127`, such as inline carry-in `0` = 128 or `-1` = 193, or `NULL` = 125), even though `dxil::Lw::read64` already decodes non-SGPR mask operands without touching any SGPR. - `src_bit()` accepted only SGPRs, `128` (0), and `193` (-1), refusing `NULL` (125), inline integer masks (`129..=192`, `194..=208`), and 32-bit literals (`255`). - `src()` and `src64()` missed `125` (`NULL`). `bridge()` now skips SGPR injection when `m > 127 || m == 125`, `src_bit()` extracts the lane's bit from `NULL`, inline integers (sign-extended to 64 bits for negative values), and 32-bit literals, and `src()`/`src64()` handle `125`. Assisted-by: Antigravity (Gemini 4 Neon)
`vgpr_uses` took an image instruction's registers from the operand tables, which give the largest case: a 3-D address with every modifier and four data registers. It missed the addresses in the NSA dwords (VADDRA, VADDRB, ...) and a compare-swap's compare value (VDATA + 1), took a G16 sample's address as shorter than the translators read it, took an atomic's data as written only (and written without GLC too), and claimed data registers that DMASK and D16 leave alone. Its callers act on those registers: the direct DXIL VS sets up the initial VGPRs it lists (vertex and instance id, fetched attributes), the HLSL path bounds its movrel switches with them, `xcl shaders` reports the inputs a program reads from them, and the per-lane form of xcl-dev#1745 passes exactly them to xcl-dev#1426's lowering, which refuses an instruction that reads another: every image instruction with NSA addresses. `vgpr_uses` now counts them as `recomp::emit` and `dxil::lower_image` read them: the address dwords from the opcode's modifiers, DIM and A16, at VADDR and the registers after it or VADDR then the NSA bytes; the data from DMASK, D16, TFE/LWE, GLC and the opcode. `dxil::lower_image` read VDATA + 1 for every atomic; it reads it for a compare-swap only now. In xcl-dev#1745's per-lane form (at 3ca3633), a sweep of every IMAGE_* instruction over DIM, A16, D16, DMASK, GLC and sequential or scattered NSA addresses through the per-lane compute lowering: 6562 of 28032 cases refused for a register not passed before (6130 NSA, 288 compare-swap, 144 G16), none after, and no case that lowered before refused. Assisted-by: Claude Code (Claude Opus 5.5, xhigh)
…per-lane form `wave_salu` in the per-lane direct DXIL backend (xcl-dev#1745) handled `S_BCNT1`, `S_BCNT0`, and `S_FF1` on mask registers, but `S_FF0_I32_B32/B64` and `S_FLBIT_I32_B32/B64` fell through to `bridge()` and failed with `"a mask read as a number"`. `wave_salu` now lowers `S_FF0_I32_B32/B64` via `first_set` on the inverted mask words and `S_FLBIT_I32_B32/B64` via leading-zero count (returning `0xFFFFFFFF` when the input is 0, matching `emit.rs` and the RDNA2 ISA). Assisted-by: Antigravity (Gemini 4 Neon)
In the per-lane direct DXIL backend (xcl-dev#1745), non-native VALU instructions with DPP16 or DPP8 modifiers (such as float wave reductions with v_add_f32_dpp, v_max_f32_dpp, or DPP source modifiers SRC0_ABS/SRC0_NEG) failed to lower: `valu()` eagerly ran `self.dpp()`, DPP source modifiers hard-refused without the `unsupported ` prefix, and `bridge()` called `Lw::inst_guarded` with `mask = None`, causing `Lw::exec_mask()` to read SSA EXEC (register 126) and fail the per-lane register check. `Ir::foreign` now forwards an optional active-lane mask to `Lw::inst_guarded`. For bridged DPP16/DPP8 instructions, `bridge()` checks `all_lanes` when fetch-inactive (`FI`) is set and passes the half-wave EXEC ballot (`exec_words(b, true)`). `Lw::sources` also clamps inactive DPP16/DPP8 source lane indices to `self.lane` before `read_lane_half` so `WaveReadLaneAt` never reads an inactive lane. Assisted-by: Antigravity (Gemini 4 Neon)
In the per-lane direct DXIL backend (xcl-dev#1745), non-native VALU instructions with DPP16 or DPP8 modifiers (such as float wave reductions with v_add_f32_dpp, v_max_f32_dpp, or DPP source modifiers SRC0_ABS/SRC0_NEG) failed to lower: `valu()` eagerly ran `self.dpp()`, DPP source modifiers hard-refused without the `unsupported ` prefix, and `bridge()` called `Lw::inst_guarded` with `mask = None`, causing `Lw::exec_mask()` to read SSA EXEC (register 126) and fail the per-lane register check. `Ir::foreign` now forwards an optional active-lane mask to `Lw::inst_guarded`. For bridged DPP16/DPP8 instructions, `bridge()` checks `all_lanes` when fetch-inactive (`FI`) is set and passes the half-wave EXEC ballot (`exec_words(b, true)`). `Lw::sources` also clamps inactive DPP16/DPP8 source lane indices to `self.lane` before `read_lane_half` so `WaveReadLaneAt` never reads an inactive lane. Assisted-by: Antigravity (Gemini 4 Neon)
…grams (xcl-dev#1269) Since xcl-dev#1426 and xcl-dev#1745 a compute program can reach DXIL three ways: the HLSL path and DXC, the direct translator (XCL_DIRECT_DXIL=1) and the per-lane form (XCL_PER_LANE=1). The benchmark timed only the first, so it could not say what the direct paths save on the same programs, or which programs they refuse. Every program now also goes through coverage::translate_mode (the direct translator) and, for compute programs, lower_dxil::compute_with (the per-lane form, as pso.rs calls it), with the same repeats as DXC. The result must be the same on a second translation and pass the DXC validator (not timed); a refusal is recorded with its reason, not a failure. The rows get time, DXIL size and refusal per path, and the summary the number translated, their total time and the per-lane refusals of compute programs (kernels are not offered to it, as in pso.rs). A cs-uniform shape (compute, no divergent ifs, no global or scalar memory) is what the per-lane form takes on the small, full and large sets: the per-lane form refuses divergent ifs ("a value written while some lanes were elsewhere, read after they met again") and global / scalar loads ("s0: a mask read as a number"). Nothing in crates/xcl/src changes: both entry points are public. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A per-lane form for the direct DXIL backend (#1426): where a lane-mask analysis proves EXEC, console code is lowered without EXEC guards. Each lane carries its own bit of every mask, mask branches become per-lane branches, and guards stay only where EXEC is not proven. Instructions it has no lowering of go through #1426's
Lw::inst_guardedwith the analysis's guard. It is opt-in: withXCL_DIRECT_DXIL=1 XCL_PER_LANE=1, a compute program tries the per-lane form, then #1426's per-instruction form, then the HLSL path. WithoutXCL_PER_LANEnothing changes. Part of #1269.It is one PR at the maintainer's request: the size rule is waived for this feature (asked of the maintainer by @gefydev; the plan is on #1269, the waiver itself was not posted on GitHub). About 2 600 of the 7 460 added lines are tests.
Result so far, for the maintainer to judge. Whole-pack sweep of a retail title (
xcl shaders --direct --lanes --sample 0 --max-bytes 0 --split 0 --windows 4 --timeout 120): the per-lane form translates 316 of 2 689 compute programs (with the stricter rules from the reviews below; 321 before). On those, its DXIL is 4 020 436 B against 3 988 440 B for #1426's per-instruction form (+0.8 %): no size gain. After bmjask's cleanups, #1426 emits few guards on these programs. Measurements on #1269 point the same way: removing every EXEC select takes about 9 % off driver time on one RTX 3080 program, against 85 % for the window switch, which #1693 now addresses. The large programs, where a gain would matter, are still refused. The main refusals are structural: a branch on whether any lane of a mask is set, with lanes in EXEC that lack the bit (the first refusal of 1 771 programs; the console decides those for the whole wave), and stale values (154). Driver time, measured by Raghav314 on an RTX 4090 (#1269), on the 310 programs that build in all four forms: per-lane 10.0 s, #1426 per-instruction 10.5 s, HLSL 14.1 s driver + 21.9 s DXC, and HLSL with heap windows 10.8 s + 17.2 s. Per-lane against #1426 is a median ratio of 0.98, so again no real gain on what it covers. So this PR is the infrastructure plus measurements. It does not deliver a speedup today.What is in it (51 commits; authors kept)
gpu/recomp/lane_masks.rs: the lane-mask analysis (BDD over lane / SCC / opaque atoms, worklist dataflow, loop heads, irreducible flow refused). The launch EXEC can be an atom for VS / PS (teidenzero).gpu/recomp/ssa.rs: on-the-fly SSA (Braun et al.), with a number view and a lane-bit view per SGPR.gpu/recomp/lower.rs,lower/wave.rs: the lowering behind anIrtrait, with a CPU interpreter for tests. It covers SALU / VALU / memory, mask ops,s_cselect/s_wqm/v_cmpx, far jumps, and cross-lane ops (Sr-0w). It refuses stale values written where some lanes are elsewhere. Also guard coalescing (MiguelMachado-dev) and VS / PS stages (teidenzero). The bridge to gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 refuses an instruction when gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 would read a register it was not passed.gpu/recomp/lower_dxil.rs: theIron gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426'sLw. It handles head / tail blocks, so gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 can make blocks inside an instruction, plus several and heap memory windows, the split wave64 form (upipibi) and batched trivial-phi replacement (Itsmetibo).gpu/dxil/kernel.rs:Lw::new/Lw::finishout of the kernel translator, with no change to gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's output (Sr-0w).gpu/recomp/pso.rs: the runtime hookup behindXCL_PER_LANE=1, with its own translated-cache identity.gpu/recomp/dxil/assemble.rs: IR text to a signed container, as a test oracle (Sr-0w).shaders.rs:xcl shaders --direct --lanes(coverage and size against gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426), plus the per-lane refusal survey (Kalmarv).s0in the mask-pair check (nobodyttk);WaveSize(64)(MiguelMachado-dev);Lw's lanes (vladbondarenko97);v_cvt_f16_f32,v_mul_f16,v_pk_mul_f16round toward zero) stay on the fallback (DIFFERS_ON_1426); itsSio is fixing them onmain.Tested
cargo test --workspace -- --test-threads=4on the head (bfb8133, onmain4178e88): 955 passed, 0 failed, 42 ignored. WithXCL_ADAPTER=warp(the CI adapter, no sized waves) the lib gives 876 passed, 0 failed, 22 ignored: the per-lane GPU tests skip there.V_CVT_F16_F32,V_MUL_F16,V_PK_MUL_F16, see above).d5fd85d, before the rebase ontomainand the last four commits): numbers as in the result paragraph; 577 s.Regression run
main:This PR's head:
Both with
XCL_PER_LANEoff (the default), so they check that nothing changes. The machine was short of memory: runs of earlier head builds gave 508 to 931 frames, so the frame counts vary a lot run to run here.Not tested
XCL_PER_LANE=1; the regression runs below are with it off, the default.AI use
Assisted-by: Antigravity (Gemini 4 Neon); the other helpers name their tools on [OFFICIAL] Looking for PRs with shaders optimization #1269.