Skip to content

Translate RDNA backward permutes within each half-wave - #2

Closed
Raxstreams wants to merge 1 commit into
r4tedx:shader/console-flow-ldsfrom
Raxstreams:codex/half-wave-backward-permute
Closed

Raxstreams wants to merge 1 commit into
r4tedx:shader/console-flow-ldsfrom
Raxstreams:codex/half-wave-backward-permute

Conversation

@Raxstreams

Copy link
Copy Markdown

This adds ds_bpermute_b32 to the half-wave operations in the wave64-on-wave32 translator. Each destination reads a byte-indexed lane in its own 32-lane half. The source ballot supplies zero for an inactive source and the EXEC guard preserves inactive destinations. See section 10.4 of the AMD RDNA 2 ISA reference.

All 16 split-wave tests passed on an RTX 3080 Ti. Two new synthetic dispatches check all 64 outputs, including wraparound, the byte offset, and disabled sources and destinations. I also tested this instruction implementation in a larger integration with a checkerboard shadow-mask compute shader. Its PSO passed offline and D3D12 pipeline statistics recorded 460,800 compute invocations during the first scene. The scene color is still black in that integration.

The base is the head of Marvisak#439. The change is independent of the inclusive-prefix follow-up. Only source and synthetic tests are included.

@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Taken into shader/console-flow-lds as 416714c (your commit, your authorship, cherry-picked because the base had moved; the only conflict was both sides appending tests to split_tests.rs), with f653ea4 after it. So this shows as closed rather than merged; it is in Marvisak#439 now. Thank you.

Review

  • Semantics as you state them: each lane gathers (addr + offset) / 4 mod 32 from its own 32-lane half, 0 from a source lane with EXEC off, and a destination with EXEC off keeps its value. I checked the lowering against that reading, not against console hardware. My recollection is that Mesa ACO emulates a full-wave backward permute on GFX10 wave64 for the same reason, but I could not fetch its source to quote it, so the plan document cites the ISA reference through you and says it is not checked on hardware.
  • The host lane is the console lane wherever console_lanes is set (the thread relabelling), so waveGetLaneIndex and the ballot half are right in all three forms: one 64-lane wave, the in-half split, and the console flow. A lane that is not in the block is not in the ballot, which gives the 0 the console gives for EXEC off.
  • Before this, a program with ds_bpermute_b32 did not translate on any host, so this is new on 64-lane hosts too.

Tested on an RTX 5070 (32..32) and a Radeon iGPU (32..64), Windows 11, each module through dxil.dll:

  • Your two tests: exact on both.
  • f653ea4 adds: EXEC over part of each half (lanes 0..21 and 42..63), two console waves per group (128 threads), groups of 48 and 32 threads (a source lane that is not there reads 0), and the permute beside a v_readlane across the halves, which goes through the console flow on the RTX. All exact on both.
  • cargo test --workspace: 292 passed, 0 failed, 4 ignored.

f653ea4 also formats the new lines to the crate width (100) and fixes nothing else.

Still open from #1, if you want either: the note in wave.rs on v_permlanex16, and float minimum / maximum across the halves.

Synthetic programs only; no title data. AI-assisted (Claude Code).

@r4tedx r4tedx closed this Nov 24, 2026
r4tedx added a commit that referenced this pull request Nov 24, 2026
Marvisak#439's branch, shader/console-flow-lds, went from e49302a to f653ea4.
The stack came into this tree through integration/wave64-with-180,
whose commit has one parent, so the four commits are picked onto this
tree in order rather than merged:

- a32c177: test, LDS written and read in different masked blocks.
- 8876ed3: the startup warning on hosts without 64-lane waves says
  what the stack does now (one string in crates/victory-gpu/src/host.rs).
- 416714c, from Raxstreams's pull request #2 (git author
  Peter Bonanni): ds_bpermute_b32 lowered as a read within the lane's
  own 32-lane half.
- f653ea4: tests for it, and the plan document.

Conflict resolution, crates/victory-shader/src/emit/lower.rs,
Lower::new, `in_half`: Marvisak#180's `implicit_derivatives` and 416714c's
`ds_bpermute_b32` are both kept. The three `permute` conditions took
416714c's text unchanged; Marvisak#98's v_permlane16 handling is in
emit/wave.rs and its name does not contain "permute", so they do not
meet. The added and removed lines of this merge are the same as those
of `git diff e49302a f653ea4`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants