Compute TG_SIZE: a partial last wave counts #134

Merged
tiagonleal merged 1 commit from upstream-pr/136 into main 2026-11-23 20:51:52 +00:00
tiagonleal commented 2026-11-23 14:48:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-23T14:48:41Z.


From #105's "also noticed": "Mode::Compute tg_size uses truncating division instead of div_ceil".

TG_SIZE (the SGPR after the group ids, wave count | wave index << 6) was emitted as threads / lanes, truncated. A group that is not a multiple of the wave size has a last, partial wave, so:

group wave size was is
96 threads 64 1 2
96 threads 32 3 3
40 threads 32 1 2

A program that uses the count (to size a cross-wave reduction, or to know how many waves reach an LDS slot) skipped the last wave. The count is now the ceiling, computed when the HLSL is made (a constant, as before).

The retail pack never enables TG_SIZE (CsInterface::tg_size doc), so no translated pack program changes. Only compute programs that enable it get different HLSL.

Test: gpu_compute_tg_size_counts_a_partial_last_wave. Every thread stores TG_SIZE, for 96 / 64 / 128 threads in wave64 and 96 / 40 in wave32 (split wave64 on 32-lane GPUs). Before: 96 threads, wave64: thread 0 – left: 1, right: 2. After: all pass.

Run: RTX 5070 Ti, driver 32.0.16.1742. cargo test --workspace --no-fail-fast -- --test-threads=4 on main 95bda11: 549 passed, 0 failed, 37 ignored.

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:6561926077 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/136). Originally posted by [tiagonleal](https://github.com/tiagonleal) on 2026-11-23T14:48:41Z. --- From #105's "also noticed": "`Mode::Compute` `tg_size` uses truncating division instead of `div_ceil`". TG_SIZE (the SGPR after the group ids, wave count | wave index << 6) was emitted as `threads / lanes`, truncated. A group that is not a multiple of the wave size has a last, partial wave, so: | group | wave size | was | is | |---|---|---|---| | 96 threads | 64 | 1 | 2 | | 96 threads | 32 | 3 | 3 | | 40 threads | 32 | 1 | 2 | A program that uses the count (to size a cross-wave reduction, or to know how many waves reach an LDS slot) skipped the last wave. The count is now the ceiling, computed when the HLSL is made (a constant, as before). The retail pack never enables TG_SIZE (`CsInterface::tg_size` doc), so no translated pack program changes. Only compute programs that enable it get different HLSL. Test: `gpu_compute_tg_size_counts_a_partial_last_wave`. Every thread stores TG_SIZE, for 96 / 64 / 128 threads in wave64 and 96 / 40 in wave32 (split wave64 on 32-lane GPUs). Before: `96 threads, wave64: thread 0 – left: 1, right: 2`. After: all pass. Run: RTX 5070 Ti, driver 32.0.16.1742. `cargo test --workspace --no-fail-fast -- --test-threads=4` on `main` 95bda11: 549 passed, 0 failed, 37 ignored. _AI-assisted._ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:57:19 +00:00
copilot-pull-request-reviewer[bot commented 2026-11-24 06:57:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-23T14:48:52Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:ivall/xcl:review:6023712613 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/136#pullrequestreview-6023712613). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/copilot-pull-request-reviewer%5Bbot%5D) on 2026-11-23T14:48:52Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
WarmMilkCodes commented 2026-11-24 07:04:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by WarmMilkCodes on 2026-11-23T18:55:08Z.


Tested #136 1058c0b merged onto main 956a476 on AMD Radeon RX 6600 XT (RDNA2), driver 32.0.21045.29003, Windows 11 23H2 (22631.6199): pass

cargo test --workspace --no-fail-fast -- --test-threads=4, no XCL_SAMPLE_* data:

main this
passed 568 569
failed 1 1
GPU tests skipped 0 0

No new failures vs main. The PR's new test passes on RDNA2. The one failure on both, gpu_wave64_ps_whole_wave_reductions, is the 32-lane PS case on this card (#155).

<!-- greyfinch-sync:ivall/xcl:comment:7110836517 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/136#issuecomment-7110836517). Originally posted by [WarmMilkCodes](https://github.com/WarmMilkCodes) on 2026-11-23T18:55:08Z. --- Tested #136 `1058c0b` merged onto main `956a476` on AMD Radeon RX 6600 XT (RDNA2), driver 32.0.21045.29003, Windows 11 23H2 (22631.6199): pass `cargo test --workspace --no-fail-fast -- --test-threads=4`, no `XCL_SAMPLE_*` data: | | main | this | |---|---|---| | passed | 568 | 569 | | failed | 1 | 1 | | GPU tests skipped | 0 | 0 | No new failures vs main. The PR's new test passes on RDNA2. The one failure on both, `gpu_wave64_ps_whole_wave_reductions`, is the 32-lane PS case on this card (#155).
ivall commented 2026-11-24 07:04:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T20:52:42Z.


Merged (main 2abc562). Checked on an RX 9070 (RDNA4) with the 11 PRs merged together on main 38b05b7: cargo build --workspace && cargo test --workspace -- --test-threads=4 - 547 unit tests passed, 0 failed (19 ignored); the integration and e2e tests passed too.

<!-- greyfinch-sync:ivall/xcl:comment:7113683844 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/136#issuecomment-7113683844). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T20:52:42Z. --- Merged (main 2abc562). Checked on an RX 9070 (RDNA4) with the 11 PRs merged together on main 38b05b7: `cargo build --workspace && cargo test --workspace -- --test-threads=4` - 547 unit tests passed, 0 failed (19 ignored); the integration and e2e tests passed too.
Sign in to join this conversation.
No reviewers
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!134
No description provided.