Skip to content

Support launch bounds (@roc maxthreads) and set them for static KernelAbstractions workgroups - #1060

Draft
gbaraldi wants to merge 1 commit into
JuliaGPU:mainfrom
gbaraldi:launch-bounds
Draft

Support launch bounds (@roc maxthreads) and set them for static KernelAbstractions workgroups#1060
gbaraldi wants to merge 1 commit into
JuliaGPU:mainfrom
gbaraldi:launch-bounds

Conversation

@gbaraldi

Copy link
Copy Markdown
Member

Depends on JuliaGPU/GPUCompiler.jl#918 (draft until a GPUCompiler release carries it).

Every kernel currently compiles against the backend default amdgpu-flat-work-group-size of 1,1024, so the register allocator budgets for 1024-item workgroups — a hard 128-VGPR cap on gfx942 — and register-heavy kernels spill even when they only ever launch with smaller workgroups. HIP C++ tunes this with __launch_bounds__; CUDA.jl exposes it as @cuda maxthreads=.

This adds the same knobs:

  • @roc maxthreads=N / minthreads=N (also on hipfunction), mapped to GCNCompilerTarget's new launch bounds.
  • ROCKernels sets maxthreads automatically for KernelAbstractions kernels with static workgroup sizes, mirroring CUDAKernels — statically-sized KA kernels get the right register budget with no user action.

Measured on MI300A (ROCm 7.2.4, Julia 1.12), register-tiled FP32 GEMM (16×16 workgroup, 8×8 microtile per thread, 4096³):

default maxthreads=256
VGPRs 64 arch + 64 accum (at the 128 cap) 136, no accum
scratch 120 B (29 spills) 0
runtime 8.61 ms, 15.96 TFLOPS 4.89 ms, 28.11 TFLOPS

The bound also lands in the code object's .max_flat_workgroup_size, so HIP rejects oversize launches at the API level (previously silent UB); the new test covers the attribute, an in-bounds launch, and the oversize rejection. test/core/codegen.jl passes in full on MI300A.

🤖 Generated with Claude Code

@roc minthreads/maxthreads map to GCNCompilerTarget's new launch bounds;
KernelAbstractions kernels with static workgroup sizes set maxthreads
automatically, matching CUDAKernels.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant