Hygon DCU Backend Optimization Guide#
Triton kernels execute on Hygon DCU accelerators through the HIP compiler pipeline. Tiling size, active warp count, software pipelining depth, and program grid ordering collectively dictate the utilization efficiency of physical vector registers, on-chip shared memory (LDS, Local Data Share), and the L2 cache.
This guide uses the representative Hygon BW / gfx936 architecture to detail core hardware limits and optimization strategies.
1. Hardware Resources & Tuning Boundaries#
The Hygon BW / gfx936 accelerator provides the following physical hardware specifications:
| Resource Category | Physical Specification | Performance Tuning Recommendation |
|---|---|---|
| Compute Units (CUs) | 80 CUs, with 4 SIMD units per CU | Launch sufficient programs in the grid to keep all CUs occupied, especially for smaller matrix shapes. |
| Wavefront Width | 64 Lanes (each Wavefront consists of 64 threads) | Size num_warps in conjunction with tile dimensions. Note that AMD/Hygon Wavefront width (64) is double that of NVIDIA warps (32). |
| Resident Waves Limit | Up to 10 resident waves per SIMD unit | Theoretical maximum of 40 waves per CU; actual occupancy is often lower due to register pressure, LDS allocation, and workgroup constraints. |
| Vector Registers (VGPR) | 192 KB register file per SIMD unit | Oversized tiles and prolonged live ranges increase register spills, drastically reducing the number of concurrent resident waves. |
| Local Data Share (LDS) | 64 KiB LDS per CU | Shared within a workgroup. Pipeline staging buffers and layout transformations must strictly fit within this 64 KiB budget. |
This device also supports Packed FP32 vector operations, allowing two FP32 operations to be executed concurrently within a single instruction when generated by the compiler. The limits above reflect the
gfx936profile; refer to the respective hardware manual for other DCU architectures.
2. DUMMA Hardware Matrix Instruction Shapes#
Table 3.1 in Section 3 of the DTK 26.04.1 DUMMA User Manual specifies the hardware matrix multiply-accumulate shapes supported by du::dumma::du_mma_sync. A single Wavefront cooperatively calculates an $M \times N$ output tile for $D = A \times B + C$.
The table below lists the 16 × 16 × K single-instruction hardware execution shapes; higher-level Triton BLOCK_M/N/K tiles are composed by tiling multiple DUMMA instructions along with a loop over the K dimension:
| A/B Input Dtype | Accumulator Dtype | Instruction Tile $M \times N \times K$ | Supported Target Architectures |
|---|---|---|---|
| FP32 | FP32 | 16 × 16 × 4 | gfx926 / 928 / 936 / 938 |
| FP32 / TF32 | FP32 | 16 × 16 × 8 | gfx928 / 936 / 938 |
| FP16 / BF16 | FP32 | 16 × 16 × 16 | gfx928 / 936 / 938 |
| Signed / Unsigned INT8 | INT32 | 16 × 16 × 32 | gfx928 / 936 / 938 |
| Signed / Unsigned INT4 | INT32 | 16 × 16 × 64 | gfx936 / 938 |
| FP64 | FP64 | 16 × 16 × 4 | gfx926 / 936 / 938 |
| FP8 (E4M3 or E5M2) | FP32 | 16 × 16 × 32 | gfx938 |
Lower input bitwidths permit processing more elements along the K dimension within a single instruction. When tuning tl.dot, disassemble the kernel to confirm that the compiler successfully lowers the computation to the targeted DUMMA instructions.
3. Software Pipelining: Balancing Overlap and Resource Consumption#
For GEMM kernels looping over the K dimension, tuning num_stages allows the compiler to construct multi-stage asynchronous software pipelines, masking global memory latency with computation.
- Input Volume Estimation: For FP16 matrix multiplication, the raw input data size for a single pair of A and B tiles is approximately $(BLOCK_M + BLOCK_N) \times BLOCK_K \times 2$ bytes. For example,
64 × 64 × 32corresponds to 8 KiB of data. - LDS Capacity Constraint: Each CU provides 64 KiB of LDS. If a single workgroup requires 32 KiB of LDS for pipelining buffers and alignment padding, at most 2 workgroups can reside simultaneously on that CU. If allocation exceeds 32 KiB, occupancy drops to 1 workgroup per CU, hurting latency hiding capability.
4. Grouped Scheduling: Maximizing L2 Cache Data Reuse#
Matrix multiplication typically flattens a two-dimensional output tile grid into a one-dimensional program grid. Introducing GROUP_M groups consecutive programs along the M dimension, allowing multiple M tiles to reuse the corresponding $K \times N$ matrix B slice loaded into L2 cache, significantly cutting redundant HBM memory bandwidth traffic:
pid = tl.program_id(0)
num_pid_m = tl.cdiv(M, BLOCK_M)
num_pid_n = tl.cdiv(N, BLOCK_N)
num_pid_in_group = GROUP_M * num_pid_n
group_id = pid // num_pid_in_group
first_pid_m = group_id * GROUP_M
group_size_m = min(num_pid_m - first_pid_m, GROUP_M)
pid_m = first_pid_m + ((pid % num_pid_in_group) % group_size_m)
pid_n = (pid % num_pid_in_group) // group_size_mCache hit rates and reuse benefits vary with matrix aspect ratio and the physical CU count. We recommend treating
GROUP_M(typical candidate values: 4, 8, 16) as a tunable parameter within LibTuner alongsideBLOCK_M/N/K.
5. References#
- 《DCU 编程实战》 (2026 Edition), Section 6.8.4
- DTK 26.04.1 DUMMA User Manual, Section 3, Table 3.1
- DTK 26.04
du_mma.handdu_mma.hpp(installed under/opt/dtk/include/)