amdgcn: Tune kernel occupancy and register usage for better performance
New option and register calculation fixes allow better control over kernel wavefronts on AMD GPUs, improving performance.
This commit introduces the -mmin-waves-per-cu option to tune the minimum number of wavefronts per compute unit for AMD GCN GPUs. This helps optimize performance by allowing more wavefronts to fit on a compute unit when kernels use excessive registers. The commit also corrects outdated register calculations and moves occupancy parameters to gcn-devices.def for consistent use between the compiler and libgomp plugin. It also refines register limit calculations for normal functions, ensuring better resource allocation.
In Details
The amdgcn backend now supports -mmin-waves-per-cu to control the minimum SGPR/VGPR/AVGPR budgets per wavefront, influencing kernel occupancy on compute units. This change revises register count calculations, previously tuned for older GCN architectures, to better reflect RDNA and CDNA devices. Occupancy parameters are now centralized in gcn-devices.def, replacing TARGET_VGPR_GRANULARITY. The kernel metadata .sgpr_count is updated to include VCC, XNACK, and flat scratch, aligning with the AMDGPU metadata spec. The libgomp plugin's occupancy check now mirrors the compiler's logic, fixi…
- wavefront
- A group of work-items that execute together on a GPU's processing units. The number of wavefronts that can run concurrently on a compute unit affects performance.
- compute unit (CU)
- A fundamental processing block on an AMD GPU, containing multiple SIMDs and other resources.
- VGPR
- Vector General-Purpose Register. High-speed storage used by GPU shaders for data.
- SGPR
- Scalar General-Purpose Register. High-speed storage used by GPU shaders for scalar data and control flow.
- SIMD
- Single Instruction, Multiple Data. A processing unit that executes the same instruction on multiple data elements simultaneously.
- GCN
- Graphics Core Next. An AMD GPU microarchitecture. RDNA and CDNA are successors to GCN.
- RDNA
- Radeon DNA. AMD's GPU microarchitecture succeeding GCN, found in modern Radeon graphics cards.
- CDNA
- Compute DNA. AMD's GPU microarchitecture designed for compute workloads, often found in Instinct accelerators.