|
2 | 2 |
|
3 | 3 | [](https://github.com/LessUp/sgemm-optimization/actions/workflows/ci.yml) |
4 | 4 | [](https://lessup.github.io/sgemm-optimization/) |
5 | | -[](LICENSE) |
| 5 | +[](LICENSE.md) |
6 | 6 |  |
7 | 7 |  |
8 | 8 |
|
9 | 9 | English | [简体中文](README.zh-CN.md) |
10 | 10 |
|
11 | | -Progressive CUDA SGEMM tutorial and reference implementation, from naive kernels to Tensor Core WMMA. Includes cuBLAS-backed verification, benchmark harness, and OpenSpec-governed repository rules. |
| 11 | +A compact CUDA SGEMM learning project that walks from a readable baseline kernel to Tensor Core WMMA, with cuBLAS verification and a CMake-first build. |
12 | 12 |
|
13 | | -## Why this repository exists |
| 13 | +## What makes it useful |
14 | 14 |
|
15 | | -- **Show the optimization ladder clearly**: naive → tiled → bank-conflict-free → double-buffer → Tensor Core WMMA |
16 | | -- **Stay readable**: each optimization lives in its own kernel file with a consistent launch interface |
17 | | -- **Stay verifiable**: kernels are checked against cuBLAS with separate tolerances for FP32 and Tensor Core paths |
18 | | -- **Stay maintainable**: OpenSpec keeps docs, workflow, and validation rules aligned |
19 | | - |
20 | | -## Optimization ladder |
21 | | - |
22 | | -| Stage | Kernel | What you learn | |
23 | | -|------:|--------|----------------| |
24 | | -| 1 | [Naive](docs/kernel-naive/) | Thread-to-output mapping and baseline cost | |
25 | | -| 2 | [Tiled](docs/kernel-tiled/) | Shared-memory blocking and data reuse | |
26 | | -| 3 | [Bank-Free](docs/kernel-bank-free/) | Padding away 32-way bank conflicts | |
27 | | -| 4 | [Double Buffer](docs/kernel-double-buffer/) | Latency hiding through staged tiles | |
28 | | -| 5 | [Tensor Core](docs/kernel-tensor-core/) | WMMA usage with guarded FP32 fallback | |
| 15 | +- **One optimization ladder**: naive -> tiled -> bank-conflict-free -> double-buffer -> Tensor Core. |
| 16 | +- **Comparable kernel interfaces**: every FP32 kernel uses the same `(A, B, C, M, K, N, stream)` launcher shape. |
| 17 | +- **Verification-first harness**: kernel output is checked against cuBLAS with separate tolerances for FP32 and Tensor Core paths. |
| 18 | +- **Learning-oriented docs**: GitHub Pages carries the full walkthrough instead of duplicating it in the README. |
29 | 19 |
|
30 | 20 | ## Quick start |
31 | 21 |
|
32 | 22 | ```bash |
33 | 23 | git clone https://github.com/LessUp/sgemm-optimization.git |
34 | 24 | cd sgemm-optimization |
35 | 25 |
|
36 | | -# Recommended: CMake |
37 | 26 | cmake -S . -B build -DCMAKE_BUILD_TYPE=Release |
38 | 27 | cmake --build build -j$(nproc) |
39 | 28 | ./build/bin/sgemm_benchmark -a |
40 | 29 | ctest --test-dir build |
41 | 30 | ``` |
42 | 31 |
|
43 | | -```bash |
44 | | -# Quick local alternative |
45 | | -make GPU_ARCH=sm_86 |
46 | | -make benchmark |
47 | | -make test |
48 | | -``` |
49 | | - |
50 | | -## Where to start |
51 | | - |
52 | | -| If you want to... | Start here | |
53 | | -|-------------------|------------| |
54 | | -| Build and run once | [Getting Started](docs/getting-started/) | |
55 | | -| Learn the optimization path | [Learning Path](docs/learning-path/) | |
56 | | -| Understand repository structure | [Architecture](docs/architecture/) | |
57 | | -| See performance context | [Benchmark Results](docs/benchmark-results/) | |
58 | | -| Inspect governance rules | [Specifications](specs/) | |
| 32 | +Runtime tests and benchmarks require a CUDA-capable local machine. Hosted CI is limited to compile-time, formatting, repository-structure, OpenSpec, and Pages checks. |
59 | 33 |
|
60 | | -## Validation boundary |
| 34 | +## Start here |
61 | 35 |
|
62 | | -- **Local GPU machine**: runtime tests, correctness checks, benchmarking |
63 | | -- **GitHub Actions**: format/style, CUDA compile, OpenSpec checks, Pages deployment |
| 36 | +| Goal | Entry point | |
| 37 | +|------|-------------| |
| 38 | +| Use the project site | [GitHub Pages](https://lessup.github.io/sgemm-optimization/) | |
| 39 | +| Build and run once | [Getting Started](docs/getting-started.md) | |
| 40 | +| Follow the kernel ladder | [Learning Path](docs/learning-path.md) | |
| 41 | +| Inspect the source layout | [Architecture](docs/architecture.md) | |
| 42 | +| Read the normative specs | [Specifications](specs.md) | |
64 | 43 |
|
65 | | -Standard FP32 kernels: `rtol=1e-3`, `atol=1e-4`. Tensor Core path: `rtol=5e-2`, `atol=1e-2`. |
66 | | - |
67 | | -## Repository layout |
| 44 | +## Source map |
68 | 45 |
|
69 | 46 | ```text |
70 | | -src/ |
71 | | -├── kernels/ # Five SGEMM kernel variants |
72 | | -├── utils/ # CUDA RAII, verification, benchmark helpers |
73 | | -└── main.cu # Benchmark entry point |
74 | | -tests/ |
75 | | -└── test_sgemm.cu # Google Test suite |
76 | | -docs/ # Learning-oriented documentation |
77 | | -openspec/ # Stable specs, changes, workflow guidance |
| 47 | +src/kernels/ CUDA SGEMM implementations |
| 48 | +src/utils/ CUDA RAII, verification, benchmark helpers |
| 49 | +src/main.cu benchmark CLI |
| 50 | +tests/ Google Test coverage against cuBLAS |
| 51 | +docs/ learning documentation mirrored on Pages |
| 52 | +openspec/ stable specs and change workflow |
78 | 53 | ``` |
79 | 54 |
|
80 | | -## Project status |
81 | | - |
82 | | -This repository is in **archive-ready** state. All kernel implementations are complete, tests pass, and documentation is aligned. Non-trivial changes follow the OpenSpec workflow: |
83 | | - |
84 | | -1. `/opsx:explore` — clarify scope and trade-offs |
85 | | -2. `/opsx:propose "description"` — create change artifacts |
86 | | -3. `/opsx:apply` — implement tasks |
87 | | -4. `/review` — quality gate |
88 | | -5. `/opsx:archive` — merge and close |
89 | | - |
90 | | -Stable specs: `openspec/specs/`. Active changes: `openspec/changes/<change>/`. |
91 | | - |
92 | 55 | ## License |
93 | 56 |
|
94 | | -MIT. See [LICENSE](LICENSE). |
| 57 | +MIT. See [LICENSE.md](LICENSE.md). |
0 commit comments