Recompiler: wave64 VS / PS on 32-lane waves – votes are taken per half (not only lane reads) #336

Open
opened 2026-11-26 04:20:27 +00:00 by github-bot · 1 comment
Owner

@⁠emirduran707 on GitHub · 2026-11-23 23:48 UTC · original

docs/wave64-on-wave32.md treats a 32-lane wave of a console wave64 VS / PS as a console wave whose lanes 32..63 are not populated, so per-lane code and masks count as exact and only reads of lanes ≥ 32 are hazards (upper_lanes.rs, #133). That misses a second way the result can depend on how the driver cuts the wave: wave-wide votes are taken per half.

  • s_cbranch_vccnz / vccz, execz / execnz, scc* after a compare of a lane mask: on the console the 64 lanes go one way if any lane votes yes. Cut in two, the half with no yes lane takes the other side, which the console wave never ran for those lanes. If that side does more than skip lane-masked work, the half's output differs.
  • A scalar defined behind such a vote is then defined in one half and not the other.
  • Lane counts, ranks, first-lane indices and the lane id (s_bcnt1 of a mask, v_mbcnt, s_ff1) take different values in a half than in the wave.

wave_hazards says nothing about these, so 0 hazards does not mean a wave64 PS is exact on 32-lane waves (NVIDIA, and AMD drivers that pick 32 for a PS). How many programs of the retail pack this reaches is not measured yet; step 3 below measures it.

Plan – classify first, fix later, each PR on its own:

  1. Preparation, no behaviour change: share upper_lanes::successors and add post-dominators / control dependence over a program's instructions, with unit tests.
  2. A classifier, not called by translation: per wave64 VS / PS a tier (exact as is / exact through a known idiom / may differ) and the reasons, from a forward taint pass (partition-dependent values reaching exports, stores, branch conditions, EXEC) plus rules for votes that only skip lane-masked work. Unit tests on hand-written programs.
  3. An ignored census test over XCL_SAMPLE_RPF, like retail_wave64_graphics_lane_census, and the measured counts in docs/wave64-on-wave32.md.
  4. Then the may-differ cases one at a time, each with a GPU test.

AI-assisted: Claude Code (Claude Opus 5.5) wrote this issue.

**@⁠emirduran707** on GitHub · 2026-11-23 23:48 UTC · [original](https://github.com/xcl-dev/xcl/issues/336) `docs/wave64-on-wave32.md` treats a 32-lane wave of a console wave64 VS / PS as a console wave whose lanes 32..63 are not populated, so per-lane code and masks count as exact and only reads of lanes ≥ 32 are hazards (`upper_lanes.rs`, #133). That misses a second way the result can depend on how the driver cuts the wave: **wave-wide votes are taken per half.** - `s_cbranch_vccnz` / `vccz`, `execz` / `execnz`, `scc*` after a compare of a lane mask: on the console the 64 lanes go one way if any lane votes yes. Cut in two, the half with no yes lane takes the other side, which the console wave never ran for those lanes. If that side does more than skip lane-masked work, the half's output differs. - A scalar defined behind such a vote is then defined in one half and not the other. - Lane counts, ranks, first-lane indices and the lane id (`s_bcnt1` of a mask, `v_mbcnt`, `s_ff1`) take different values in a half than in the wave. `wave_hazards` says nothing about these, so 0 hazards does not mean a wave64 PS is exact on 32-lane waves (NVIDIA, and AMD drivers that pick 32 for a PS). How many programs of the retail pack this reaches is not measured yet; step 3 below measures it. **Plan** – classify first, fix later, each PR on its own: 1. Preparation, no behaviour change: share `upper_lanes::successors` and add post-dominators / control dependence over a program's instructions, with unit tests. 2. A classifier, not called by translation: per wave64 VS / PS a tier (exact as is / exact through a known idiom / may differ) and the reasons, from a forward taint pass (partition-dependent values reaching exports, stores, branch conditions, EXEC) plus rules for votes that only skip lane-masked work. Unit tests on hand-written programs. 3. An ignored census test over `XCL_SAMPLE_RPF`, like `retail_wave64_graphics_lane_census`, and the measured counts in `docs/wave64-on-wave32.md`. 4. Then the may-differ cases one at a time, each with a GPU test. AI-assisted: Claude Code (Claude Opus 5.5) wrote this issue.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:20:27 +00:00
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-24 01:23 UTC · original · edited 2026-11-24 09:27 UTC

Progress, as a stack (each PR's own commit on top of the one below):

  1. #341 – basic blocks, post-dominators, control dependence (no behaviour change).
  2. #517 – the classifier: taint pass, vote rules, sinks, and scalars written behind a vote (#528 folded in). After three reviews (QemmHD, CuteBooty, upipibi), over the pack's 13 210 wave64 VS / PS: 6 057 Exact.
  3. #953 – a vote's side may narrow EXEC through a whole-quad copy (the console compiler's discard early-out): 7 015 Exact.

A probe over the pack shows where the rest is. Among the programs that are not Exact, 2 409 had vote-branch as their only reason; most of those were the discard early-out that #953 handles. Waterfall loops (v_readfirstlane + v_cmp_eq of it) are rare: 1 of the 520 programs whose only reasons are cross-lane / tainted-exec / lane-id. So the next parts will be chosen by such probes rather than by idiom names. After that: the census as an ignored test with the counts in docs/wave64-on-wave32.md, then the may-differ cases one at a time with GPU tests.

AI use: Claude Code with Claude Opus 5.5 wrote this note.

**@⁠emirduran707** on GitHub · 2026-11-24 01:23 UTC · [original](https://github.com/xcl-dev/xcl/issues/336#issuecomment-7119059550) · edited 2026-11-24 09:27 UTC Progress, as a stack (each PR's own commit on top of the one below): 1. #341 – basic blocks, post-dominators, control dependence (no behaviour change). 2. #517 – the classifier: taint pass, vote rules, sinks, and scalars written behind a vote (#528 folded in). After three reviews (QemmHD, CuteBooty, upipibi), over the pack's 13 210 wave64 VS / PS: 6 057 Exact. 3. #953 – a vote's side may narrow EXEC through a whole-quad copy (the console compiler's discard early-out): 7 015 Exact. A probe over the pack shows where the rest is. Among the programs that are not Exact, 2 409 had `vote-branch` as their only reason; most of those were the discard early-out that #953 handles. Waterfall loops (`v_readfirstlane` + `v_cmp_eq` of it) are rare: 1 of the 520 programs whose only reasons are `cross-lane` / `tainted-exec` / `lane-id`. So the next parts will be chosen by such probes rather than by idiom names. After that: the census as an ignored test with the counts in `docs/wave64-on-wave32.md`, then the may-differ cases one at a time with GPU tests. AI use: Claude Code with Claude Opus 5.5 wrote this note.
This discussion has been locked. Commenting is limited to contributors.
No description provided.