You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Recompiler: ds_bpermute_b32 in wave64 may stay within each 32-lane half on RDNA2 (needs a hardware run) #772
ds_bpermute_b32 in a wave64 program reads any of the 64 lanes: emit.rs ("ds_bpermute_b32", about line 3832 on f4ce27c) uses ((addr + offset) >> 2) & 63. On RDNA 1/2 in wave64, the permute may stay within each 32-lane half: lane l reads lane (l & 32) | (index & 31).
Sources that disagree
RDNA2 ISA §10.4.4 (LDS lane permutes) and Mesa ACO: ACO doesn't emit a plain ds_bpermute_b32 for wave64 on GFX10. It goes through emit_gfx10_wave64_bpermute (aco_lower_to_hw_instr.cpp), which combines a within-half permute with a swapped-halves copy, because the instruction alone does not cross halves.
The opcode table in the same RDNA2 PDF describes the index as mod 64, which is what XCL follows. gpu_split_wave64_cross_half_operations currently asserts the cross-half result.
Where they'd differ: whenever the index points into the other half. For example, all lanes active and index = 4 * (63 - l): XCL gives lane 0 the value of lane 63, while a within-half permute gives lane 31. A rotate-by-one pattern (index = 4 * (l + 1)) differs at lanes 31 and 63.
Needs a hardware run: native wave64 on an RDNA 1 or 2 GPU. #518's method (inline RDNA assembly through OpenCL on an RDNA2 iGPU) would settle it with one kernel: all lanes active, ds_bpermute_b32 v1, v0, v2 with v2 = lane id and v0 = 4 * (63 - lane), recording v1 per lane. If the hardware stays within halves, the fix in emit.rs is the index change above (and the split-wave64 path's handling of it); if it doesn't, a GPU test pinning the cross-half result would document it.
I have no RDNA hardware (RTX 3070 only), so this comes from reading the sources, not measured. Found in a read-only audit of the recompiler's instruction semantics.
No RDNA1/2 hardware here, but a measured RDNA3 datapoint that narrows the question, plus split-path behavior that seems adjacent to it.
RDNA3 native (RX 7900 XT / RADV NAVI31, Mesa 26.2.5, Wine/Proton Experimental wine-11.0 + patched vkd3d-proton v3.1, main d5442d2, full row in #42): the native bpermute/swizzle tests (gpu_ds_swizzle_modes, gpu_ds_swizzle_and_bpermute_zero_inactive_lanes, and the rest of the gpu_ds_* family) pass — 8 full lib-suite runs, 0 hits. So on RDNA3 in wave64 the permute does cross halves as the opcode table says (mod 64); the within-half reading is not a general RDNA behavior, the open question really is RDNA1/2-specific.
Split wave64 forced on that same card (XCL_SPLIT_WAVE64=1, --test-threads=1, main d5442d2): the cross-half emulation does misbehave on RDNA3 when it runs as two halves:
gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves: fails 12/12 ([256,1,1], group 0 thread 96 (wave 1, lane 32): s_bcnt1 sum left: 0 right: 42)
gpu_split_wave64_waves_diverge: fails 9/12 (group 1 thread 64: ds_bpermute left: 0) — genuinely flaky, not a fixed mismatch
both reproduce with RADV_DEBUG=llvm as well as ACO, so it is not the known Mesa ACO ds_bpermute lowering bug
at the older 3db536e both tests were flaky (mixed results single-threaded); at d5442d2 the masks test is now deterministic — whatever changed between those commits stabilized one of them
So the split path's cross-half ballot/bpermute handling has a live failure mode over RADV even where the hardware itself is fine — worth a look when deciding what emit.rs should assume.
Not tested: RDNA1/2 hardware (the actual #772 question — the #518 OpenCL kernel settles it, but I have no such card), NVIDIA wave32 native for the split tests, Windows on any of this.
Counts only, no game data.
AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
Thanks @SlopTart, that narrows it to RDNA 1/2. One NVIDIA data point for your split-path note: on an RTX 3070 (driver 616.56, Windows 11, 32-lane waves only, so every wave64 program takes the split path natively), gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves and gpu_split_wave64_waves_diverge both passed in 6 of 6 full cargo test --workspace -- --test-threads=4 runs this hour (PR heads dc6fa59, e9b0186, 7728d19, 422f56d, bbf6c40, 9683e7a, none of which change the recompiler). So the failures you see under RADV with XCL_SPLIT_WAVE64=1 don't show up on NVIDIA's native wave32, which points at the forced-split-on-wave64-hardware combination rather than the split lowering itself.
Plain ds_bpermute_b32 stayed inside each 32-lane half on this RDNA2 GPU during native wave64 execution. Both runs produced identical results.
Tested
Radeon RX 6800M (gfx1031), Windows 11 build 26200, Windows display driver 30.0.13002.13003, AMD OpenCL 3302.6 (PAL,LC).
One 64-item OpenCL workgroup built with -cl-std=CL2.0 -Wf,-mwavefrontsize64. Inline s_bcnt1_i32_b64 counted 64 active lanes in EXEC, and v_mbcnt_lo / v_mbcnt_hi returned hardware lane IDs 0 through 63. An independent v_readlane_b32 of lane 63 returned 63. get_sub_group_size() reported 32 on this driver, so I used the hardware instructions to verify wave64.
Each lane passed its hardware lane ID as the source value. The inline sequence used ds_bpermute_b32 followed by s_waitcnt lgkmcnt(0). The byte address was four times the requested source lane, with no immediate offset.
Source index
Half-wave matches
Full-wave matches
Distinguishing outputs
lane
64/64
64/64
Identity control
63 - lane
64/64
0/64
Lane 0 read 31, lane 32 read 63, lane 63 read 32
(lane + 1) & 63
64/64
62/64
Lane 31 read 0, lane 63 read 32
The half-wave model was (lane & 32) | (index & 31). I also checked that emit.rs on e50836b still uses a 63 mask for wave64.
Not tested
Partial EXEC masks, nonzero immediate offsets, other GPUs and XCL's split-wave path. This was a native instruction probe on an RDNA2 laptop GPU.
AI use
OpenAI Codex (GPT-6 family, exact model variant unavailable) wrote and ran the probe, checked the raw lane output, and drafted this report.
Thanks @luckyteagirl, that settles it for RDNA2: plain ds_bpermute_b32 in native wave64 stays within each 32-lane half, so XCL's & 63 index is wrong for this console, and @SlopTart's RDNA3 result (crossing halves) shows the behaviour differs by generation. I'll prepare the fix (index (lane & 32) | (index & 31) for wave64 programs, with a GPU test built from your lane results) and link it here.
@upipibi, one note on the RDNA 3 result before you write the fix. It doesn't show that the behaviour differs by generation. XCL emits WaveReadLaneAt, and on RADV that becomes a NIR shuffle, which ACO lowers through emit_bpermute. For wave64 there, ACO emulates a whole-wave bpermute on GFX10 through GFX11.5 ("GFX10-11.5 wave64 mode: emulate full-wave bpermute"), and elsewhere it notes that "ds_bpermute is restricted to 32 lanes on GFX10-GFX11.7" (emit_bpermute, rotate fallback, the GFX10 emulation). So those tests pass on RDNA 3 whatever the hardware's own ds_bpermute_b32 does, and ACO treats RDNA 3 as half-wave too. The RX 6800M probe is the only measurement of the instruction itself.
In case it saves you time: a local branch with that fix passed the suite on an RTX 4060 Laptop, though only in the split form.
The change: in emit.rs, the lane is (lane_id & 0x20) | (index & 31) through rla_half_fn, like ds_swizzle. xcl_x_rla_any is no longer used.
The new test fails on mainbeaa245.
With the fix, cargo test --workspace -- --test-threads=4 gives 714 passed, 0 failed, 41 ignored, with 2 SKIPPED (no wave64).
Three existing assertions encode the whole-wave reading and need the half-wave lanes:
gpu_format_stores_atomics_global_lds: l ^ 31;
gpu_split_wave64_cross_half_operations: l ^ 31;
gpu_split_wave64_waves_diverge: l ^ 1.
I'm happy to test your PR on that card when it's up.
@luckyteagirl, if you have time: a partial EXEC (e.g. 0x5555_5555_5555_5555) and a nonzero immediate offset (e.g. offset:4) are the two cases no hardware run covers yet.
Data point for prioritization: I decoded the RDNA2 machine code of all 24,804 shader records in the retail shader database (shaders.rpf entry 0) (25,194 programs, 44.25M instructions, cross-checked length/family/wave-class against xcl's own decoder at every reachable offset).
ds_permute_b32 / ds_bpermute_b32 appears in 0 of the 22,532 wave64 programs. It shows up only in 5 wave32 programs (74 occurrences total). So whatever the correct cross-half semantics are, this instruction is not on the critical path for this title in wave64.
For context, the wave64 ops that do occur and genuinely cross the two 32-lane halves on GFX10 are: 64-bit EXEC/VCC masks (20,704 programs), v_readfirstlane_b32 (14,518), v_mbcnt_hi_u32_b32 (10,034), v_readlane/v_writelane with a constant lane 32-63 (611), and 64-bit mask scans like s_bcnt1_i32_b64 (631). DPP, permlane16/permlanex16 and ds_swizzle all stay within a 32-lane half, so they do not need cross-half handling.
Analysis produced with AI assistance (Claude Opus 5.5), directed and reviewed by the account owner. Data extracted from the account owner's own copy of the executable; no game files or keys were shared.
Edit: the source is the title's shader database (shaders.rpf entry 0), not the pipeline cache (entry 1). The numbers are unchanged.
RDNA2 (gfx1036) hardware result — partial EXEC, nonzero immediate offsets, and ds_permute_b32
Measured on an AMD Ryzen 7 9800X3D integrated RDNA2 GPU (gfx1036), confirming the RX 6800M (gfx1031) half-wave result and covering the two cases @NathanTheophile asked for (partial EXEC and nonzero immediate offset), plus ds_permute_b32 (for #925).
Single 64-item OpenCL workgroup compiled with -cl-std=CL2.0 -Wf,-mwavefrontsize64. Every run verified s_bcnt1_i32_b64 of initial EXEC == 64, v_mbcnt_lo/v_mbcnt_hi lane IDs 0..63, v_readlane_b32(lane, 63) == 63, and s_bcnt1_i32_b64 after s_and_saveexec_b64 matched the test mask's popcount.
Verified in the compiled OpenCL ELF (CL_PROGRAM_BINARIES) that all 7 ds_bpermute_b32 (0xDACCxxxx) and 6 ds_permute_b32 (0xDAC8xxxx) kernels emitted a single raw hardware instruction with the exact 16-bit immediate offset (0, 4, 2, 128, 132, 252, 65532 and 0, 4, 2, 128, 132, 65532) — no compiler wave64 lowering.
Source data was 1000 + lane (so a 0 from an inactive source is distinct from lane 0), and dst was pre-loaded with 0xDEADBEEF before s_and_saveexec_b64 to verify inactive destination lanes are untouched. Every case ran twice with identical results.
Half-wave models checked
ds_bpermute_b32: active lane l reads src = (l & 32) | (((addr[l] + offset) >> 2) & 31); returns data[src] if src is active in EXEC, else 0. Inactive l leaves dst unchanged (0xDEADBEEF).
ds_permute_b32: active sender s sends data[s] to dst = (s & 32) | (((addr[s] + offset) >> 2) & 31); highest active sender in that half wins; active lane with no active sender gets 0; inactive lanes neither send nor receive (dst stays 0xDEADBEEF).
l0=1031, l32=1063, all other lanes 0 (each half resolves its own highest sender independently)
0x5555_5555_5555_5555, 4*((l+2)&63), offset:0
64/64
62/64
l0=1030, l32=1062; odd lanes stay 0xDEADBEEF
0xAAAA_AAAA_5555_5555, 4*(l^32), offset:0
64/64
32/64
l0=1000, l63=1063
Full EXEC, 4*l, offset:4
64/64
62/64
l0=1031, l1=1000, l32=1063, l33=1032
Full EXEC, 4*l+2, offset:0 vs offset:2
64/64
62/64 (off:2)
off:0: l0=1000; off:2: l0=1031, l32=1063
Full EXEC, 4*l, offset:128 (+32 lanes)
64/64
0/64
l0=1000, l32=1032
Both instructions follow the exact same (lane & 32) | (((addr + offset) >> 2) & 31) rule in native wave64 on RDNA2, with per-half active-lane checking (EXEC) and byte-level addition of the 16-bit immediate offset before >> 2.
Not tested
Other GPU generations (RDNA1/RDNA3/RDNA4), ds_bpermute/ds_permute inside XCL's translated HLSL or split-wave64 path, or retail titles.
AI use
Antigravity (gemini-4-neon) wrote and ran the OpenCL probe, verified the compiled ELF opcodes, and drafted this report.
Correction to my earlier comment here, prompted by @NathanTheophile's Mesa reading. I wrote that our RDNA3 passes show "the permute does cross halves as the opcode table says" - that inference was wrong. ACO emulates the full-wave bpermute for wave64 on GFX10 through GFX11.5 regardless of what the hardware instruction does, so our gpu_ds_* passes over RADV say nothing about the real ds_bpermute_b32 behavior on RDNA3. They only show XCL's emitted NIR shuffle crosses halves as ACO lowers it. The RX 6800M native probe stands as the only direct hardware measurement in this thread, and my "the within-half reading is not a general RDNA behavior" line should be read as "not a general Mesa-lowered behavior".
The split-path failures I reported (gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves 12/12, gpu_split_wave64_waves_diverge 9/12 under XCL_SPLIT_WAVE64=1 on RADV) stand as measured - they are in the split emulation path, and the NVIDIA native-wave32 contrast @upipibi posted still sharpens them.
Happy to run the half-wave fix when it lands - my rig also has the forced-split-on-wave64 combination nobody else covers.
AI use: Hermes agent (local Qwen-class) drafted this; I checked it before posting.
Fix with a GPU test built from the measured lane results (@luckyteagirl's patterns plus @certified-retart's offsets and partial-EXEC case): #1022. It ran in the split form only (RTX 3070); a native wave64 run would still be welcome.
Follow-up from my RDNA3/Wine row on this thread (comment 7123193308 and the correction below it): the split-wave64 suite on this rig has moved to a much worse floor today, and I want to put the numbers up since #1022's author and I both flagged split-mode instability.
Current main 47efa2e, XCL_SPLIT_WAVE64=1, solo --exact runs, --test-threads=1, 6 reps each:
gpu_split_wave64_lane_local_masks: 6/6 (the one that never touches cross-half traffic)
For contrast, my posted measurement earlier today on this rig was 12/12 on the masks tests and 9/12 on waves_diverge (so waves_diverge was already flaky-red 3/12 then). One solo run earlier today still passed waves_diverge, then it went 0/6 on an unchanged checkout - the instability band has slid from "mostly green" to "mostly red".
What I ruled out on the rig side: same commit passed and failed within ~10 minutes; main did not move between the pass and the streak; Mesa 26.2.5 / kernel 7.2 / DXC 1.9.2609.5 unchanged (pacman log + file listing); my patched vkd3d-proton dlls are byte-identical to the ones that measured 12/12 (sha256 73c6e076...); no on-disk DXIL cache exists under the prefix. I also rebuilt the era-era pin 1ec4c98 (before the allocator-pool and bpermute merges) and it shows the same mixed-or-red pattern in combined runs today (1/4, 2/3, 2/3 failures over 6 runs), so this is not a change between 1ec4c98 and 47efa2e - it is run-to-run state that has drifted on the Wine+RADV side.
Failure signature is stable in shape, unstable in values: diverging-wave loop comparisons mismatch (example: group 0 thread 192: loop of wave 3, left 1402 right 1864), different numbers per run, GPU-computed comparisons fail with no panic text on the CPU side. Consistent with the nondeterministic cross-half exchange behavior I flagged in my correction above; the exchange now loses the race far more often than this morning.
ACO/llvm fork test on the four failing tests (RADV_DEBUG=llvm, same commit, same solo mode, 2 reps each): failures persist, 7/8 red (waves_diverge 0/2, local_and_exchanged_masks 1/2, masks_read_whole 0/2, cross_half 0/2). So the ACO lowering is not the variable, matching my earlier fork tests on this rig. One rig-side timing candidate I cannot prove or exclude: this GPU also serves a local LLM (strata) whose load varies between measurements, and this rig has logged amdgpu scheduler-priority oddities under mixed load. A shader-level race in the split-half exchange that is timing-sensitive would fit everything above.
Counts only, no game data. Full per-run logs available.
@SlopTart The four gpu_split_wave64_* failures above are the same Mesa 26.2.5 NIR issue we just captured on #847 (#847 (comment)), not an issue with #1022.
RADV_DEBUG=shaders on both cross_half_operations (offset:512) and waves_diverge (offset:2048) shows the same hoisting as in #847: Mesa NIR lowers InterlockedAdd(XCL_XC(...), 0u, c) to @load_shared (access=atomic) and eliminates the loop-body read, leaving a single ds_load_b32 before the 0xfffff loop and zero LDS reads inside it. That also explains why RADV_DEBUG=llvm still fails (verified here on cross_half_operations: 0/3 default vs 3/3 with XCL_WAVE64_SPIN=0), since the elimination happens in NIR before ACO or LLVM. Both 64-thread tests fail with half-divergence (s0: 0x20 / 0x28, missing the other half's bits) and go 5/5 with XCL_WAVE64_SPIN=0; the 256-thread tests stay 0/5 because emit.rs:4177 forces XCL_X_SPIN 1 whenever threads > 64.
Not tested: PR #1022 checkout, RX 7900 XT (RDNA3), or 47efa2e.
AI use: Antigravity (Gemini 4 Neon) ran the test loops and RADV_DEBUG=shaders dumps on my machine and drafted this comment; I reviewed the results before posting.
RDNA4 native Windows result: plain ds_bpermute_b32 in native wave64 crosses halves (index mod 64) on RX 9070 XT. So the half-wave behaviour @luckyteagirl and @certified-retart measured is specific to RDNA2 (and maybe RDNA1), not to RDNA in general.
Hardware probe (same method as #518 and @luckyteagirl): one 64-item OpenCL workgroup, -cl-std=CL2.0 -Wf,-mwavefrontsize64, inline asm ds_bpermute_b32 r, 4*idx, 1000+lane then s_wait_dscnt 0. Inline s_bcnt1_i32_b64 exec = 64, v_mbcnt_lo/hi lane IDs 0..63, v_readlane_b32 ..., 63 = 63. Two runs, identical:
idx
half-wave (l&32)|(idx&31)
mod 64
sample
lane
64/64
64/64
control
63 - lane
0/64
64/64
l0=1063, l31=1032, l32=1031, l63=1000
(lane+1) & 63
62/64
64/64
l31=1032, l63=1000
lane ^ 32
0/64
64/64
l0=1032, l32=1000
Control: the same kernel built for wave32 (no -mwavefrontsize64, exec count 32) gives the within-32 result 64/64, so the probe tells the two apart.
XCL tests, native wave64 here (adapter runs 64-lane waves, not the split form): cargo test -p xcl --lib cross_half (2 tests, incl. gpu_split_wave64_cross_half_operations) 3/3 passed; bpermute (gpu_ds_swizzle_and_bpermute_zero_inactive_lanes) 3/3 passed. Those go through WaveReadLaneAt, so they show the driver's lowering, not the raw instruction; the probe above is the raw instruction.
For XCL this doesn't change #1022: the console is RDNA2, so its half-wave rule is the one to emulate. It does mean a test can't use the host GPU's raw ds_bpermute as reference on RDNA4.
Investigation by Claude Code (Claude Opus 5.5) on this machine.
RDNA3 native Windows result: plain ds_bpermute_b32 in native wave64 stays within each 32-lane half on an RX 7600 XT (gfx1102), as on RDNA2. So the half-wave behaviour is not RDNA2-only: so far it is RDNA2 and RDNA3 within halves, RDNA4 (@Diskuss's RX 9070 XT) across. This fits the ACO note @NathanTheophile quoted ("ds_bpermute is restricted to 32 lanes on GFX10-GFX11.7").
Hardware probe (same method as #518, @luckyteagirl and @Diskuss): one 64-item OpenCL workgroup, -cl-std=CL2.0 -Wf,-mwavefrontsize64, inline asm ds_bpermute_b32 r, 4*idx, 1000+lane then s_waitcnt lgkmcnt(0). In every run all 64 lanes passed the wave64 checks: inline s_bcnt1_i32_b64 exec = 64, v_mbcnt_lo/hi lane IDs 0..63, v_readlane_b32 …, 63 = 63. Two runs per pattern, identical:
idx
half-wave (l&32)|(idx&31)
mod 64
sample
lane
64/64
64/64
control
63 - lane
64/64
0/64
l0=1031, l31=1000, l32=1063, l63=1032
(lane+1) & 63
64/64
62/64
l31=1000, l63=1032
The compiled code object (CL_PROGRAM_BINARIES, gfx1102 ELF): its .text has exactly one DS-encoded instruction, ds_bpermute_b32 (dacc0000 01000201, op 179, offset 0). A full-wave emulation by the compiler would have given the mod-64 results, so this is the plain instruction's behaviour.
The same results, lane for lane, with both OpenCL runtimes installed here (3679.0 and 3652.0, which compiled different code objects), and recomputed from the raw per-lane values: with each runtime, 0 of the 384 reads (3 patterns × 2 runs × 64 lanes) came from the other half.
Control: the same program on this machine's Ryzen 5 9600X iGPU (gfx1036, RDNA2) gives the same table, matching @certified-retart's gfx1036 and @luckyteagirl's gfx1031 results (l0 reads lane 31, l32 reads 63, l63 reads 32).
Setup: AMD Radeon RX 7600 XT 16 GB (RDNA3, gfx1102), display driver 32.0.31041.1004 (AMD Software 26.8.1), AMD OpenCL 3679.0 (PAL,LC) and 3652.0 (PAL,LC) (platform "AMD Accelerated Parallel Processing", OpenCL 2.1); Ryzen 5 9600X; Windows 11 Home 26200.9974. The host program is a small Rust program calling OpenCL.dll directly; the kernel:
Update: partial EXEC, immediate offsets and ds_permute_b32 on the same card are all half-wave too. Same setup and checks, with @certified-retart's RDNA2 case set: 20 ds_bpermute_b32 cases (offsets 0, 2, 4, 128, 132, 252, 65532) and 11 ds_permute_b32 cases (offsets 0, 2, 4, 128, 132, 65532). EXEC is set inside the asm with s_and_saveexec_b64 and restored after (s_bcnt1_i32_b64 exec inside matched the mask's popcount in every case), the source is 1000 + lane, and dst is preloaded with 0xDEADBEEF to show which lanes are left alone.
All 31 cases match the half-wave model on 64/64 lanes, both runs identical: ds_bpermute_b32 lane l reads (l & 32) | (((addr + offset) >> 2) & 31) (0 from an inactive source, inactive l untouched); ds_permute_b32 sends within the sender's half, the highest active sender wins, an active lane nobody sends to gets 0, inactive lanes neither send nor receive.
The same values, lane for lane, with both OpenCL runtimes (3679.0, 3652.0) and on this machine's gfx1036 iGPU; the mod-64 counts and the sample lanes match @certified-retart's table.
In the code objects, .text has 13 DS instructions, one per kernel: ds_bpermute_b32 with offsets 0, 2, 4, 128, 132, 252, 65532 and ds_permute_b32 with 0, 2, 4, 128, 132, 65532.
all 31 cases (RX 7600 XT, OpenCL 3679.0; DEAD = 0xDEADBEEF, left untouched)
instruction
EXEC
address
offset
half-wave
mod 64
lanes 0 / 1 / 31 / 32 / 33 / 63
ds_bpermute_b32
full
4*l
0
64/64
64/64
1000 / 1001 / 1031 / 1032 / 1033 / 1063
ds_bpermute_b32
full
4*(63-l)
0
64/64
0/64
1031 / 1030 / 1000 / 1063 / 1062 / 1032
ds_bpermute_b32
full
4*((l+1)&63)
0
64/64
62/64
1001 / 1002 / 1000 / 1033 / 1034 / 1032
ds_bpermute_b32
full
4*(l^32)
0
64/64
0/64
1000 / 1001 / 1031 / 1032 / 1033 / 1063
ds_bpermute_b32
0x55555555_55555555
4*((62-l)&63)
0
64/64
32/64
1030 / DEAD / DEAD / 1062 / DEAD / DEAD
ds_bpermute_b32
0x55555555_55555555
4*((l+1)&63)
0
64/64
64/64
0 / DEAD / DEAD / 0 / DEAD / DEAD
ds_bpermute_b32
0x55555555_55555555
4*((l+2)&63)
0
64/64
62/64
1002 / DEAD / DEAD / 1034 / DEAD / DEAD
ds_bpermute_b32
0xAAAAAAAA_55555555
4*(l^32)
0
64/64
32/64
1000 / DEAD / DEAD / DEAD / 1033 / 1063
ds_bpermute_b32
0x00000000_FFFFFFFF
4*(l^32)
0
64/64
32/64
1000 / 1001 / 1031 / DEAD / DEAD / DEAD
ds_bpermute_b32
0xFFFFFFFF_00000000
4*(l^32)
0
64/64
32/64
DEAD / DEAD / DEAD / 1032 / 1033 / 1063
ds_bpermute_b32
full
4*l
4
64/64
62/64
1001 / 1002 / 1000 / 1033 / 1034 / 1032
ds_bpermute_b32
full
4*(63-l)
4
64/64
2/64
1000 / 1031 / 1001 / 1032 / 1063 / 1033
ds_bpermute_b32
0x55555555_55555555
4*l
4
64/64
64/64
0 / DEAD / DEAD / 0 / DEAD / DEAD
ds_bpermute_b32
0x55555555_55555555
4*((l+1)&63)
4
64/64
62/64
1002 / DEAD / DEAD / 1034 / DEAD / DEAD
ds_bpermute_b32
full
4*l+2
0
64/64
64/64
1000 / 1001 / 1031 / 1032 / 1033 / 1063
ds_bpermute_b32
full
4*l+2
2
64/64
62/64
1001 / 1002 / 1000 / 1033 / 1034 / 1032
ds_bpermute_b32
full
4*l
128
64/64
0/64
1000 / 1001 / 1031 / 1032 / 1033 / 1063
ds_bpermute_b32
full
4*l
132
64/64
2/64
1001 / 1002 / 1000 / 1033 / 1034 / 1032
ds_bpermute_b32
full
4*l
252
64/64
62/64
1031 / 1000 / 1030 / 1063 / 1032 / 1062
ds_bpermute_b32
full
4*l
65532
64/64
62/64
1031 / 1000 / 1030 / 1063 / 1032 / 1062
ds_permute_b32
full
4*l
0
64/64
64/64
1000 / 1001 / 1031 / 1032 / 1033 / 1063
ds_permute_b32
full
4*(63-l)
0
64/64
0/64
1031 / 1030 / 1000 / 1063 / 1062 / 1032
ds_permute_b32
full
0 (all to lane 0)
0
64/64
62/64
1031 / 0 / 0 / 1063 / 0 / 0
ds_permute_b32
0x55555555_55555555
4*((l+2)&63)
0
64/64
62/64
1030 / DEAD / DEAD / 1062 / DEAD / DEAD
ds_permute_b32
0xAAAAAAAA_55555555
4*(l^32)
0
64/64
32/64
1000 / DEAD / DEAD / DEAD / 1033 / 1063
ds_permute_b32
full
4*l
4
64/64
62/64
1031 / 1000 / 1030 / 1063 / 1032 / 1062
ds_permute_b32
full
4*l+2
0
64/64
64/64
1000 / 1001 / 1031 / 1032 / 1033 / 1063
ds_permute_b32
full
4*l+2
2
64/64
62/64
1031 / 1000 / 1030 / 1063 / 1032 / 1062
ds_permute_b32
full
4*l
128
64/64
0/64
1000 / 1001 / 1031 / 1032 / 1033 / 1063
ds_permute_b32
full
4*l
132
64/64
2/64
1031 / 1000 / 1030 / 1063 / 1032 / 1062
ds_permute_b32
full
4*l
65532
64/64
62/64
1001 / 1002 / 1000 / 1033 / 1034 / 1032
Not tested: other RDNA3 chips (gfx1100/gfx1101). (#1022 on this card: see my comment there.)
AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them and wrote this comment from their output.
Activity
SlopTart commentedon Nov 24, 2026
No RDNA1/2 hardware here, but a measured RDNA3 datapoint that narrows the question, plus split-path behavior that seems adjacent to it.
RDNA3 native (RX 7900 XT / RADV NAVI31, Mesa 26.2.5, Wine/Proton Experimental wine-11.0 + patched vkd3d-proton v3.1, main
d5442d2, full row in #42): the native bpermute/swizzle tests (gpu_ds_swizzle_modes,gpu_ds_swizzle_and_bpermute_zero_inactive_lanes, and the rest of thegpu_ds_*family) pass — 8 full lib-suite runs, 0 hits. So on RDNA3 in wave64 the permute does cross halves as the opcode table says (mod 64); the within-half reading is not a general RDNA behavior, the open question really is RDNA1/2-specific.Split wave64 forced on that same card (
XCL_SPLIT_WAVE64=1,--test-threads=1, maind5442d2): the cross-half emulation does misbehave on RDNA3 when it runs as two halves:gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves: fails 12/12 ([256,1,1], group 0 thread 96 (wave 1, lane 32): s_bcnt1 sum left: 0 right: 42)gpu_split_wave64_waves_diverge: fails 9/12 (group 1 thread 64: ds_bpermute left: 0) — genuinely flaky, not a fixed mismatchRADV_DEBUG=llvmas well as ACO, so it is not the known Mesa ACOds_bpermutelowering bug3db536eboth tests were flaky (mixed results single-threaded); atd5442d2the masks test is now deterministic — whatever changed between those commits stabilized one of themSo the split path's cross-half ballot/bpermute handling has a live failure mode over RADV even where the hardware itself is fine — worth a look when deciding what
emit.rsshould assume.Not tested: RDNA1/2 hardware (the actual #772 question — the #518 OpenCL kernel settles it, but I have no such card), NVIDIA wave32 native for the split tests, Windows on any of this.
Counts only, no game data.
AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
upipibi commentedon Nov 24, 2026
Thanks @SlopTart, that narrows it to RDNA 1/2. One NVIDIA data point for your split-path note: on an RTX 3070 (driver 616.56, Windows 11, 32-lane waves only, so every wave64 program takes the split path natively),
gpu_split_wave64_local_and_exchanged_masks_in_diverging_wavesandgpu_split_wave64_waves_divergeboth passed in 6 of 6 fullcargo test --workspace -- --test-threads=4runs this hour (PR headsdc6fa59,e9b0186,7728d19,422f56d,bbf6c40,9683e7a, none of which change the recompiler). So the failures you see under RADV withXCL_SPLIT_WAVE64=1don't show up on NVIDIA's native wave32, which points at the forced-split-on-wave64-hardware combination rather than the split lowering itself.AI-assisted (Claude Code).
luckyteagirl commentedon Nov 24, 2026
RX 6800M hardware result
Plain
ds_bpermute_b32stayed inside each 32-lane half on this RDNA2 GPU during native wave64 execution. Both runs produced identical results.Tested
gfx1031), Windows 11 build 26200, Windows display driver30.0.13002.13003, AMD OpenCL3302.6 (PAL,LC).-cl-std=CL2.0 -Wf,-mwavefrontsize64. Inlines_bcnt1_i32_b64counted 64 active lanes inEXEC, andv_mbcnt_lo/v_mbcnt_hireturned hardware lane IDs 0 through 63. An independentv_readlane_b32of lane 63 returned 63.get_sub_group_size()reported 32 on this driver, so I used the hardware instructions to verify wave64.ds_bpermute_b32followed bys_waitcnt lgkmcnt(0). The byte address was four times the requested source lane, with no immediate offset.lane63 - lane(lane + 1) & 63The half-wave model was
(lane & 32) | (index & 31). I also checked thatemit.rsone50836bstill uses a 63 mask for wave64.Not tested
Partial
EXECmasks, nonzero immediate offsets, other GPUs and XCL's split-wave path. This was a native instruction probe on an RDNA2 laptop GPU.AI use
OpenAI Codex (GPT-6 family, exact model variant unavailable) wrote and ran the probe, checked the raw lane output, and drafted this report.
upipibi commentedon Nov 24, 2026
Thanks @luckyteagirl, that settles it for RDNA2: plain
ds_bpermute_b32in native wave64 stays within each 32-lane half, so XCL's& 63index is wrong for this console, and @SlopTart's RDNA3 result (crossing halves) shows the behaviour differs by generation. I'll prepare the fix (index(lane & 32) | (index & 31)for wave64 programs, with a GPU test built from your lane results) and link it here.AI-assisted (Claude Code).
NathanTheophile commentedon Nov 24, 2026
@upipibi, one note on the RDNA 3 result before you write the fix. It doesn't show that the behaviour differs by generation. XCL emits
WaveReadLaneAt, and on RADV that becomes a NIR shuffle, which ACO lowers throughemit_bpermute. For wave64 there, ACO emulates a whole-wave bpermute on GFX10 through GFX11.5 ("GFX10-11.5 wave64 mode: emulate full-wave bpermute"), and elsewhere it notes that "ds_bpermute is restricted to 32 lanes on GFX10-GFX11.7" (emit_bpermute, rotate fallback, the GFX10 emulation). So those tests pass on RDNA 3 whatever the hardware's ownds_bpermute_b32does, and ACO treats RDNA 3 as half-wave too. The RX 6800M probe is the only measurement of the instruction itself.In case it saves you time: a local branch with that fix passed the suite on an RTX 4060 Laptop, though only in the split form.
emit.rs, the lane is(lane_id & 0x20) | (index & 31)throughrla_half_fn, likeds_swizzle.xcl_x_rla_anyis no longer used.mainbeaa245.cargo test --workspace -- --test-threads=4gives 714 passed, 0 failed, 41 ignored, with 2 SKIPPED (no wave64).gpu_format_stores_atomics_global_lds:l ^ 31;gpu_split_wave64_cross_half_operations:l ^ 31;gpu_split_wave64_waves_diverge:l ^ 1.I'm happy to test your PR on that card when it's up.
@luckyteagirl, if you have time: a partial EXEC (e.g.
0x5555_5555_5555_5555) and a nonzero immediate offset (e.g.offset:4) are the two cases no hardware run covers yet.AI-assisted: Claude Code, Claude Opus 5.5.
nineforge0 commentedon Nov 24, 2026
Data point for prioritization: I decoded the RDNA2 machine code of all 24,804 shader records in the retail shader database (
shaders.rpfentry 0) (25,194 programs, 44.25M instructions, cross-checked length/family/wave-class against xcl's own decoder at every reachable offset).ds_permute_b32/ds_bpermute_b32appears in 0 of the 22,532 wave64 programs. It shows up only in 5 wave32 programs (74 occurrences total). So whatever the correct cross-half semantics are, this instruction is not on the critical path for this title in wave64.For context, the wave64 ops that do occur and genuinely cross the two 32-lane halves on GFX10 are: 64-bit EXEC/VCC masks (20,704 programs),
v_readfirstlane_b32(14,518),v_mbcnt_hi_u32_b32(10,034),v_readlane/v_writelanewith a constant lane 32-63 (611), and 64-bit mask scans likes_bcnt1_i32_b64(631). DPP,permlane16/permlanex16andds_swizzleall stay within a 32-lane half, so they do not need cross-half handling.Full per-stage breakdown and method: https://github.com/nineforge0/forge9/blob/main/docs/wave64_instruction_usage.md (reproduce with
forge9 isa shaders.rpf 0 --summary).Analysis produced with AI assistance (Claude Opus 5.5), directed and reviewed by the account owner. Data extracted from the account owner's own copy of the executable; no game files or keys were shared.
Edit: the source is the title's shader database (
shaders.rpfentry 0), not the pipeline cache (entry 1). The numbers are unchanged.certified-retart commentedon Nov 24, 2026
RDNA2 (
gfx1036) hardware result — partialEXEC, nonzero immediate offsets, andds_permute_b32Measured on an AMD Ryzen 7 9800X3D integrated RDNA2 GPU (
gfx1036), confirming the RX 6800M (gfx1031) half-wave result and covering the two cases @NathanTheophile asked for (partialEXECand nonzero immediateoffset), plusds_permute_b32(for #925).Hardware & setup
gfx1036, Ryzen 7 9800X3D iGPU), Windows 10 Pro build 19045, display driver32.0.21030.2001, AMD OpenCL2.1 AMD-APP (3652.0)/3652.0 (PAL,LC).-cl-std=CL2.0 -Wf,-mwavefrontsize64. Every run verifieds_bcnt1_i32_b64of initialEXEC == 64,v_mbcnt_lo/v_mbcnt_hilane IDs0..63,v_readlane_b32(lane, 63) == 63, ands_bcnt1_i32_b64afters_and_saveexec_b64matched the test mask's popcount.CL_PROGRAM_BINARIES) that all 7ds_bpermute_b32(0xDACCxxxx) and 6ds_permute_b32(0xDAC8xxxx) kernels emitted a single raw hardware instruction with the exact 16-bit immediate offset (0, 4, 2, 128, 132, 252, 65532and0, 4, 2, 128, 132, 65532) — no compiler wave64 lowering.1000 + lane(so a0from an inactive source is distinct from lane0), anddstwas pre-loaded with0xDEADBEEFbefores_and_saveexec_b64to verify inactive destination lanes are untouched. Every case ran twice with identical results.Half-wave models checked
ds_bpermute_b32: active lanelreadssrc = (l & 32) | (((addr[l] + offset) >> 2) & 31); returnsdata[src]ifsrcis active inEXEC, else0. Inactivelleavesdstunchanged (0xDEADBEEF).ds_permute_b32: active senderssendsdata[s]todst = (s & 32) | (((addr[s] + offset) >> 2) & 31); highest active sender in that half wins; active lane with no active sender gets0; inactive lanes neither send nor receive (dststays0xDEADBEEF).ds_bpermute_b32results (21/21 cases matched half-wave 64/64)EXEC,addr,offset)EXEC,4*(63-l),offset:0l0=1031,l31=1000,l32=1063,l63=1032EXEC,4*(l^32),offset:0l0=1000,l31=1031,l32=1032,l63=10630x5555_5555_5555_5555,4*((62-l)&63),offset:0l0=1030,l32=1062; odd lanes stay0xDEADBEEF0x5555_5555_5555_5555,4*((l+1)&63),offset:000x5555_5555_5555_5555,4*((l+2)&63),offset:0l30=1000,l62=1032(wraps within half)0xAAAA_AAAA_5555_5555,4*(l^32),offset:0l0=1000,l63=1063(active in own half, would be inactive in other half)0x0000_0000_FFFF_FFFF,4*(l^32),offset:0l0=1000..l31=1031(reads own active half, not inactive upper half)0xFFFF_FFFF_0000_0000,4*(l^32),offset:0l32=1032..l63=1063EXEC,4*l,offset:4l31=1000,l63=1032EXEC,4*(63-l),offset:4l0=1000,l1=1031,l32=1032,l63=10330x5555_5555_5555_5555,4*l,offset:4l+1(inactive) →00x5555_5555_5555_5555,4*((l+1)&63),offset:4l0=1002,l30=1000,l32=1034,l62=1032EXEC,4*l+2,offset:0vsoffset:2off:2)off:0:l0=1000, l31=1031;off:2:l0=1001, l31=1000, l32=1033, l63=1032— confirms byte add(addr + offset) >> 2carries bit 1 into bit 2EXEC,4*l,offset:128(+32 lanes)l0=1000,l32=1032—+128bytes does not cross halvesEXEC,4*l,offset:132(+33 lanes)l0=1001,l31=1000,l32=1033,l63=1032EXEC,4*l,offset:65532l0=1031,l32=1063ds_permute_b32results (17/17 cases matched half-wave 64/64)EXEC,addr,offset)EXEC,4*(63-l),offset:0l0=1031,l31=1000,l32=1063,l63=1032EXEC,0(all 64 lanes send to 0),offset:0l0=1031,l32=1063, all other lanes0(each half resolves its own highest sender independently)0x5555_5555_5555_5555,4*((l+2)&63),offset:0l0=1030,l32=1062; odd lanes stay0xDEADBEEF0xAAAA_AAAA_5555_5555,4*(l^32),offset:0l0=1000,l63=1063EXEC,4*l,offset:4l0=1031,l1=1000,l32=1063,l33=1032EXEC,4*l+2,offset:0vsoffset:2off:2)off:0:l0=1000;off:2:l0=1031,l32=1063EXEC,4*l,offset:128(+32 lanes)l0=1000,l32=1032Both instructions follow the exact same
(lane & 32) | (((addr + offset) >> 2) & 31)rule in native wave64 on RDNA2, with per-half active-lane checking (EXEC) and byte-level addition of the 16-bit immediateoffsetbefore>> 2.Not tested
ds_bpermute/ds_permuteinside XCL's translated HLSL or split-wave64 path, or retail titles.AI use
gemini-4-neon) wrote and ran the OpenCL probe, verified the compiled ELF opcodes, and drafted this report.SlopTart commentedon Nov 24, 2026
Correction to my earlier comment here, prompted by @NathanTheophile's Mesa reading. I wrote that our RDNA3 passes show "the permute does cross halves as the opcode table says" - that inference was wrong. ACO emulates the full-wave bpermute for wave64 on GFX10 through GFX11.5 regardless of what the hardware instruction does, so our
gpu_ds_*passes over RADV say nothing about the realds_bpermute_b32behavior on RDNA3. They only show XCL's emitted NIR shuffle crosses halves as ACO lowers it. The RX 6800M native probe stands as the only direct hardware measurement in this thread, and my "the within-half reading is not a general RDNA behavior" line should be read as "not a general Mesa-lowered behavior".The split-path failures I reported (
gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves12/12,gpu_split_wave64_waves_diverge9/12 underXCL_SPLIT_WAVE64=1on RADV) stand as measured - they are in the split emulation path, and the NVIDIA native-wave32 contrast @upipibi posted still sharpens them.Happy to run the half-wave fix when it lands - my rig also has the forced-split-on-wave64 combination nobody else covers.
AI use: Hermes agent (local Qwen-class) drafted this; I checked it before posting.
upipibi commentedon Nov 24, 2026
Fix with a GPU test built from the measured lane results (@luckyteagirl's patterns plus @certified-retart's offsets and partial-EXEC case): #1022. It ran in the split form only (RTX 3070); a native wave64 run would still be welcome.
AI-assisted (Claude Code).
SlopTart commentedon Nov 24, 2026
Follow-up from my RDNA3/Wine row on this thread (comment 7123193308 and the correction below it): the split-wave64 suite on this rig has moved to a much worse floor today, and I want to put the numbers up since #1022's author and I both flagged split-mode instability.
Current main
47efa2e,XCL_SPLIT_WAVE64=1, solo--exactruns,--test-threads=1, 6 reps each:gpu_split_wave64_waves_diverge: 0/6gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves: 0/6gpu_split_wave64_masks_read_whole_after_partial_writes: 0/6gpu_split_wave64_cross_half_operations: 0/6gpu_split_wave64_lane_local_masks: 6/6 (the one that never touches cross-half traffic)For contrast, my posted measurement earlier today on this rig was 12/12 on the masks tests and 9/12 on
waves_diverge(sowaves_divergewas already flaky-red 3/12 then). One solo run earlier today still passedwaves_diverge, then it went 0/6 on an unchanged checkout - the instability band has slid from "mostly green" to "mostly red".What I ruled out on the rig side: same commit passed and failed within ~10 minutes; main did not move between the pass and the streak; Mesa 26.2.5 / kernel 7.2 / DXC 1.9.2609.5 unchanged (pacman log + file listing); my patched vkd3d-proton dlls are byte-identical to the ones that measured 12/12 (sha256
73c6e076...); no on-disk DXIL cache exists under the prefix. I also rebuilt the era-era pin1ec4c98(before the allocator-pool and bpermute merges) and it shows the same mixed-or-red pattern in combined runs today (1/4, 2/3, 2/3 failures over 6 runs), so this is not a change between1ec4c98and47efa2e- it is run-to-run state that has drifted on the Wine+RADV side.Failure signature is stable in shape, unstable in values: diverging-wave loop comparisons mismatch (example:
group 0 thread 192: loop of wave 3, left 1402 right 1864), different numbers per run, GPU-computed comparisons fail with no panic text on the CPU side. Consistent with the nondeterministic cross-half exchange behavior I flagged in my correction above; the exchange now loses the race far more often than this morning.ACO/llvm fork test on the four failing tests (
RADV_DEBUG=llvm, same commit, same solo mode, 2 reps each): failures persist, 7/8 red (waves_diverge0/2,local_and_exchanged_masks1/2,masks_read_whole0/2,cross_half0/2). So the ACO lowering is not the variable, matching my earlier fork tests on this rig. One rig-side timing candidate I cannot prove or exclude: this GPU also serves a local LLM (strata) whose load varies between measurements, and this rig has logged amdgpu scheduler-priority oddities under mixed load. A shader-level race in the split-half exchange that is timing-sensitive would fit everything above.Counts only, no game data. Full per-run logs available.
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.AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
SzczepanGrela commentedon Nov 24, 2026
@SlopTart The four
gpu_split_wave64_*failures above are the same Mesa26.2.5NIR issue we just captured on #847 (#847 (comment)), not an issue with #1022.Verified on RX 9070 (RADV GFX1201, Mesa
26.2.5-arch3.1, kernel7.3.0-5-cachyos,GE-Proton11-12+vkd3d-protonv3.1-1-g8293130eb,main1ec4c98, release MSVC,XCL_SPLIT_WAVE64=1,XCL_NETWORK=0, solo--exact --test-threads=1):SPIN=1)SPIN=0)gpu_split_wave64_waves_divergegpu_split_wave64_local_and_exchanged_masks_in_diverging_wavesgpu_split_wave64_masks_read_whole_after_partial_writesgpu_split_wave64_cross_half_operationsgpu_split_wave64_lane_local_masksRADV_DEBUG=shaderson bothcross_half_operations(offset:512) andwaves_diverge(offset:2048) shows the same hoisting as in #847: Mesa NIR lowersInterlockedAdd(XCL_XC(...), 0u, c)to@load_shared (access=atomic)and eliminates the loop-body read, leaving a singleds_load_b32before the0xfffffloop and zero LDS reads inside it. That also explains whyRADV_DEBUG=llvmstill fails (verified here oncross_half_operations:0/3default vs3/3withXCL_WAVE64_SPIN=0), since the elimination happens in NIR before ACO or LLVM. Both 64-thread tests fail with half-divergence (s0: 0x20 / 0x28, missing the other half's bits) and go5/5withXCL_WAVE64_SPIN=0; the 256-thread tests stay0/5becauseemit.rs:4177forcesXCL_X_SPIN 1wheneverthreads > 64.Not tested: PR #1022 checkout, RX 7900 XT (RDNA3), or
47efa2e.AI use: Antigravity (Gemini 4 Neon) ran the test loops and
RADV_DEBUG=shadersdumps on my machine and drafted this comment; I reviewed the results before posting.Diskuss commentedon Nov 24, 2026
RDNA4 native Windows result: plain
ds_bpermute_b32in native wave64 crosses halves (index mod 64) on RX 9070 XT. So the half-wave behaviour @luckyteagirl and @certified-retart measured is specific to RDNA2 (and maybe RDNA1), not to RDNA in general.AMD Radeon RX 9070 XT (RDNA4,
gfx1201), driver 32.0.32015.7029, AMD OpenCL3683.0 (PAL,LC); Windows 11 Pro 26300; DXC 1.9.2602.17;mainc160d86ef2efe3a07e4dfb473e4fa72eafb413c0, debug.Hardware probe (same method as #518 and @luckyteagirl): one 64-item OpenCL workgroup,
-cl-std=CL2.0 -Wf,-mwavefrontsize64, inline asmds_bpermute_b32 r, 4*idx, 1000+lanethens_wait_dscnt 0. Inlines_bcnt1_i32_b64 exec= 64,v_mbcnt_lo/hilane IDs 0..63,v_readlane_b32 ..., 63= 63. Two runs, identical:(l&32)|(idx&31)lane63 - lane(lane+1) & 63lane ^ 32Control: the same kernel built for wave32 (no
-mwavefrontsize64,execcount 32) gives the within-32 result 64/64, so the probe tells the two apart.XCL tests, native wave64 here (adapter runs 64-lane waves, not the split form):
cargo test -p xcl --lib cross_half(2 tests, incl.gpu_split_wave64_cross_half_operations) 3/3 passed;bpermute(gpu_ds_swizzle_and_bpermute_zero_inactive_lanes) 3/3 passed. Those go throughWaveReadLaneAt, so they show the driver's lowering, not the raw instruction; the probe above is the raw instruction.For XCL this doesn't change #1022: the console is RDNA2, so its half-wave rule is the one to emulate. It does mean a test can't use the host GPU's raw
ds_bpermuteas reference on RDNA4.Investigation by Claude Code (Claude Opus 5.5) on this machine.
Recompiler: ds_bpermute_b32 in wave64 stays in each 32-lane half (xcl…
cindertheblue commentedon Nov 25, 2026
RDNA3 native Windows result: plain
ds_bpermute_b32in native wave64 stays within each 32-lane half on an RX 7600 XT (gfx1102), as on RDNA2. So the half-wave behaviour is not RDNA2-only: so far it is RDNA2 and RDNA3 within halves, RDNA4 (@Diskuss's RX 9070 XT) across. This fits the ACO note @NathanTheophile quoted ("ds_bpermute is restricted to 32 lanes on GFX10-GFX11.7").Hardware probe (same method as #518, @luckyteagirl and @Diskuss): one 64-item OpenCL workgroup,
-cl-std=CL2.0 -Wf,-mwavefrontsize64, inline asmds_bpermute_b32 r, 4*idx, 1000+lanethens_waitcnt lgkmcnt(0). In every run all 64 lanes passed the wave64 checks: inlines_bcnt1_i32_b64 exec= 64,v_mbcnt_lo/hilane IDs 0..63,v_readlane_b32 …, 63= 63. Two runs per pattern, identical:(l&32)|(idx&31)lane63 - lane(lane+1) & 63CL_PROGRAM_BINARIES,gfx1102ELF): its.texthas exactly one DS-encoded instruction,ds_bpermute_b32(dacc0000 01000201, op 179, offset 0). A full-wave emulation by the compiler would have given the mod-64 results, so this is the plain instruction's behaviour.3679.0and3652.0, which compiled different code objects), and recomputed from the raw per-lane values: with each runtime, 0 of the 384 reads (3 patterns × 2 runs × 64 lanes) came from the other half.gfx1036, RDNA2) gives the same table, matching @certified-retart'sgfx1036and @luckyteagirl'sgfx1031results (l0 reads lane 31, l32 reads 63, l63 reads 32).Setup: AMD Radeon RX 7600 XT 16 GB (RDNA3,
gfx1102), display driver 32.0.31041.1004 (AMD Software 26.8.1), AMD OpenCL3679.0 (PAL,LC)and3652.0 (PAL,LC)(platform "AMD Accelerated Parallel Processing", OpenCL 2.1); Ryzen 5 9600X; Windows 11 Home 26200.9974. The host program is a small Rust program callingOpenCL.dlldirectly; the kernel:kernel
Update: partial
EXEC, immediate offsets andds_permute_b32on the same card are all half-wave too. Same setup and checks, with @certified-retart's RDNA2 case set: 20ds_bpermute_b32cases (offsets 0, 2, 4, 128, 132, 252, 65532) and 11ds_permute_b32cases (offsets 0, 2, 4, 128, 132, 65532).EXECis set inside the asm withs_and_saveexec_b64and restored after (s_bcnt1_i32_b64 execinside matched the mask's popcount in every case), the source is1000 + lane, anddstis preloaded with0xDEADBEEFto show which lanes are left alone.ds_bpermute_b32lanelreads(l & 32) | (((addr + offset) >> 2) & 31)(0 from an inactive source, inactiveluntouched);ds_permute_b32sends within the sender's half, the highest active sender wins, an active lane nobody sends to gets 0, inactive lanes neither send nor receive.3679.0,3652.0) and on this machine'sgfx1036iGPU; the mod-64 counts and the sample lanes match @certified-retart's table..texthas 13 DS instructions, one per kernel:ds_bpermute_b32with offsets 0, 2, 4, 128, 132, 252, 65532 andds_permute_b32with 0, 2, 4, 128, 132, 65532.all 31 cases (RX 7600 XT, OpenCL 3679.0; DEAD = 0xDEADBEEF, left untouched)
EXECds_bpermute_b324*lds_bpermute_b324*(63-l)ds_bpermute_b324*((l+1)&63)ds_bpermute_b324*(l^32)ds_bpermute_b320x55555555_555555554*((62-l)&63)ds_bpermute_b320x55555555_555555554*((l+1)&63)ds_bpermute_b320x55555555_555555554*((l+2)&63)ds_bpermute_b320xAAAAAAAA_555555554*(l^32)ds_bpermute_b320x00000000_FFFFFFFF4*(l^32)ds_bpermute_b320xFFFFFFFF_000000004*(l^32)ds_bpermute_b324*lds_bpermute_b324*(63-l)ds_bpermute_b320x55555555_555555554*lds_bpermute_b320x55555555_555555554*((l+1)&63)ds_bpermute_b324*l+2ds_bpermute_b324*l+2ds_bpermute_b324*lds_bpermute_b324*lds_bpermute_b324*lds_bpermute_b324*lds_permute_b324*lds_permute_b324*(63-l)ds_permute_b320 (all to lane 0)ds_permute_b320x55555555_555555554*((l+2)&63)ds_permute_b320xAAAAAAAA_555555554*(l^32)ds_permute_b324*lds_permute_b324*l+2ds_permute_b324*l+2ds_permute_b324*lds_permute_b324*lds_permute_b324*lNot tested: other RDNA3 chips (
gfx1100/gfx1101). (#1022 on this card: see my comment there.)AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them and wrote this comment from their output.
Recompiler: ds_bpermute_b32 in wave64 stays in each 32-lane half (xcl…
Direct DXIL: ds_bpermute_b32 in wave64 stays in each 32-lane half (xc…
Tests: split_wave64_reduction_tail_rules counts 2 prelude meets