Skip to content

Shaders: use console flow for masks read as data - #13

Closed
mohammadallami75-ops wants to merge 1 commit into
r4tedx:shader/wave-per-groupfrom
mohammadallami75-ops:shader/scalar-state-fixtures
Closed

mohammadallami75-ops wants to merge 1 commit into
r4tedx:shader/wave-per-groupfrom
mohammadallami75-ops:shader/scalar-state-fixtures

Conversation

@mohammadallami75-ops

Copy link
Copy Markdown

Part 1 of the scalar-state review. This routes compute mask data reads through console flow on hosts that run the console wave size and retains the lowering fallback. It includes all seven original fixtures. Four scalar-detection tests are temporarily ignored until Part 2.

The RTX 2080 SUPER returned 64 for the loop exit mask and 32 for the branch-grown mask in every lane. The split suite passed with 35 passed and 4 ignored.

AI.

@mohammadallami75-ops

Copy link
Copy Markdown
Author

Both CI Clippy commands passed at 8a4d40b. cargo test --workspace --locked passed with 387 passed, 0 failed and 10 ignored. Four of those fixtures are enabled in Part 2. The two mask fixtures returned exact readbacks on the RTX 2080 SUPER.

AI.

@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you for splitting it so quickly. I had started on the same part from your original diff before these arrived, and measuring it turned up something that changes what part 1 has to be, so here is where it stands.

Your rule here covers one of the two faulty shapes. wants_console_flow |= x.target.runs(wave) && reads_mask_data uses reads_mask_as_data, which knows masks the structure tracks as masks. The branch-grown mask is one of those, so that fixture is fixed. The loop's exit mask is not: it starts as s_mov 0, so the structure holds it as a number (Structured::others), reads_mask_as_data does not see its count as a mask read, and on a host that runs the program's wave size the program stays per lane. Your run was on a 32-lane card with a wave64 program, which takes the console flow for other reasons, so it could not show this. On the Radeon iGPU (64-lane waves) that fixture returns 1 where 64 is expected without a rule that sees held masks.

And the fault is wider than wave64. The wave32 form of the same loop (32 threads, _b32 operations) returns 1 in every lane where 32 is expected, on the RTX 5070 and on the Radeon alike, in the plain per-lane form, with no wave split involved. Same values at Marvisak#233's head, where masks are handled as on main. I filed it upstream with the program: Marvisak#1498.

What I committed on the branch (shader/wave-per-group, two commits, the first with you as author; pushed once the full test run that is queued passes):

  • your Structured::divergent_joins from the original patch, as it was;
  • the rule narrowed to masks and widened to held ones: a scalar join at such a join whose value is a mask in any form the structure knows (tracked, a high dword, or held as a number), and somewhere a read of such a mask as a number; then the console flow on a host that runs the program's wave size, with the per-lane fallback kept. No restriction to wave64;
  • your two mask fixtures, plus the wave32 one.

Measured (local title data, offline, CPU only, counts only): no program changes outcome for a 32-lane or a 32-64 host except three that get past the mask and name their next blocker. The rule fires for about 400 compute programs on a 32-64 host and about 300 on a 32-lane host (all wave32 there). Your simpler rule would fire for about 160 and miss the held masks.

So I would close this one in favour of what is on the branch, unless you see a case mine misses. The four scalar fixtures you kept ignored belong with #14, which I will measure next as you asked (translate --validate at 32-32 and 32-64 against the branch with the mask rule in).

AI-assisted (Claude Code).

@mohammadallami75-ops

Copy link
Copy Markdown
Author

Thanks for checking both wave sizes and catching the zero-seeded loop case. I verified that shader/wave-per-group contains eaf0d36 and 88b38e8. Those commits carry the divergent-join detection and the original mask fixtures forward, and add the Wave32 loop regression. Closing this PR in favor of that implementation. The separate scalar-state change remains in #14 for its own comparison.

AI-assisted.

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.

2 participants