Recompiler: the split-wave64 mask analyses leave out exchanges a program needs (root cause of #505's out-of-step halves) #3758

Open
opened 2026-12-03 02:45:23 +00:00 by throny · 2 comments
throny commented 2026-12-03 02:45:23 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by throny on 2026-12-03T02:45:23Z.


What's wrong. On 32-lane GPUs a split 64-lane wave runs as two halves that exchange their masks at set points. Two analyses leave out exchanges they find unneeded: the half-local mask analysis (gpu/recomp/x64_masks.rs) and the lazy planner (gpu/dxil/kernel.rs, mask_exchange::plan_of). In some programs they leave out one that is needed. The halves fall out of step, the next exchange gives up after its spin limit, and the wave reads zeros from then on. On #505 that showed as a dark, dotted picture and 31-40 ms GPU calls. Found by theaustinayers, with data from KDenKC and us.

Now. #3748 keeps every exchange by default. XCL_X64_PRECISE_MASKS=1 turns the analyses back on and brings the problem back. Open PRs that leave out more exchanges (#1111, #1193) build on the same analyses.

What's needed. The pattern the analyses get wrong. A first step: with XCL_X64_PRECISE_MASKS=1 and a longer spin limit (theaustinayers' local XCL_X_SPIN_LIMIT), log which program and which exchange site a half gives up at, then reduce that program to a test that fails on the GPU. KDenKC's list on #505 names seven compute programs with 31.4-31.9 ms calls.

AI use: Claude Code (Claude Opus 5.5) wrote this at throny's request.

<!-- greyfinch-sync:ivall/xcl:issue:6759436912 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/3758). Originally posted by [throny](https://github.com/throny) on 2026-12-03T02:45:23Z. --- **What's wrong.** On 32-lane GPUs a split 64-lane wave runs as two halves that exchange their masks at set points. Two analyses leave out exchanges they find unneeded: the half-local mask analysis (`gpu/recomp/x64_masks.rs`) and the lazy planner (`gpu/dxil/kernel.rs`, `mask_exchange::plan_of`). In some programs they leave out one that is needed. The halves fall out of step, the next exchange gives up after its spin limit, and the wave reads zeros from then on. On #505 that showed as a dark, dotted picture and 31-40 ms GPU calls. Found by theaustinayers, with data from KDenKC and us. **Now.** #3748 keeps every exchange by default. `XCL_X64_PRECISE_MASKS=1` turns the analyses back on and brings the problem back. Open PRs that leave out more exchanges (#1111, #1193) build on the same analyses. **What's needed.** The pattern the analyses get wrong. A first step: with `XCL_X64_PRECISE_MASKS=1` and a longer spin limit (theaustinayers' local `XCL_X_SPIN_LIMIT`), log which program and which exchange site a half gives up at, then reduce that program to a test that fails on the GPU. KDenKC's list on #505 names seven compute programs with 31.4-31.9 ms calls. *AI use: Claude Code (Claude Opus 5.5) wrote this at throny's request.*
CharlyRien commented 2026-12-03 10:00:20 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-03T10:00:20Z.


Twelve small synthetic programs reproduce this deterministically on an RTX 3090 (driver 621.47, Windows 11 22631). They come from the #3716 wave64 fuzzer, are compute programs in the direct split form, and contain no data from any application. With the analyses on (the default on main), all 12 give wrong words in every run so far. With XCL_X64_ALL_MASKS=1 (= #3748's default) all 12 are right.

tree default XCL_X64_ALL_MASKS=1
main 5ad98adb + #3716 d2293dcb + a test-only probe + a local change that passes group-shared indices instead of pointers to the split helpers 12 / 12 wrong 12 / 12 right
#3707 7b19e27d + #3716 d2293dcb + the same probe 12 / 12 wrong 12 / 12 right

Seeds: 155, 525, 824, 1869, 1000823, 1001176, 1001212, 1001676, 1001998, 2000677, 3000171, 3000294. Four controls (2, 10, 11, 188) are right either way. On main 5ad98adb + #3716 with the helpers as they are, turning off only the lazy planner (a local probe) also made all 12 right. The DXIL of the default form gives the reference words in a CPU interpreter that runs the two halves in a fixed interleaving. So the wrong words come from how the GPU runs that DXIL, not from the translation's logic. I first read that as the halves getting out of step; a first reduction (below, when confirmed) points instead to the lower half's own word of one compare being read as 0 on the 3090, with the exchange still paired.

To run them: branch probe/direct-split-nv (main 5ad98adb + #3716 + an ignored probe):

cargo test -p xcl --lib direct_split_driver_probe -- --ignored --nocapture --test-threads=1

It prints one SUMMARY line; G6=n/12 counts these programs that match the RDNA2 reference. Set XCL_X64_ALL_MASKS=1 to compare. A 3070 Laptop GPU (621.40) gave G6=1/12 in the default form (on #3779), so it is not only this card. I am now separating which of the two analyses the failure needs, and will post the reduced program here.

AI use: Claude Code (Claude Opus 5.5) ran the fuzz programs on the 3090 and in the CPU interpreter and wrote this; checked and posted by me.

<!-- greyfinch-sync:ivall/xcl:comment:7374594478 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/3758#issuecomment-7374594478). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-12-03T10:00:20Z. --- Twelve small synthetic programs reproduce this deterministically on an RTX 3090 (driver 621.47, Windows 11 22631). They come from the #3716 wave64 fuzzer, are compute programs in the direct split form, and contain no data from any application. With the analyses on (the default on `main`), all 12 give wrong words in every run so far. With `XCL_X64_ALL_MASKS=1` (= #3748's default) all 12 are right. | tree | default | `XCL_X64_ALL_MASKS=1` | |---|---|---| | `main` `5ad98adb` + #3716 `d2293dcb` + a test-only probe + a local change that passes group-shared indices instead of pointers to the split helpers | 12 / 12 wrong | 12 / 12 right | | #3707 `7b19e27d` + #3716 `d2293dcb` + the same probe | 12 / 12 wrong | 12 / 12 right | Seeds: 155, 525, 824, 1869, 1000823, 1001176, 1001212, 1001676, 1001998, 2000677, 3000171, 3000294. Four controls (2, 10, 11, 188) are right either way. On `main` `5ad98adb` + #3716 with the helpers as they are, turning off only the lazy planner (a local probe) also made all 12 right. The DXIL of the default form gives the reference words in a CPU interpreter that runs the two halves in a fixed interleaving. So the wrong words come from how the GPU runs that DXIL, not from the translation's logic. I first read that as the halves getting out of step; a first reduction (below, when confirmed) points instead to the lower half's own word of one compare being read as 0 on the 3090, with the exchange still paired. To run them: branch [`probe/direct-split-nv`](https://github.com/CharlyRien/xcl/tree/probe/direct-split-nv) (`main` `5ad98adb` + #3716 + an ignored probe): ``` cargo test -p xcl --lib direct_split_driver_probe -- --ignored --nocapture --test-threads=1 ``` It prints one `SUMMARY` line; `G6=n/12` counts these programs that match the RDNA2 reference. Set `XCL_X64_ALL_MASKS=1` to compare. A 3070 Laptop GPU (621.40) gave `G6=1/12` in the default form ([on #3779](https://github.com/xcl-dev/xcl/issues/3779#issuecomment-7373655152)), so it is not only this card. I am now separating which of the two analyses the failure needs, and will post the reduced program here. AI use: Claude Code (Claude Opus 5.5) ran the fuzz programs on the 3090 and in the CPU interpreter and wrote this; checked and posted by me.
CharlyRien commented 2026-12-03 10:55:24 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-03T10:55:24Z.


Follow-up with the reduced program, and a split between the two analyses. This is about one program on one GPU. In it, no exchange is left out and none gives up. The analyses keep one compare's mask as a half-local pair. The RTX 3090 then reads the lower half's own word of that pair as 0.

Which analysis. We ran 17 cases on one test exe, the reduced program, the 12 seeds and the 4 controls, with one switch at a time. The tree is #3707 7b19e27d + #3716 d2293dcb + test-only probes; the GPU is an RTX 3090, driver 621.47.

form wrong cases
default 13 (reduced program + the 12 seeds)
lazy planner off (plan_of(.., lazy = false), local probe) 0
half-local masks off (whole_live cleared, so every ballot is exchanged where it is made; plan unchanged; local probe) 0
local EXEC skips off (plan_of(skip = false), local probe) 9 (reduced program + 155, 525, 824, 1000823, 1001676, 2000677, 3000171, 3000294)
XCL_X64_ALL_MASKS=1 0

The controls 2, 10, 11 and 188 are right in every form. Turning off either analysis alone is enough. Turning off the local skips is not.

Reduced program. Seed 1000823 shrinks to 120 instructions: 96 threads, 2 groups, s0 = 0xFFFFFFFA, memory zeroed. It gives 128 wrong words: v1 in both groups.

  • Threads 0-31 (the lower half of console wave 0) read 0.
  • Threads 64-95 (console wave 1, a lower half with no partner) keep their first v1.
  • Threads 32-63 are right.
  • The result is the same on the #3716 tree (616.56) and on the #3707 tree (621.47).

The part that matters:

#64 pc 456  v_cmp_ne_u32       s[40:41], v10, v4
#65 pc 464  s_and_saveexec_b64 s[42:43], s[40:41]
#66 pc 468  s_cbranch_execz    -> #71              ; EXEC read whole
#67 pc 472  s_or_saveexec_b64  s[46:47], -1
#68 pc 476  v_cndmask_b32      v17, 0, v12, s[46:47]
#69 pc 484  v_mov_b32          v1, v17
#70 pc 488  s_mov_b64          exec, s[46:47]
#71 pc 492  s_andn2_b64        exec, s[42:43], s[40:41]
The whole program (120 instructions)
#0   pc 0    v_mad_u32_u24        v1, v0, 1, 0x9e3779b9
#1   pc 12   v_mad_u32_u24        v2, v0, 2, 0x3c6ef372
#2   pc 24   v_mad_u32_u24        v3, v0, 3, 0xdaa66d2b
#3   pc 36   v_mad_u32_u24        v4, v0, 4, 0x78dde6e4
#4   pc 48   v_mad_u32_u24        v5, v0, 5, 0x1715609d
#5   pc 60   v_mad_u32_u24        v6, v0, 6, 0xb54cda56
#6   pc 72   v_mad_u32_u24        v7, v0, 7, 0x5384540f
#7   pc 84   v_mad_u32_u24        v8, v0, 8, 0xf1bbcdc8
#8   pc 96   v_mad_u32_u24        v9, v0, 9, 0x8ff34781
#9   pc 108  v_mad_u32_u24        v10, v0, 10, 0x2e2ac13a
#10  pc 120  v_mad_u32_u24        v11, v0, 11, 0xcc623af3
#11  pc 132  v_mad_u32_u24        v12, v0, 12, 0x6a99b4ac
#12  pc 144  v_mad_u32_u24        v13, v0, 13, 0x8d12e65
#13  pc 156  v_mad_u32_u24        v14, v0, 14, 0xa708a81e
#14  pc 168  v_mad_u32_u24        v15, v0, 15, 0x454021d7
#15  pc 180  v_mad_u32_u24        v16, v0, 16, 0xe3779b90
#16  pc 192  v_and_b32            v13, 7, v13
#17  pc 196  v_cvt_f32_i32        v13, v13
#18  pc 200  v_and_b32            v14, 7, v14
#19  pc 204  v_cvt_f32_i32        v14, v14
#20  pc 208  v_and_b32            v15, 7, v15
#21  pc 212  v_cvt_f32_i32        v15, v15
#22  pc 216  v_and_b32            v16, 7, v16
#23  pc 220  v_cvt_f32_i32        v16, v16
#24  pc 224  s_mul_i32            s4, s0, 0x17af29ac
#25  pc 232  s_mul_i32            s5, s0, 0x9d9af417
#26  pc 240  s_mul_i32            s6, s0, 0x2386be82
#27  pc 248  s_mul_i32            s7, s0, 0xa97288ed
#28  pc 256  s_mul_i32            s8, s0, 0x2f5e5358
#29  pc 264  s_mul_i32            s9, s0, 0xb54a1dc3
#30  pc 272  s_mul_i32            s10, s0, 0x3b35e82e
#31  pc 280  s_mul_i32            s11, s0, 0xc121b299
#32  pc 288  s_mul_i32            s12, s0, 0x470d7d04
#33  pc 296  s_mul_i32            s13, s0, 0xccf9476f
#34  pc 304  s_mul_i32            s14, s0, 0x52e511da
#35  pc 312  s_mul_i32            s15, s0, 0xd8d0dc45
#36  pc 320  s_mov_b64            s[60:61], exec
#37  pc 324  v_cmp_ne_u32         s[40:41], v8, v3
#38  pc 332  s_and_saveexec_b64   s[42:43], s[40:41]
#39  pc 336  s_cbranch_execz      -> #40
#40  pc 340  s_andn2_b64          exec, s[42:43], s[40:41]
#41  pc 344  s_cbranch_execz      -> #55
#42  pc 348  v_cmp_gt_u32         s[44:45], v11, v10
#43  pc 356  s_and_saveexec_b64   s[46:47], s[44:45]
#44  pc 360  s_cbranch_execz      -> #52
#45  pc 364  v_cmp_lt_u32         s[48:49], v10, v8
#46  pc 372  s_and_saveexec_b64   s[50:51], s[48:49]
#47  pc 376  s_cbranch_execz      -> #49
#48  pc 380  v_cndmask_b32        v3, 38, v1, vcc
#49  pc 384  s_andn2_b64          exec, s[50:51], s[48:49]
#50  pc 388  s_cbranch_execz      -> #51
#51  pc 392  s_mov_b64            exec, s[50:51]
#52  pc 396  s_andn2_b64          exec, s[46:47], s[44:45]
#53  pc 400  s_cbranch_execz      -> #54
#54  pc 404  s_mov_b64            exec, s[46:47]
#55  pc 408  s_mov_b64            exec, s[42:43]
#56  pc 412  s_or_saveexec_b64    s[42:43], -1
#57  pc 416  v_cndmask_b32        v17, 0, v10, s[42:43]
#58  pc 424  v_readlane_b32       s36, v17, 32
#59  pc 432  v_readlane_b32       s37, v17, 0
#60  pc 440  v_mov_b32            v18, s36
#61  pc 444  v_add_nc_u32         v17, s37, v18
#62  pc 448  v_mov_b32            v5, v17
#63  pc 452  s_mov_b64            exec, s[42:43]
#64  pc 456  v_cmp_ne_u32         s[40:41], v10, v4
#65  pc 464  s_and_saveexec_b64   s[42:43], s[40:41]
#66  pc 468  s_cbranch_execz      -> #71
#67  pc 472  s_or_saveexec_b64    s[46:47], -1
#68  pc 476  v_cndmask_b32        v17, 0, v12, s[46:47]
#69  pc 484  v_mov_b32            v1, v17
#70  pc 488  s_mov_b64            exec, s[46:47]
#71  pc 492  s_andn2_b64          exec, s[42:43], s[40:41]
#72  pc 496  s_cbranch_execz      -> #73
#73  pc 500  s_mov_b64            exec, s[42:43]
#74  pc 504  s_mov_b64            exec, s[60:61]
#75  pc 508  s_mul_i32            s62, s1, 0x2a00
#76  pc 516  v_mul_u32_u24        v24, 0x70, v0
#77  pc 524  v_add_nc_u32         v24, s62, v24
#78  pc 528  v_mov_b32            v25, 0
#79  pc 532  v_mov_b32            v22, s4
#80  pc 536  global_store_dword   v[24:25], v22, off offset:64
#81  pc 544  v_mov_b32            v22, s5
#82  pc 548  global_store_dword   v[24:25], v22, off offset:68
#83  pc 556  v_mov_b32            v22, s6
#84  pc 560  global_store_dword   v[24:25], v22, off offset:72
#85  pc 568  v_mov_b32            v22, s7
#86  pc 572  global_store_dword   v[24:25], v22, off offset:76
#87  pc 580  v_mov_b32            v22, s8
#88  pc 584  global_store_dword   v[24:25], v22, off offset:80
#89  pc 592  v_mov_b32            v22, s9
#90  pc 596  global_store_dword   v[24:25], v22, off offset:84
#91  pc 604  v_mov_b32            v22, s10
#92  pc 608  global_store_dword   v[24:25], v22, off offset:88
#93  pc 616  v_mov_b32            v22, s11
#94  pc 620  global_store_dword   v[24:25], v22, off offset:92
#95  pc 628  v_mov_b32            v22, s12
#96  pc 632  global_store_dword   v[24:25], v22, off offset:96
#97  pc 640  v_mov_b32            v22, s13
#98  pc 644  global_store_dword   v[24:25], v22, off offset:100
#99  pc 652  v_mov_b32            v22, s14
#100 pc 656  global_store_dword   v[24:25], v22, off offset:104
#101 pc 664  v_mov_b32            v22, s15
#102 pc 668  global_store_dword   v[24:25], v22, off offset:108
#103 pc 676  global_store_dword   v[24:25], v1, off offset:0
#104 pc 684  global_store_dword   v[24:25], v2, off offset:4
#105 pc 692  global_store_dword   v[24:25], v3, off offset:8
#106 pc 700  global_store_dword   v[24:25], v4, off offset:12
#107 pc 708  global_store_dword   v[24:25], v5, off offset:16
#108 pc 716  global_store_dword   v[24:25], v6, off offset:20
#109 pc 724  global_store_dword   v[24:25], v7, off offset:24
#110 pc 732  global_store_dword   v[24:25], v8, off offset:28
#111 pc 740  global_store_dword   v[24:25], v9, off offset:32
#112 pc 748  global_store_dword   v[24:25], v10, off offset:36
#113 pc 756  global_store_dword   v[24:25], v11, off offset:40
#114 pc 764  global_store_dword   v[24:25], v12, off offset:44
#115 pc 772  global_store_dword   v[24:25], v13, off offset:48
#116 pc 780  global_store_dword   v[24:25], v14, off offset:52
#117 pc 788  global_store_dword   v[24:25], v15, off offset:56
#118 pc 796  global_store_dword   v[24:25], v16, off offset:60
#119 pc 804  s_endpgm

DXIL at that site.

Default form (the pair stays half-local; the halves only exchange EXEC, at the branch; value names shortened):

%288 = WaveActiveBallot(v10 != v4)
%289 = select i1 %upper, i32 0, i32 %288     ; lower word of the pair
%290 = and i32 %289, %exec_lo                 ; EXEC word of the lower half
%291 = and i32 %288, %exec_own                ; (upper half: its own EXEC word)
%292 = select i1 %upper, i32 %291, i32 %290  ; own word, also sent to the other half
...    exchange of EXEC, then
%365 = select i1 %upper, i32 %recv, i32 %290
%366 = select i1 %upper, i32 %291, i32 %recv
br (%365 | %366) == 0                        ; pc 468
...    then the lane's bit: (%292 >> lane) & 1
  • Lazy planner off: the raw ballot is sent at the compare. Both words come from select(upper, recv, ballot), and there is no select(upper, 0, ballot).
  • Half-local masks off: the ballot is exchanged at the compare, and EXEC is still exchanged at the branch. The lower word becomes and(select(upper, recv, ballot), exec_lo). It is the same value as the default form's %290 in the lower half.
  • In all four DXILs of the reduced program, the forms that pass have no select(upper, 0, ballot) at this site; the default has one.

Not out of step (measured on the CPU). A small interpreter of the emitted DXIL runs the lanes of a wave together and joins them at post-dominators. It interleaves the waves at random and runs the spin loop as written. On the default DXIL it gives the reference words, both exchanges pair up, and no wait reaches its limit.

To match the 3090, we zeroed each of the 296 values of main, one at a time, in the lower halves and then in both halves.

  • Only the chain of the lower half's own word gives exactly the 3090's 128 words: v10 != v4, its ballot, select(upper, 0, ballot), exec_lo, and their and.
  • A give-up at either exchange (the received word read as 0) gives other words, or the right ones.
  • The 3090's words also show that the lower half received the upper half's word. It entered the block with its own word at 0 and wrote v1 = 0. The lone half with no partner did not enter.

So, for this issue: in this program the analyses move the exchange from the compare to the EXEC branch, which is correct in the interpreter. The failure needs the half-local pair select(upper, 0, ballot) that they leave in place of the exchange. It is close to #3779's shape (select(upper, 0, X), then a lane-bit test). But reading the word from the first lane before the bit test does not fix these 12 programs: the branch reads 0 too. The #505 programs may still be a real left-out exchange; this result does not show that either way.

Stack.

  • Split table: #3707 7b19e27d (on main 078358a0) + #3716 d2293dcb + local test-only probes. They switch XCL_PROBE_PLAN_MODE=nolazy|noskip (passes lazy / skip = false to plan_of) and XCL_PROBE_NO_HALFLOCAL (clears Lw::whole_live after the plan). None of this is in a PR.
  • Reduced program: shrunk on main 5ad98adb + #3716 d2293dcb + the probe (driver 616.56), then rerun on the tree above (621.47).
  • RTX 3090, Windows 11 22631, debug test builds. Synthetic fuzz programs only.

AI use: Claude Code (Claude Opus 5.5) ran the probes, the reduction and the interpreter and wrote this; checked and posted by me.

<!-- greyfinch-sync:ivall/xcl:comment:7375963701 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/3758#issuecomment-7375963701). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-12-03T10:55:24Z. --- Follow-up with the reduced program, and a split between the two analyses. This is about one program on one GPU. In it, no exchange is left out and none gives up. The analyses keep one compare's mask as a half-local pair. The RTX 3090 then reads the lower half's own word of that pair as 0. **Which analysis.** We ran 17 cases on one test exe, the reduced program, the 12 seeds and the 4 controls, with one switch at a time. The tree is #3707 `7b19e27d` + #3716 `d2293dcb` + test-only probes; the GPU is an RTX 3090, driver 621.47. | form | wrong cases | |---|---| | default | 13 (reduced program + the 12 seeds) | | lazy planner off (`plan_of(.., lazy = false)`, local probe) | 0 | | half-local masks off (`whole_live` cleared, so every ballot is exchanged where it is made; plan unchanged; local probe) | 0 | | local EXEC skips off (`plan_of(skip = false)`, local probe) | 9 (reduced program + 155, 525, 824, 1000823, 1001676, 2000677, 3000171, 3000294) | | `XCL_X64_ALL_MASKS=1` | 0 | The controls 2, 10, 11 and 188 are right in every form. Turning off either analysis alone is enough. Turning off the local skips is not. **Reduced program.** Seed 1000823 shrinks to 120 instructions: 96 threads, 2 groups, `s0` = `0xFFFFFFFA`, memory zeroed. It gives 128 wrong words: `v1` in both groups. - Threads 0-31 (the lower half of console wave 0) read 0. - Threads 64-95 (console wave 1, a lower half with no partner) keep their first `v1`. - Threads 32-63 are right. - The result is the same on the #3716 tree (616.56) and on the #3707 tree (621.47). The part that matters: ``` #64 pc 456 v_cmp_ne_u32 s[40:41], v10, v4 #65 pc 464 s_and_saveexec_b64 s[42:43], s[40:41] #66 pc 468 s_cbranch_execz -> #71 ; EXEC read whole #67 pc 472 s_or_saveexec_b64 s[46:47], -1 #68 pc 476 v_cndmask_b32 v17, 0, v12, s[46:47] #69 pc 484 v_mov_b32 v1, v17 #70 pc 488 s_mov_b64 exec, s[46:47] #71 pc 492 s_andn2_b64 exec, s[42:43], s[40:41] ``` <details><summary>The whole program (120 instructions)</summary> ``` #0 pc 0 v_mad_u32_u24 v1, v0, 1, 0x9e3779b9 #1 pc 12 v_mad_u32_u24 v2, v0, 2, 0x3c6ef372 #2 pc 24 v_mad_u32_u24 v3, v0, 3, 0xdaa66d2b #3 pc 36 v_mad_u32_u24 v4, v0, 4, 0x78dde6e4 #4 pc 48 v_mad_u32_u24 v5, v0, 5, 0x1715609d #5 pc 60 v_mad_u32_u24 v6, v0, 6, 0xb54cda56 #6 pc 72 v_mad_u32_u24 v7, v0, 7, 0x5384540f #7 pc 84 v_mad_u32_u24 v8, v0, 8, 0xf1bbcdc8 #8 pc 96 v_mad_u32_u24 v9, v0, 9, 0x8ff34781 #9 pc 108 v_mad_u32_u24 v10, v0, 10, 0x2e2ac13a #10 pc 120 v_mad_u32_u24 v11, v0, 11, 0xcc623af3 #11 pc 132 v_mad_u32_u24 v12, v0, 12, 0x6a99b4ac #12 pc 144 v_mad_u32_u24 v13, v0, 13, 0x8d12e65 #13 pc 156 v_mad_u32_u24 v14, v0, 14, 0xa708a81e #14 pc 168 v_mad_u32_u24 v15, v0, 15, 0x454021d7 #15 pc 180 v_mad_u32_u24 v16, v0, 16, 0xe3779b90 #16 pc 192 v_and_b32 v13, 7, v13 #17 pc 196 v_cvt_f32_i32 v13, v13 #18 pc 200 v_and_b32 v14, 7, v14 #19 pc 204 v_cvt_f32_i32 v14, v14 #20 pc 208 v_and_b32 v15, 7, v15 #21 pc 212 v_cvt_f32_i32 v15, v15 #22 pc 216 v_and_b32 v16, 7, v16 #23 pc 220 v_cvt_f32_i32 v16, v16 #24 pc 224 s_mul_i32 s4, s0, 0x17af29ac #25 pc 232 s_mul_i32 s5, s0, 0x9d9af417 #26 pc 240 s_mul_i32 s6, s0, 0x2386be82 #27 pc 248 s_mul_i32 s7, s0, 0xa97288ed #28 pc 256 s_mul_i32 s8, s0, 0x2f5e5358 #29 pc 264 s_mul_i32 s9, s0, 0xb54a1dc3 #30 pc 272 s_mul_i32 s10, s0, 0x3b35e82e #31 pc 280 s_mul_i32 s11, s0, 0xc121b299 #32 pc 288 s_mul_i32 s12, s0, 0x470d7d04 #33 pc 296 s_mul_i32 s13, s0, 0xccf9476f #34 pc 304 s_mul_i32 s14, s0, 0x52e511da #35 pc 312 s_mul_i32 s15, s0, 0xd8d0dc45 #36 pc 320 s_mov_b64 s[60:61], exec #37 pc 324 v_cmp_ne_u32 s[40:41], v8, v3 #38 pc 332 s_and_saveexec_b64 s[42:43], s[40:41] #39 pc 336 s_cbranch_execz -> #40 #40 pc 340 s_andn2_b64 exec, s[42:43], s[40:41] #41 pc 344 s_cbranch_execz -> #55 #42 pc 348 v_cmp_gt_u32 s[44:45], v11, v10 #43 pc 356 s_and_saveexec_b64 s[46:47], s[44:45] #44 pc 360 s_cbranch_execz -> #52 #45 pc 364 v_cmp_lt_u32 s[48:49], v10, v8 #46 pc 372 s_and_saveexec_b64 s[50:51], s[48:49] #47 pc 376 s_cbranch_execz -> #49 #48 pc 380 v_cndmask_b32 v3, 38, v1, vcc #49 pc 384 s_andn2_b64 exec, s[50:51], s[48:49] #50 pc 388 s_cbranch_execz -> #51 #51 pc 392 s_mov_b64 exec, s[50:51] #52 pc 396 s_andn2_b64 exec, s[46:47], s[44:45] #53 pc 400 s_cbranch_execz -> #54 #54 pc 404 s_mov_b64 exec, s[46:47] #55 pc 408 s_mov_b64 exec, s[42:43] #56 pc 412 s_or_saveexec_b64 s[42:43], -1 #57 pc 416 v_cndmask_b32 v17, 0, v10, s[42:43] #58 pc 424 v_readlane_b32 s36, v17, 32 #59 pc 432 v_readlane_b32 s37, v17, 0 #60 pc 440 v_mov_b32 v18, s36 #61 pc 444 v_add_nc_u32 v17, s37, v18 #62 pc 448 v_mov_b32 v5, v17 #63 pc 452 s_mov_b64 exec, s[42:43] #64 pc 456 v_cmp_ne_u32 s[40:41], v10, v4 #65 pc 464 s_and_saveexec_b64 s[42:43], s[40:41] #66 pc 468 s_cbranch_execz -> #71 #67 pc 472 s_or_saveexec_b64 s[46:47], -1 #68 pc 476 v_cndmask_b32 v17, 0, v12, s[46:47] #69 pc 484 v_mov_b32 v1, v17 #70 pc 488 s_mov_b64 exec, s[46:47] #71 pc 492 s_andn2_b64 exec, s[42:43], s[40:41] #72 pc 496 s_cbranch_execz -> #73 #73 pc 500 s_mov_b64 exec, s[42:43] #74 pc 504 s_mov_b64 exec, s[60:61] #75 pc 508 s_mul_i32 s62, s1, 0x2a00 #76 pc 516 v_mul_u32_u24 v24, 0x70, v0 #77 pc 524 v_add_nc_u32 v24, s62, v24 #78 pc 528 v_mov_b32 v25, 0 #79 pc 532 v_mov_b32 v22, s4 #80 pc 536 global_store_dword v[24:25], v22, off offset:64 #81 pc 544 v_mov_b32 v22, s5 #82 pc 548 global_store_dword v[24:25], v22, off offset:68 #83 pc 556 v_mov_b32 v22, s6 #84 pc 560 global_store_dword v[24:25], v22, off offset:72 #85 pc 568 v_mov_b32 v22, s7 #86 pc 572 global_store_dword v[24:25], v22, off offset:76 #87 pc 580 v_mov_b32 v22, s8 #88 pc 584 global_store_dword v[24:25], v22, off offset:80 #89 pc 592 v_mov_b32 v22, s9 #90 pc 596 global_store_dword v[24:25], v22, off offset:84 #91 pc 604 v_mov_b32 v22, s10 #92 pc 608 global_store_dword v[24:25], v22, off offset:88 #93 pc 616 v_mov_b32 v22, s11 #94 pc 620 global_store_dword v[24:25], v22, off offset:92 #95 pc 628 v_mov_b32 v22, s12 #96 pc 632 global_store_dword v[24:25], v22, off offset:96 #97 pc 640 v_mov_b32 v22, s13 #98 pc 644 global_store_dword v[24:25], v22, off offset:100 #99 pc 652 v_mov_b32 v22, s14 #100 pc 656 global_store_dword v[24:25], v22, off offset:104 #101 pc 664 v_mov_b32 v22, s15 #102 pc 668 global_store_dword v[24:25], v22, off offset:108 #103 pc 676 global_store_dword v[24:25], v1, off offset:0 #104 pc 684 global_store_dword v[24:25], v2, off offset:4 #105 pc 692 global_store_dword v[24:25], v3, off offset:8 #106 pc 700 global_store_dword v[24:25], v4, off offset:12 #107 pc 708 global_store_dword v[24:25], v5, off offset:16 #108 pc 716 global_store_dword v[24:25], v6, off offset:20 #109 pc 724 global_store_dword v[24:25], v7, off offset:24 #110 pc 732 global_store_dword v[24:25], v8, off offset:28 #111 pc 740 global_store_dword v[24:25], v9, off offset:32 #112 pc 748 global_store_dword v[24:25], v10, off offset:36 #113 pc 756 global_store_dword v[24:25], v11, off offset:40 #114 pc 764 global_store_dword v[24:25], v12, off offset:44 #115 pc 772 global_store_dword v[24:25], v13, off offset:48 #116 pc 780 global_store_dword v[24:25], v14, off offset:52 #117 pc 788 global_store_dword v[24:25], v15, off offset:56 #118 pc 796 global_store_dword v[24:25], v16, off offset:60 #119 pc 804 s_endpgm ``` </details> **DXIL at that site.** Default form (the pair stays half-local; the halves only exchange EXEC, at the branch; value names shortened): ``` %288 = WaveActiveBallot(v10 != v4) %289 = select i1 %upper, i32 0, i32 %288 ; lower word of the pair %290 = and i32 %289, %exec_lo ; EXEC word of the lower half %291 = and i32 %288, %exec_own ; (upper half: its own EXEC word) %292 = select i1 %upper, i32 %291, i32 %290 ; own word, also sent to the other half ... exchange of EXEC, then %365 = select i1 %upper, i32 %recv, i32 %290 %366 = select i1 %upper, i32 %291, i32 %recv br (%365 | %366) == 0 ; pc 468 ... then the lane's bit: (%292 >> lane) & 1 ``` - **Lazy planner off:** the raw ballot is sent at the compare. Both words come from `select(upper, recv, ballot)`, and there is no `select(upper, 0, ballot)`. - **Half-local masks off:** the ballot is exchanged at the compare, and EXEC is still exchanged at the branch. The lower word becomes `and(select(upper, recv, ballot), exec_lo)`. It is the same value as the default form's `%290` in the lower half. - In all four DXILs of the reduced program, the forms that pass have no `select(upper, 0, ballot)` at this site; the default has one. **Not out of step (measured on the CPU).** A small interpreter of the emitted DXIL runs the lanes of a wave together and joins them at post-dominators. It interleaves the waves at random and runs the spin loop as written. On the default DXIL it gives the reference words, both exchanges pair up, and no wait reaches its limit. To match the 3090, we zeroed each of the 296 values of `main`, one at a time, in the lower halves and then in both halves. - Only the chain of the lower half's own word gives exactly the 3090's 128 words: `v10 != v4`, its ballot, `select(upper, 0, ballot)`, `exec_lo`, and their `and`. - A give-up at either exchange (the received word read as 0) gives other words, or the right ones. - The 3090's words also show that the lower half received the upper half's word. It entered the block with its own word at 0 and wrote `v1 = 0`. The lone half with no partner did not enter. **So, for this issue:** in this program the analyses move the exchange from the compare to the EXEC branch, which is correct in the interpreter. The failure needs the half-local pair `select(upper, 0, ballot)` that they leave in place of the exchange. It is close to #3779's shape (`select(upper, 0, X)`, then a lane-bit test). But reading the word from the first lane before the bit test does not fix these 12 programs: the branch reads 0 too. The #505 programs may still be a real left-out exchange; this result does not show that either way. **Stack.** - Split table: #3707 `7b19e27d` (on main `078358a0`) + #3716 `d2293dcb` + local test-only probes. They switch `XCL_PROBE_PLAN_MODE=nolazy|noskip` (passes `lazy` / `skip` = false to `plan_of`) and `XCL_PROBE_NO_HALFLOCAL` (clears `Lw::whole_live` after the plan). None of this is in a PR. - Reduced program: shrunk on main `5ad98adb` + #3716 `d2293dcb` + the probe (driver 616.56), then rerun on the tree above (621.47). - RTX 3090, Windows 11 22631, debug test builds. Synthetic fuzz programs only. AI use: Claude Code (Claude Opus 5.5) ran the probes, the reduction and the interpreter and wrote this; checked and posted by me.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl#3758
No description provided.