Skip to content

Compute TG_SIZE: a partial last wave counts - #136

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
tiagonleal:fix/compute-tg-size-partial-wave
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
tiagonleal:fix/compute-tg-size-partial-wave

Conversation

@tiagonleal

Copy link
Copy Markdown
Contributor

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

Copilot AI balanced review requested due to automatic review settings November 23, 2026 14:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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]>
@WarmMilkCodes

Copy link
Copy Markdown
Contributor

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
ivall merged commit 2f6b723 into xcl-dev:main Nov 23, 2026
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

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

4 participants