A collection of AMD GPU programming examples targeting CDNA / RDNA
architectures (primarily gfx942 / MI300), covering hand-written GCN
assembly kernels, HIP C++ device code, and PyTorch/Triton extensions.
| Tag | Meaning |
|---|
[A] | Hand-written GCN assembly kernel (.s) |
[H] | HIP / C++ / CUDA device code |
[A/H] | Both hand-written assembly and HIP host code |
+ | Has Python / PyTorch / Triton interface (can run from Python directly) |
bandwidth_memread/ [H] -- The go-to
memory bandwidth microbenchmark. Measures peak read-only and read+write
GPU memory bandwidth using float4 vectorized, non-temporal, persistent kernels.
Supports both ROCm and CUDA. Sweeps from ~78 KB to ~1.7 GB and reports GB/s
per size. Peak observed: ~4.56 TB/s read-only on MI308X (gfx942).
See the detailed README.
vector_add_asm/ [A/H] -- A minimal but complete
hand-written GCN assembly kernel for C[i] = A[i] + B[i] on gfx942,
demonstrating persistent kernel launch, double LDS buffering with deep pipeline
fill, buffer_load_dword ... offen lds (async load to LDS), OOB-based control
flow (no exec mask), and vmcnt(3) pipelining.
See the detailed README.
| Tag | Folder | Description |
|---|
[H] | vector_add | Basic HIP vector add C[i] = A[i] + B[i] |
[A/H] | vector_add_asm | Hand-written asm vector add with buffer_load...lds, double LDS buffering, OOB control flow, vmcnt(3) pipelining (gfx942) |
[H] | absdiff | SAD 8x8 absolute difference using __builtin_amdgcn_sad_u16 |
| Tag | Folder | Description |
|---|
[A/H] | hgemm | Half-precision GEMM 128x128 with hand-written MFMA asm |
[H+] | hgemm_mfma | Half-precision GEMM with MFMA; Python codegen helpers |
[A/H] | sgemm | SGEMM 128x128 with hand-written asm (VEGA64) |
[H] | sgemm_reduction | SGEMM with warp reduction for large K, small M/N |
| Tag | Folder | Description |
|---|
[A/H] | bandwidth | Memory bandwidth memcpy with hand-written asm kernel |
[H] | bandwidth_c | Memory bandwidth benchmark (CUDA/HIP memcpy kernel) |
[H] | bandwidth_hip_jit | JIT HIP bandwidth -- kernel compiled and loaded at runtime |
[H] | bandwidth_memread | Memory bandwidth microbenchmark -- read-only & read+write, float4, non-temporal, persistent kernels (ROCm / CUDA) |
[H] | bandwidth_memread_2d | 2D memory read bandwidth benchmark |
[H+] | membench | Memory bandwidth test suite with JSON config |
[H] | memcpy_async | Async memcpy via shared memory (global -> LDS -> global) |
[A/H] | memcpy_example | Memcpy kernel with hand-written asm |
[A/H] | memcpy_example_gfx1030 | Memcpy kernels for gfx1030 (RDNA2) |
[+] | triton_memread | Triton memory read kernel |
[H] | smid | Memcpy throughput benchmark (buffer load, swizzled) |
| Tag | Folder | Description |
|---|
[H] | cvt_fp8 | FP8 (E4M3) conversion test using builtins |
[H] | cvt_i4 | Int4 conversion / IPS test |
[H] | pk_cvt | FP8 packed conversion |
[H] | opus_cast | Fast tanh via opus (ROCm / CUDA) |
[H] | mix_load | Mixed-load kernel (bf16x2, gfx942) |
[H] | lqq | LQQ quantization: i8 -> i4 with scale/zero |
| Tag | Folder | Description |
|---|
[A/H] | measure_ips | Instruction throughput (IPS) measurement |
[A/H+] | measure_ips_bench | IPS benchmark for many instructions; Python generates asm |
[H] | hwreg | HW_ID register readout for wave layout |
[H] | hwreg_mask | HW_ID register access with masking |
| Tag | Folder | Description |
|---|
[H+] | opus_fmm | PyTorch extension for opus flat matrix multiply |
[+] | hadmard_rotate | Hadamard / orthogonal matrix (PyTorch) |
[+] | merge_w_kv_o | Merge K/KV/O utility (Python) |
[+] | co-exec | Python tool: compile + run asm/HIP kernels via HSA |