Compute TG_SIZE: a partial last wave counts #136

Manually merged
github merged 1 commit from gh-pr/136/head into gh-pr/136/base 2026-11-26 04:11:59 +00:00
Owner

@⁠tiagonleal on GitHub · 2026-11-23 14:48 UTC · original
tiagonleal:fix/compute-tg-size-partial-wave → main · +31 −1 · 2 files · 1 commits · merged 2026-11-23 20:51 UTC

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

**@⁠tiagonleal** on GitHub · 2026-11-23 14:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/136) `tiagonleal:fix/compute-tg-size-partial-wave` → `main` · +31 −1 · 2 files · 1 commits · merged 2026-11-23 20:51 UTC 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)
TG_SIZE (the SGPR after the group ids) held threads / wave size,
truncated: a 96-thread group reported 1 wave of 64 instead of 2, and a
40-thread group 1 wave of 32 instead of 2. The count is now the
ceiling, computed when the HLSL is made.

Test: gpu_compute_tg_size_counts_a_partial_last_wave (96 / 64 / 40 / 128
threads, wave64 and wave32; every thread stores TG_SIZE).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:11:58 +00:00
github manually merged commit 1058c0b006 into gh-pr/136/base 2026-11-26 04:11:59 +00:00
Author
Owner

@⁠WarmMilkCodes on GitHub · 2026-11-23 18:55 UTC · original

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).

**@⁠WarmMilkCodes** on GitHub · 2026-11-23 18:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/136#issuecomment-7110836517) 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).
Author
Owner

@⁠ivall on GitHub · 2026-11-23 20:52 UTC · original

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.

**@⁠ivall** on GitHub · 2026-11-23 20:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/136#issuecomment-7113683844) 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.
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-23 14:48 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-23 14:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/136#pullrequestreview-6023712613) · **reviewed** 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.