How serge45/amdgpu-arch-gemm works
Project type and purpose
• This is an open-source tool (a domain-specific code generator and tuner) for emitting AMD GCN assembly kernels specialized for single-precision GEMM and for evaluating them via a VM or native hardware runner.
File structure
• Top-level folders:
• generator/ – Python module that takes GEMM parameters and emits AMD GCN .s code
• vm/ – Python “GCN Virtual Machine” that simulates execution of the generated code
• tuner/ – Python tuner that drives generator + benchmark harness (runner or VM) to optimize tiling/blocking parameters
• runner/ – C++ harness (with CMake) compiling + launching the generated kernels on real AMD hardware
• test/ – Python pytest tests validating generator correctness and VM accuracy
• Config/build:
• runner/Utils/*.hpp – helper classes for buffers, kernel arguments, TOML config parsing, math helpers
• runner/CMakeLists.txt – build scripts for the native runner
• requirements.txt / requirements-test.txt – Python dependencies
README for additional insights
• Purpose: learn and record how to generate optimal AMD GCN assembly for SGEMM on gfx90a/908
• Current scope: only NN SGEMM
a. Main components:
1) Tuner (Python)
2) Generator (Python)
3) VM (Python)
4) Runner (C++ on GPU)
5) Test Suite (pytest)
6) Config/Parameter Store (TOML)
b. Relationships / data flow:
• Tuner reads problem specs & search space → invokes Generator → outputs .s assembly →
→ feeds either VM or Runner → execution returns performance metrics →
→ Tuner updates parameters → loop until optimum
• Test Suite invokes Generator and VM to assert correctness of code emission and simulation results
c. Architectural patterns / principles:
• Pipeline pattern: a parameter-search pipeline stitched from modular stages (generate → execute → measure)
• Separation of concerns: code-generation, simulation, native execution, and tuning are decoupled
• Extensible: new GEMM variants or hardware targets can be added by extending the generator or VM
d. Key technologies / libraries:
• Python 3.x (generator, VM, tuner, tests)
• C++17 (runner) + CMake + TOML for native execution
• pytest for test validation
Detail
• Sub-modules only if they add clarity (e.g., the runner’s Utils folder as an internal detail)
• External dependencies (Python, CMake, GPU hardware)
• Keep each component’s interface explicit (inputs/outputs)