Recompiler: early-exit-safe multi-wave s_barrier in direct DXIL #3264
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3264"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T02:18:30Z.
Overlaps #1793 (mastrr9, same goal, currently conflicting with main): this is amd-dev's implementation (
965cc655, raylitebull). Maintainers, keep one of the two.Multi-wave compute and mesh programs containing
s_barrierfall back to HLSL + DXC today (on this card's retail run: 84 CS + 2 MS; amd-dev's commit counts 192/192 MS and 21 CS on a world load). This lowers the barrier in the direct DXIL translator with the same bounded, early-exit-safe groupshared arrival barrier as the HLSL path'sPRELUDE_SAFE_BARRIER(XCL_BAR_ALIVE/XCL_BAR_STATE), so a wave that left (s_endpgm, loop budget) does not hang the others. On NVIDIA a plainbar.syncwith a missing wave hangs the GPU, so this is the PR that most needs an NVIDIA run.Review fix (throny): amd-dev put the wave's alive flag (
VAR_BAR_ALIVE) inVAR_BUDGET + 5, which on main islower_round::VAR_F32_MODE. A program that directs f32 rounding and sets its MODE bits to 0 then counted itself out and passed its barriers early. The flag now has the free slotVAR_BUDGET + 7. A GPU test runs such a program (an LDS exchange across waves afters_denorm_mode 0/s_round_mode 0), andthe_translator_variables_have_slots_of_their_ownchecks the slots on any machine.What is in it
crates/xcl/src/gpu/dxil/lanes.rs:safe_barrier_init(reusesxcl_lds[8189..8190]when the program has LDS, else a 2-dwordxcl_bar),safe_barrier_sync,safe_barrier_exiton the exit tailcrates/xcl/src/gpu/dxil/lower.rs,kernel.rs:s_barriertakes it in groups of several hardware waves (XCL_SAFE_BARRIER=0keeps the plain barrier)crates/xcl/src/gpu/dxil/robustness_tests.rs:a_group_barrier_of_several_hardware_waves_uses_safe_barrier_directlyreplaces the test that asserted the HLSL fallback;gpu_a_multi_wave_barrier_after_the_f32_mode_is_set_to_zero_still_waitsandthe_translator_variables_have_slots_of_their_own(review fix)GROUP_SYNC(amd-dev'sbarrier_uav_fencecomes from a WIP commit main does not have)Tested
cargo test --workspace --no-fail-fast -- --test-threads=4onf8c01769(rebased onto main0fe06eb0): 2739 passed, 0 failed, 49 ignored. SKIPPED GPU tests: 45 distinct notices, almost allno wave64.cargo test -p xcl --lib gpu::dxil: the newa_group_barrier_of_several_hardware_waves_uses_safe_barrier_directlypassesgpu_a_multi_wave_barrier_after_the_f32_mode_is_set_to_zero_still_waitsfails without the review fix above (wave64 split form: thread 0 read 0 instead of 320) and passes with it7b568a10) did not compile on main (lanes.rsused amd-dev'sbarrier_uav_fence, the test anMsInterface.paramsfield main lacks). Kalmarv caught it; my earlier compile check was broken (the wrapper hid cargo's exit code). Fixed: the safe barrier fences groupshared memory only, as the HLSL path'sxcl_s_barrier(GroupMemoryBarrier).-StartupTimeoutSeconds 3600for the cold pipeline rebuild new DXIL needs.Regression run
main:
this PR:
Not tested
AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T03:23:05Z.
merge-check
base:
fa204595a4head:
44be66d4c3merge: clean onto main and with the 7-PR stack.
build: cargo build --workspace -> ok; cargo build --release -p xcl -> ok.
tests: Standalone on RTX 5070 Ti:
cargo test -p xcl --lib gpu::dxil::-> 231 passed, 0 failed, 3 ignored (all 4fuzz_validate_and_gpu_0..3passed); standalone 150 s NVIDIA hang-test smoke (ea3b5e4d,XCL_PREPARE=0) ->exit: 0x0,2076frames shown,0device removals,0crashes,0nvlddmkm/display System events,32971 MBpeak commit,0s_barrierdirect-DXIL fallbacks. tested in the clean 7-PR stack (#3250+#3261+#3263+#3264+#3265+#3266+#3268) on mainfa204595:cargo test --workspace --no-fail-fast -- --test-threads=4(DXC 1.9.2609.5;-p xcl --librerun skipping the 2 knownmain#3187uma_drivermixed-window testsa_refused_gpu_upload_segment_becomes_customandmixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment) -> 2620 passed, 0 failed, 49 ignored (2481 lib + 139 integration, 25 SKIPPED notices; all 4fuzz_validate_and_gpu_0..3passed); failing: none. 150 sxcl-smoke(ea3b5e4d,XCL_PREPARE=0, RTX 5070 Ti) on the combined 8-PR stack:exit: 0x0,2096frames shown,0device removals,0crashes,0display System events,32049 MBpeak commit.review: none (whole diff read: branchless
safe_barrier_init, bounded CAS generation/arrival loop insafe_barrier_syncwith TGSM fence matching HLSLxcl_s_barrier, and unified exit-tailsafe_barrier_exit; reusesxcl_lds[8189..8190]to stay within 32 KiB D3D12 groupshared limit).performance: positive: eliminates multi-wave
s_barrierHLSL fallbacks without hanging or regressing RTX 5070 Ti (2076 frames standalone, 2096 frames in 8-PR stack).verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (wave32 only), Windows 11, DXC 1.9.2609.5 via XCL_DXC_DIR; Antigravity (Gemini 3.5 Pro) ran the merges, builds, workspace test suites, 150 s title smokes, diff reviews, and drafted this check.
Imported from ivall/xcl. Originally posted by throny on 2026-11-29T09:01:25Z.
merge-check claim
head:
44be66d4c3Imported from ivall/xcl. Originally posted by throny on 2026-11-29T09:20:35Z.
merge-check
base:
d8bd9a38head:
44be66d4c3merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2618 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at
d8bd9a38: 2618 passed, 0 failed, 49 ignored.review: one blocking finding. The new
VAR_BAR_ALIVEisVAR_BUDGET + 5in lower.rs, and main already uses that slot:lower_round::VAR_F32_MODEisVAR_BUDGET + 5(lower_round.rs line 25 atd8bd9a38). So the alive count and the f32 rounding mode share one variable. From reading the init code, the existing check forVAR_F32_MODEcomes first, so the new "start at 1" branch is not reached; a program that sets its f32 mode bits to 0 would mark its wave as having left, skip the barriers after that and never count itself out, and a barrier timeout would write 0 into the rounding mode. The suite does not catch it because the new test only checks disassembly strings. Apart from that the port matches the HLSL barrier from reading: every exit goes through the tail where the wave counts itself out, and waiting waves re-read the alive count on every spin, so a wave that leaves early releases them. Also: this is the same work as the older open #1793 (listed on #1607); one of the two should be closed.performance: not measured.
verdict: not yet: give
VAR_BAR_ALIVEa free slot (no constant on main isVAR_BUDGET + 7) and add a test that runs a program which changes the f32 mode and uses the barrier.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).
Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T17:18:49Z.
Thanks throny, the slot clash was real. Fixed in
f8c01769(rebased onto main0fe06eb0):VAR_BAR_ALIVEis nowVAR_BUDGET + 7, the free slot.gpu_a_multi_wave_barrier_after_the_f32_mode_is_set_to_zero_still_waitsruns the program you described (directed f32 rounding, MODE set to 0, then an LDS exchange across waves throughs_barrier). Without the fix it fails here: the wave64 split form read 0 instead of 320. With the fix it passes.the_translator_variables_have_slots_of_their_ownchecks the slots on any machine, CI included.Full suite on
f8c01769: 2739 passed, 0 failed, 49 ignored. The new smoke run is in the description. I'm leaving the overlap with #1793 for the maintainers to settle.(Written with Claude Code, Claude Opus 5.5.)
Imported from ivall/xcl. Originally posted by afpruivo on 2026-11-30T00:32:22Z.
Test report on NVIDIA: #3264 head
f8c01769againstmain0fe06eb0(its base), retail title, 4 alternating runs after a warm-up per build.Setup: RTX 3090 24 GB, driver 621.40, i5-13600K, Windows 11 26300, release builds named
xcl.exe(NVIDIA profile applies), no local changes.XCL_DIRECT_DXIL=1 XCL_NETWORK=0 XCL_UMA_DRIVER=mixed:1536:1792 XCL_TEXTURE_LEVEL_PAGES=1, scripted presses,XCL_GPU_TIMES=16,750(16 frames in the world after 750 s).Result:
mainthe log has 1,271direct DXIL fallback … s_barrier in a group of several hardware waves – HLSL pathlines; on the PR there are none.Not tested: AMD; visual correctness (frames are black in the world on this 3090 on every build, known);
cargo teston the PR head.AI use: Claude Code (Claude Opus 5.5) built the trees, ran the runs and wrote this report.