recomp: memory window from the full address, carry in 32 bits (#123 again) #138
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!138
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/138/head"
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?
@gefydev on GitHub · 2026-11-23 14:51 UTC · original
gefydev:recomp-window-carry-32→main· +106 −13 · 2 files · 1 commits · closed without merging#123 was reverted in
70f8dc4: AMD's shader compiler crashed on XDefiant's CS8e4af296b9d7fd9c. This PR is a second try, in the form suggested there: a 32-bit carry compare instead ofuint64_t.The problem it fixes is the same. With several memory windows, smem, MUBUF and FLAT / global picked the window from the base's high dword before adding the offsets. So an offset that carried out of the low dword went to the base's window at the wrapped address.
What changed from #123:
window_atadds the low dword and the offsets in 32 bits and counts the carries with one compare per term:xcl_ws += t; xcl_wc += (uint)(xcl_ws < t);.stride * indexproduct is now 32-bit, so it no longer catches a product above 4 GiB.For example, a global load with SADDR emits:
As in #123, with one window it emits nothing, so the single-window HLSL and its DXIL cache are unchanged;
gpu_memory_windows_above_4_gibchecks that.Test
gpu_memory_window_carry(from #123): the base sits at0xFFFF_F000of window 0, and s_load, s_buffer_load, buffer load / store, global load with SADDR and a global atomic each reach window 1. It now also checks that thexcl_w =lines contain no 64-bit arithmetic. Without the emit change it fails; with it, it passes on a GTX 1650 under Wine, and so do the other lib tests that run there.I can't run XDefiant or an AMD GPU here, so whether this shape avoids the
amdxc64.dllcrash needs your RX 9070 check. If it still crashes, the next step would be your other suggestion: emit the carry only where an offset can actually cross the dword.@tronLives111 on GitHub · 2026-11-23 17:06 UTC · original
One remaining carry case in
b7177b1:buffer_windowpassesstride * indextowindow_atas a single HLSLuint. The multiplication can already have discarded its high word beforewindow_atcounts the carries from addition. AMD’s RDNA 2 ISA guide §8.1.1 addsStride * Vindexto the full linear buffer address.For a synthetic, in-range structured buffer, take base
0:0x4000, stride16, index0x10000001, andNumRecords = 0x10000002, with both byte offsets zero. The product is1:0x10, so the full address is1:0x4010. The emitted arithmetic keeps the same low word but selects0:0x4010. This is separate from the offset-addition carries already covered bygpu_memory_window_carry.The emitter already has
mul_hi_u32. Adding its result to the window’s high word alongside the existing addition carry would keep this path 32-bit. I checked that arithmetic against a full-width integer oracle for 100,000 stride/index/base-low combinations. This was a CPU arithmetic check and source review, with no DXC or GPU run. AI-assisted review.AMD RDNA 2 ISA guide, §8.1
@WarmMilkCodes on GitHub · 2026-11-23 18:55 UTC · original
Tested #138
b7177b1merged onto main956a476on AMD Radeon RX 6600 XT (RDNA2), driver 32.0.21045.29003, Windows 11 23H2 (22631.6199): passcargo test --workspace --no-fail-fast -- --test-threads=4, noXCL_SAMPLE_*data:No new failures vs main. The PR's new test passes on RDNA2. The one failure on both,
gpu_wave64_ps_whole_wave_reductions, is the 32-lane PS case on this card (#155).@ivall on GitHub · 2026-11-23 21:09 UTC · original
Not merged in this round on purpose: it changes the HLSL of every multi-window program, so the next run of a title recompiles all of its shaders, and I wanted the other merges checked on a warm cache first. It is next. Could you rebase on main (
6da33fa)?@Kalmarv on GitHub · 2026-11-23 21:21 UTC · original
The carry fix holds where lanes disagree: one load whose even lanes stay in window 0 and odd lanes carry into window 1 (4 GiB apart) reads 17 / 31 with this PR in all 64 lanes, and 17 / 23 on main (the carry lost). Same on the merge with main
6da33fa.Tested
A single translated
GLOBAL_LOAD_DWORDselected different windows for adjacent lanes on Blackwell. I used two 1 MiB windows 4 GiB apart, SADDR low word0x1004, and signed instruction offset −4. Even lanes supplied VGPR offset 0 and loaded 17 from window 0 at0x1000. Odd lanes supplied0xfffffffcand should load 31 from window 1 at0xffc. Window 0 held 23 at that same offset to distinguish a lost carry from a wrong low address.6da33fa+ testsb7177b1e263903(0, 0)(0xc0ffee, 0x1234)RTX 5070 Ti, 610.74, Windows x64, native D3D12. Built with
cargo test -p xcl --lib --no-run -j 2and rangpu::recomp:: --test-threads=1. Direct head passed 165 module tests, plus the mixed-lane probe separately. The merge passed 173 including that probe, with 18 ignored. The shared main control passed 171 and failed both #138 tests and three carried #202 tests. The original956a476control also returned 17 / 23.Not tested
Retail shaders, AMD, native wave64, ADDTID, or stride-product overflow. The mixed-lane case used the split wave64 implementation on 32-lane hardware.
AI use — Codex, GPT-6.2 Astra.
@srcamarda on GitHub · 2026-11-23 21:37 UTC · original
RDNA3 run plus the two open review points (@tronLives111's
stride * index, @RemingtonWilcox's*_addtid), on RX 7800 XT, driver 32.0.32029.2010, Windows 11 26300, native 64-lane waves, debug build.Rebase:
b7177b1ontomain0f34407has one conflict intests.rs, wheregpu_uma_import_check_at_initandgpu_memory_window_carrywere added at the same spot. Keeping both resolves it.The two points, fixed in 32 bits
buffer_window: the window's high dword gets+ mul_hi_u32(stride, index)next to the carries, so a structured buffer past 4 GiB of records moves to the next window. The low word stays the wrapping 32-bit product. Nothing changes without IDXEN (indexis0u).flat_window:addris nowOption<u64>, and the*_addtidcall passesNone. The terms are then SADDR +4u * lane_id, or0u:4u * lane_idwith a null SADDR. The ADDR field's VGPR is no longer read (or registered).Patch below (on the rebased commit). The HLSL changes only for multi-window programs with an indexed MUBUF access or an addtid access.
New GPU test:
gpu_memory_window_stride_product_and_addtidTwo 1 MiB windows 4 GiB apart. Each wrong window holds a sentinel.
buffer_load_dwordwith IDXEN: base0:0x4000, stride 16, index0x1000_0001,num_records 0x1000_0002→1:0x4010(tronLives111's example). All 64 lanes read window 1's value.global_load_dword_addtid, SADDR0xFFFF_FF80,v0 = 0: lanes 32..63 carry into window 1. EXEC is set to lanes 32..63 for this load. Lanes 0..31 would read the top of window 0, which the arena doesn't map, and that removed the device here (0x887A0006) and took the next tests down with it.mul_hi_u32(and4u * lane_idin thexcl_w =lines, no 64-bit integers) come first.Checked by sabotage. Without the
emit.rschange, the HLSL check fails. With the HLSL checks disabled, the GPU check reads0xBAD0(the stride sentinel in window 0). With only the addtid call reverted, lane 32 reads0xBAD1(the addtid sentinel).Results (rebased + patch)
cargo test -p xcl --lib -- --test-threads=4: 613 passed, 0 failed, 20 ignoredXCL_SPLIT_WAVE64=1: 613 passed, 0 failedgpu_memory_window_carry,gpu_memory_windows_above_4_gib,gpu_mesh_mode_reads_memory_windows,gpu_bvh64_intersect_ray_across_memory_windows_and_grazing, and the addtid tests: passNot tested: XDefiant (the
amdxc64crash from #123), retail packs, NVIDIA, RDNA2.Patch on
b7177b1rebased onto0f34407(git apply)@Kalmarv on GitHub · 2026-11-23 21:54 UTC · original
Driver cost of this PR's 32-bit carry when combined with #187's heap windows, on an access-dense compute program: with #187, #138 makes first creation in the driver about 50–65 % slower. That is still about 25× faster than the switch form without #138.
The shape is split wave64 compute with a load and a store of title memory every round and an exec-masked block every 4 rounds. Each cell is 2 programs the driver had never seen, and the driver times are min / max:
Tested
main0cd0a53+ #187c74b03a+ an ignored bench, without and with #138 atb7177b1. Synthetic programs only.Not tested
main.🤖 Claude Fable 5.2, Claude Opus 5.5
@raylitebull on GitHub · 2026-11-24 10:42 UTC · original
Closing as superseded by #792, which has already been merged into
main.Pull request closed