# capple217/tiled-sgemm architecture

> Architecture diagram of the GitHub repository capple217/tiled-sgemm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/capple217/tiled-sgemm
- Repository: https://github.com/capple217/tiled-sgemm

## Overview

This repository is a CUDA SGEMM optimization and measurement project. Its main workflow is to run a selected kernel stage, verify its result, time it against a precision-matched cuBLAS baseline, and compare performance with device peaks. Separate capabilities cover template autotuning and Nsight Compute profiling, with results summarized and plotted. Stage implementations and several core utilities are identified by the supplied tree and excerpts; some internal dispatch details are not shown, so those links are omitted.

Main entry points: [`src/registry.cu`](https://github.com/capple217/tiled-sgemm/blob/main/src/registry.cu) (Kernel registry), [`bench/bench.cu`](https://github.com/capple217/tiled-sgemm/blob/main/bench/bench.cu) (Benchmark driver), [`scripts/collate.py`](https://github.com/capple217/tiled-sgemm/blob/main/scripts/collate.py) (Run summary), [`src/check.cu`](https://github.com/capple217/tiled-sgemm/blob/main/src/check.cu) (GPU correctness check)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_kernels["SGEMM stages"]
  node_registry["Kernel registry<br/>[registry.cu]"]
  node_naive["Naive kernel<br/>[01_naive.cu]"]
  node_coalesced["Coalesced kernel<br/>[02_coalesced.cu]"]
  node_smem["Shared-memory tiling<br/>[03_smem_tiling.cu]"]
  node_tile1d["1D register tiling"]
  node_tile2d["2D register tiling"]
  node_vectorized["Vectorized kernel<br/>[06_vectorized.cu]"]
  node_warp["Warp tiling<br/>[07_warptiling.cu]"]
  node_tf32["TF32 WMMA kernel<br/>[09_tf32_wmma.cu]"]
end

subgraph group_validation["Numerics and reference"]
  node_check["GPU correctness check<br/>[check.cu]"]
  node_hostutils["Host numerics<br/>[host_utils.hpp]"]
  node_precision["Precision policy<br/>[precision.hpp]"]
  node_cublas["cuBLAS reference<br/>[cublas_ref.cu]"]
end

subgraph group_measurement["Benchmark and tuning"]
  node_driver["Benchmark driver<br/>[bench.cu]"]
  node_autotune["Template autotuner<br/>[autotune.cu]"]
  node_timing["CUDA-event timing<br/>[timing.hpp]"]
  node_device["Device and peak info<br/>[device_info.cu]"]
end

subgraph group_analysis["Profiling and reports"]
  node_ncu["Nsight profiling<br/>[profile.sh]"]
  node_summarize["Counter summaries<br/>[summarize.py]"]
  node_plot["Performance plots<br/>[plot.py]"]
  node_collate["Run summary<br/>[collate.py]"]
end

node_user(("Engineer"))

node_user -->|"runs sweep"| node_driver
node_driver -->|"iterates kernels"| node_registry
node_registry -->|"dispatches"| node_naive
node_registry -->|"dispatches"| node_coalesced
node_registry -->|"dispatches"| node_smem
node_registry -->|"dispatches"| node_tile1d
node_registry -->|"dispatches"| node_tile2d
node_registry -->|"dispatches"| node_vectorized
node_registry -->|"dispatches"| node_warp
node_registry -->|"dispatches"| node_tf32
node_driver -->|"verifies results"| node_check
node_driver -->|"compares against"| node_cublas
node_driver -->|"times runs"| node_timing
node_driver -->|"records peaks"| node_device
node_check -->|"uses tolerances"| node_hostutils
node_hostutils -->|"uses precision"| node_precision
node_user -->|"tunes families"| node_autotune
node_user -->|"profiles stages"| node_ncu
node_ncu -->|"summarizes counters"| node_summarize
node_user -->|"plots results"| node_plot
node_user -->|"builds run summary"| node_collate
node_collate -->|"uses plotting"| node_plot
node_collate -->|"uses metrics"| node_summarize

click node_driver "https://github.com/capple217/tiled-sgemm/blob/main/bench/bench.cu"
click node_registry "https://github.com/capple217/tiled-sgemm/blob/main/src/registry.cu"
click node_naive "https://github.com/capple217/tiled-sgemm/blob/main/kernels/01_naive.cu"
click node_coalesced "https://github.com/capple217/tiled-sgemm/blob/main/kernels/02_coalesced.cu"
click node_smem "https://github.com/capple217/tiled-sgemm/blob/main/kernels/03_smem_tiling.cu"
click node_tile1d "https://github.com/capple217/tiled-sgemm/blob/main/kernels/04_blocktiling_1d.cu"
click node_tile2d "https://github.com/capple217/tiled-sgemm/blob/main/kernels/05_blocktiling_2d.cu"
click node_vectorized "https://github.com/capple217/tiled-sgemm/blob/main/kernels/06_vectorized.cu"
click node_warp "https://github.com/capple217/tiled-sgemm/blob/main/kernels/07_warptiling.cu"
click node_autotune "https://github.com/capple217/tiled-sgemm/blob/main/bench/autotune.cu"
click node_tf32 "https://github.com/capple217/tiled-sgemm/blob/main/kernels/09_tf32_wmma.cu"
click node_check "https://github.com/capple217/tiled-sgemm/blob/main/src/check.cu"
click node_hostutils "https://github.com/capple217/tiled-sgemm/blob/main/include/sgemm/host_utils.hpp"
click node_precision "https://github.com/capple217/tiled-sgemm/blob/main/include/sgemm/precision.hpp"
click node_cublas "https://github.com/capple217/tiled-sgemm/blob/main/src/cublas_ref.cu"
click node_timing "https://github.com/capple217/tiled-sgemm/blob/main/include/sgemm/timing.hpp"
click node_device "https://github.com/capple217/tiled-sgemm/blob/main/src/device_info.cu"
click node_ncu "https://github.com/capple217/tiled-sgemm/blob/main/profiling/profile.sh"
click node_summarize "https://github.com/capple217/tiled-sgemm/blob/main/profiling/summarize.py"
click node_plot "https://github.com/capple217/tiled-sgemm/blob/main/scripts/plot.py"
click node_collate "https://github.com/capple217/tiled-sgemm/blob/main/scripts/collate.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_registry,node_naive,node_coalesced,node_smem,node_tile1d,node_tile2d,node_vectorized,node_warp,node_tf32 toneBlue
class node_check,node_hostutils,node_precision,node_cublas toneAmber
class node_driver,node_autotune,node_timing,node_device toneMint
class node_ncu,node_summarize,node_plot,node_collate toneRose
class node_user toneIndigo
```

## Components

### SGEMM stages

- [Kernel registry](https://github.com/capple217/tiled-sgemm/blob/main/src/registry.cu): `src/registry.cu`
- [Naive kernel](https://github.com/capple217/tiled-sgemm/blob/main/kernels/01_naive.cu): `kernels/01_naive.cu`
- [Coalesced kernel](https://github.com/capple217/tiled-sgemm/blob/main/kernels/02_coalesced.cu): `kernels/02_coalesced.cu`
- [Shared-memory tiling](https://github.com/capple217/tiled-sgemm/blob/main/kernels/03_smem_tiling.cu): `kernels/03_smem_tiling.cu`
- [1D register tiling](https://github.com/capple217/tiled-sgemm/blob/main/kernels/04_blocktiling_1d.cu): `kernels/04_blocktiling_1d.cu`
- [2D register tiling](https://github.com/capple217/tiled-sgemm/blob/main/kernels/05_blocktiling_2d.cu): `kernels/05_blocktiling_2d.cu`
- [Vectorized kernel](https://github.com/capple217/tiled-sgemm/blob/main/kernels/06_vectorized.cu): `kernels/06_vectorized.cu`
- [Warp tiling](https://github.com/capple217/tiled-sgemm/blob/main/kernels/07_warptiling.cu): `kernels/07_warptiling.cu`
- [TF32 WMMA kernel](https://github.com/capple217/tiled-sgemm/blob/main/kernels/09_tf32_wmma.cu): `kernels/09_tf32_wmma.cu`

### Numerics and reference

- [GPU correctness check](https://github.com/capple217/tiled-sgemm/blob/main/src/check.cu): `src/check.cu`
- [Host numerics](https://github.com/capple217/tiled-sgemm/blob/main/include/sgemm/host_utils.hpp): `include/sgemm/host_utils.hpp`
- [Precision policy](https://github.com/capple217/tiled-sgemm/blob/main/include/sgemm/precision.hpp): `include/sgemm/precision.hpp`
- [cuBLAS reference](https://github.com/capple217/tiled-sgemm/blob/main/src/cublas_ref.cu): `src/cublas_ref.cu`

### Benchmark and tuning

- [Benchmark driver](https://github.com/capple217/tiled-sgemm/blob/main/bench/bench.cu): `bench/bench.cu`
- [Template autotuner](https://github.com/capple217/tiled-sgemm/blob/main/bench/autotune.cu): `bench/autotune.cu`
- [CUDA-event timing](https://github.com/capple217/tiled-sgemm/blob/main/include/sgemm/timing.hpp): `include/sgemm/timing.hpp`
- [Device and peak info](https://github.com/capple217/tiled-sgemm/blob/main/src/device_info.cu): `src/device_info.cu`

### Profiling and reports

- [Nsight profiling](https://github.com/capple217/tiled-sgemm/blob/main/profiling/profile.sh): `profiling/profile.sh`
- [Counter summaries](https://github.com/capple217/tiled-sgemm/blob/main/profiling/summarize.py): `profiling/summarize.py`
- [Performance plots](https://github.com/capple217/tiled-sgemm/blob/main/scripts/plot.py): `scripts/plot.py`
- [Run summary](https://github.com/capple217/tiled-sgemm/blob/main/scripts/collate.py): `scripts/collate.py`

### Other components

- **Engineer**

## Connections

- Engineer → Benchmark driver: runs sweep (evidence: `README.md`)
- Benchmark driver → Kernel registry: iterates kernels (evidence: `README.md`)
- Kernel registry → Naive kernel: dispatches (evidence: `README.md`)
- Kernel registry → Coalesced kernel: dispatches (evidence: `README.md`)
- Kernel registry → Shared-memory tiling: dispatches (evidence: `README.md`)
- Kernel registry → 1D register tiling: dispatches (evidence: `README.md`)
- Kernel registry → 2D register tiling: dispatches (evidence: `README.md`)
- Kernel registry → Vectorized kernel: dispatches (evidence: `README.md`)
- Kernel registry → Warp tiling: dispatches (evidence: `README.md`)
- Kernel registry → TF32 WMMA kernel: dispatches (evidence: `README.md`)
- Benchmark driver → GPU correctness check: verifies results (evidence: `README.md`)
- Benchmark driver → cuBLAS reference: compares against (evidence: `README.md`)
- Benchmark driver → CUDA-event timing: times runs (evidence: `include/sgemm/timing.hpp`)
- Benchmark driver → Device and peak info: records peaks (evidence: `README.md`)
- GPU correctness check → Host numerics: uses tolerances
- Host numerics → Precision policy: uses precision (evidence: `include/sgemm/host_utils.hpp`)
- Engineer → Template autotuner: tunes families (evidence: `README.md`)
- Engineer → Nsight profiling: profiles stages (evidence: `README.md`)
- Nsight profiling → Counter summaries: summarizes counters (evidence: `README.md`)
- Engineer → Performance plots: plots results (evidence: `README.md`)
- Engineer → Run summary: builds run summary (evidence: `README.md`)
- Run summary → Performance plots: uses plotting (evidence: `scripts/collate.py`)
- Run summary → Counter summaries: uses metrics (evidence: `scripts/collate.py`)
