Support launch bounds on the GCN target - #918
Open
gbaraldi wants to merge 1 commit into
Open
Conversation
minthreads/maxthreads on GCNCompilerTarget emit amdgpu-flat-work-group-sizes, mirroring the PTX target's fields. Without the attribute the backend budgets registers for 1024-item workgroups. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
maleadt
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The GCN target compiles every kernel with the backend's default
amdgpu-flat-work-group-sizeof1,1024, so the register allocator always budgets for 1024-item workgroups: on gfx942 that is a 128-VGPR cap, and register-heavy kernels spill even when they will only ever be launched with smaller workgroups. HIP C++ exposes this via__launch_bounds__; the PTX target already exposes it asminthreads/maxthreads.This adds the same two fields to
GCNCompilerTarget, emitted asamdgpu-flat-work-group-sizeon kernels. LLVM derives the minimum waves/EU from the attribute's maximum (AMDGPUSubtarget::getEffectiveWavesPerEU), which sets the VGPR budget (GCNSubtarget::getBaseMaxNumVGPRs).Measured on MI300A (gfx942, ROCm 7.2.4, Julia 1.12) with a register-tiled FP32 GEMM from AMDGPU.jl (16×16 workgroup, 8×8 accumulator microtile per thread, 4096³):
maxthreads=256A companion AMDGPU.jl PR plumbs this through
@roc maxthreads=and sets it automatically for KernelAbstractions kernels with static workgroup sizes, mirroring CUDA.jl. As a bonus the bound lands in the code object's.max_flat_workgroup_size, so HIP itself rejects out-of-bounds launches that were previously silent UB.🤖 Generated with Claude Code