Skip to content

Commit ee0135a

Browse files
LessUpqwencoder
andcommitted
feat(docs): comprehensive GitHub Pages optimization
- Add complete documentation suite: getting-started, architecture, kernel-details, and benchmark-results guides - Enhance _config.yml with sitemap, collections, and better defaults - Rewrite index.md as professional landing page with navigation - Create assets/ directory structure for diagrams and images - Clean up docs/ directory (removed nested repo and unrelated files) - Update pages.yml workflow to include docs/ and specs/ paths - Add jekyll-sitemap plugin for better SEO Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
1 parent 6969453 commit ee0135a

13 files changed

Lines changed: 1283 additions & 80 deletions

File tree

.github/workflows/pages.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ on:
1212
- 'README.zh-CN.md'
1313
- 'CHANGELOG.md'
1414
- '_config.yml'
15+
- 'docs/**'
16+
- 'specs/**'
1517
- '.github/workflows/pages.yml'
1618
workflow_dispatch:
1719

@@ -38,7 +40,11 @@ jobs:
3840
README.zh-CN.md
3941
_config.yml
4042
CHANGELOG.md
43+
CONTRIBUTING.md
4144
LICENSE
45+
docs/
46+
specs/
47+
assets/
4248
4349
- name: Setup Pages
4450
uses: actions/configure-pages@v5

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,3 @@ _site/
4545
# OS
4646
.DS_Store
4747
Thumbs.db
48-
49-
# Separate git repository
50-
docs/

_config.yml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,85 @@ remote_theme: pages-themes/cayman@v0.2.0
99
plugins:
1010
- jekyll-remote-theme
1111
- jekyll-seo-tag
12+
- jekyll-sitemap
1213

1314
# Site info
1415
title: SGEMM Optimization
1516
description: >-
16-
从零手写极致优化的 CUDA 矩阵乘法 — HPC 领域的 "Hello World"
17-
五个渐进式优化的 kernel 变体,展示 GPU 核心优化技术。
17+
Hand-written, progressively optimized CUDA matrix multiplication — the "Hello World" of HPC.
18+
Five kernel variants from naive triple-loop to Tensor Core WMMA.
1819
repository: LessUp/sgemm-optimization
1920

2021
# URLs
21-
url: https://lessup.github.io
22+
url: "https://lessup.github.io"
2223
baseurl: /sgemm-optimization
2324

2425
# Localization
25-
lang: zh-CN
26+
lang: en
2627
author: LessUp
2728

2829
# Navigation
29-
show_downloads: false
30+
show_downloads: true
3031

3132
# Markdown
3233
markdown: kramdown
3334
kramdown:
3435
input: GFM
3536
hard_wrap: false
3637
syntax_highlighter: rouge
38+
syntax_highlighter_opts:
39+
css_class: highlight
40+
span:
41+
line_numbers: false
42+
block:
43+
line_numbers: true
44+
start_line: 1
45+
46+
# Collections
47+
collections:
48+
docs:
49+
output: true
50+
permalink: /:collection/:path/
3751

3852
# Defaults
3953
defaults:
4054
- scope:
4155
path: ""
4256
values:
4357
layout: default
58+
- scope:
59+
path: "docs"
60+
type: "pages"
61+
values:
62+
layout: default
63+
nav_order: 1
64+
- scope:
65+
path: "specs"
66+
type: "pages"
67+
values:
68+
layout: default
4469

4570
# Exclude from build
4671
exclude:
4772
- build/
4873
- cmake-build-*/
4974
- src/
5075
- tests/
76+
- benchmarks/data/
5177
- .github/
5278
- .kiro/
5379
- .vscode/
80+
- node_modules/
81+
- vendor/
5482
- "*.cu"
5583
- "*.cuh"
5684
- "*.csv"
5785
- "*.o"
5886
- "*.so"
87+
- "*.a"
5988
- .editorconfig
6089
- .gitignore
6190
- CMakeLists.txt
6291
- Makefile
92+
- Gemfile
93+
- Gemfile.lock

assets/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Assets
2+
3+
This directory contains static assets for the GitHub Pages site.
4+
5+
## Structure
6+
7+
- `images/` - Diagrams, screenshots, and visual assets
8+
- `css/` - Custom stylesheets (optional)
9+
- `js/` - Custom JavaScript (optional)
10+
11+
## Adding Images
12+
13+
Place diagrams and screenshots here. Recommended formats:
14+
15+
- **SVG** - Architecture diagrams, flow charts (scalable)
16+
- **PNG** - Benchmark charts, screenshots (lossless)
17+
- **WebP** - Photos or complex visuals (compressed)
18+
19+
## Current Assets
20+
21+
| Asset | Purpose | Status |
22+
|-------|---------|--------|
23+
| `images/` | Diagrams and charts | Ready for content |

assets/images/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Images
2+
3+
Place diagrams, charts, and screenshots here.
4+
5+
## Suggested Assets
6+
7+
- `architecture-diagram.svg` - System architecture visualization
8+
- `optimization-roadmap.svg` - Kernel evolution flowchart
9+
- `performance-chart.png` - Benchmark results visualization
10+
- `roofline-model.svg` - Roofline analysis diagram
11+
- `memory-access-patterns.svg` - Coalescing vs non-coalescing visualization

docs

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SGEMM Optimization Documentation
2+
3+
Comprehensive documentation for the SGEMM Optimization project, covering architecture, implementation details, performance analysis, and usage guides.
4+
5+
## Documentation Index
6+
7+
### Getting Started
8+
- [Quick Start Guide](getting-started.md) - Build, run, and benchmark in 5 minutes
9+
- [Project Overview](../README.md) - High-level introduction and roadmap
10+
11+
### Technical Documentation
12+
- [Architecture Guide](architecture.md) - System design and interface specifications
13+
- [Kernel Implementations](kernel-details.md) - Deep dive into each kernel variant
14+
- [Benchmark Results](benchmark-results.md) - Performance analysis and comparisons
15+
16+
### Specifications (Spec-Driven Development)
17+
- [Product Requirements](../specs/product/sgemm-kernel-requirements.md) - Functional requirements
18+
- [Core Architecture RFC](../specs/rfc/0001-core-architecture.md) - Technical design decisions
19+
- [Implementation Roadmap](../specs/rfc/0002-implementation-roadmap.md) - Development phases
20+
- [Test Specifications](../specs/testing/kernel-verification.md) - Verification scenarios
21+
22+
### Additional Resources
23+
- [CHANGELOG](../CHANGELOG.md) - Version history
24+
- [Contributing Guide](../CONTRIBUTING.md) - How to contribute
25+
- [License](../LICENSE) - MIT License
26+
27+
---
28+
29+
**GitHub Pages**: https://lessup.github.io/sgemm-optimization/
30+
**Repository**: https://github.com/LessUp/sgemm-optimization

docs/_config.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
layout: default
3+
title: Navigation
4+
nav_order: 1
5+
---
6+
7+
# Navigation
8+
9+
This file provides navigation structure for the documentation site.
10+
11+
## Main Sections
12+
13+
1. [Home](../index.md) - Project landing page
14+
2. [Getting Started](getting-started.md) - Quick start guide
15+
3. Architecture & Implementation
16+
- [Architecture Guide](architecture.md)
17+
- [Kernel Details](kernel-details.md)
18+
- [Benchmark Results](benchmark-results.md)
19+
4. Specifications
20+
- [Product Requirements](../specs/product/sgemm-kernel-requirements.md)
21+
- [Core Architecture RFC](../specs/rfc/0001-core-architecture.md)
22+
- [Test Specifications](../specs/testing/kernel-verification.md)
23+
5. [CHANGELOG](../CHANGELOG.md)

docs/architecture.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
---
2+
layout: default
3+
title: Architecture Guide
4+
nav_order: 2
5+
---
6+
7+
# Architecture Guide
8+
9+
This document describes the system architecture and design decisions for the SGEMM Optimization project.
10+
11+
## System Overview
12+
13+
The project implements five progressively optimized CUDA SGEMM (Single-precision General Matrix Multiply) kernels, demonstrating core GPU optimization techniques from a naive triple-loop to Tensor Core WMMA API usage.
14+
15+
### Design Principles
16+
17+
1. **Single Source of Truth**: All implementations follow specifications in `/specs/`
18+
2. **Spec-Driven Development (SDD)**: Specs before code, documentation synchronized with implementation
19+
3. **RAII Resource Management**: No raw `cudaFree()` calls, all resources use wrapper classes
20+
4. **Exception-Based Error Handling**: No `exit()` in library code
21+
5. **Header-Only Kernels**: All kernels are `.cuh` files for easy integration
22+
23+
## Architecture Layers
24+
25+
```
26+
┌─────────────────────────────────────────────┐
27+
│ Application Layer │
28+
│ main.cu - Entry point & benchmark runner │
29+
├─────────────────────────────────────────────┤
30+
│ Framework Layer │
31+
│ utils/benchmark.cuh - Benchmark framework │
32+
│ utils/verify.cuh - Correctness checks │
33+
│ utils/cuda_utils.cuh - RAII wrappers │
34+
├─────────────────────────────────────────────┤
35+
│ Kernel Layer │
36+
│ kernels/naive_sgemm.cuh │
37+
│ kernels/tiled_sgemm.cuh │
38+
│ kernels/bank_conflict_free_sgemm.cuh │
39+
│ kernels/double_buffer_sgemm.cuh │
40+
│ kernels/tensor_core_sgemm.cuh │
41+
├─────────────────────────────────────────────┤
42+
│ CUDA Runtime Layer │
43+
│ cuBLAS, CUDA Runtime API, WMMA API │
44+
└─────────────────────────────────────────────┘
45+
```
46+
47+
## Unified Kernel Interface
48+
49+
All kernels implement the same interface template:
50+
51+
```cpp
52+
template<int TILE_SIZE = 32>
53+
void sgemm_naive(const float* A, const float* B, float* C,
54+
int M, int N, int K, cudaStream_t stream = 0);
55+
56+
template<int TILE_SIZE = 32>
57+
void sgemm_tiled(const float* A, const float* B, float* C,
58+
int M, int N, int K, cudaStream_t stream = 0);
59+
60+
// ... and so on for each variant
61+
```
62+
63+
### Interface Contract
64+
65+
| Parameter | Description | Constraints |
66+
|-----------|-------------|-------------|
67+
| `A` | Input matrix A (M×K), row-major | Device pointer, valid |
68+
| `B` | Input matrix B (K×N), row-major | Device pointer, valid |
69+
| `C` | Output matrix C (M×N), row-major | Device pointer, allocated |
70+
| `M` | Rows of A and C | M > 0 |
71+
| `N` | Columns of B and C | N > 0 |
72+
| `K` | Columns of A / Rows of B | K > 0 |
73+
| `stream` | CUDA stream (optional) | Default: 0 |
74+
75+
### Grid-Block Configuration
76+
77+
```cpp
78+
dim3 block(TILE_SIZE, TILE_SIZE);
79+
dim3 grid((N + TILE_SIZE - 1) / TILE_SIZE,
80+
(M + TILE_SIZE - 1) / TILE_SIZE);
81+
```
82+
83+
## Tensor Core Architecture
84+
85+
The Tensor Core kernel uses NVIDIA's WMMA (Warp Matrix Multiply Accumulate) API:
86+
87+
### Architecture-Specific Guards
88+
89+
```cpp
90+
#if __CUDA_ARCH__ >= 700
91+
// WMMA code for Volta and newer
92+
#include <mma.h>
93+
#else
94+
// Fallback to FP32 tiled kernel
95+
#endif
96+
```
97+
98+
### Alignment Requirements
99+
100+
| Requirement | Detail |
101+
|-------------|--------|
102+
| M, K, N | Must be multiples of 16 for WMMA fast path |
103+
| Fallback | Automatic FP32 kernel for non-aligned sizes |
104+
| Precision | FP16 input, FP32 accumulation |
105+
| Verification | Relaxed tolerances: `rtol=5e-2, atol=1e-2` |
106+
107+
## Error Handling Strategy
108+
109+
All errors are handled via exceptions, not `exit()`:
110+
111+
```cpp
112+
#define CUDA_CHECK(call) \
113+
do { \
114+
cudaError_t err = call; \
115+
if (err != cudaSuccess) { \
116+
throw std::runtime_error( \
117+
std::string("CUDA error: ") + \
118+
cudaGetErrorString(err)); \
119+
} \
120+
} while(0)
121+
```
122+
123+
## Memory Management
124+
125+
RAII wrappers ensure no memory leaks:
126+
127+
```cpp
128+
struct DeviceBuffer {
129+
float* ptr;
130+
DeviceBuffer(size_t bytes) {
131+
CUDA_CHECK(cudaMalloc(&ptr, bytes));
132+
}
133+
~DeviceBuffer() {
134+
CUDA_CHECK(cudaFree(ptr));
135+
}
136+
// Deleted copy/move constructors prevent misuse
137+
};
138+
```
139+
140+
## Build System
141+
142+
### CMake (Recommended)
143+
144+
```cmake
145+
add_executable(sgemm_benchmark src/main.cu)
146+
target_link_libraries(sgemm_benchmark PRIVATE cublas)
147+
set_target_properties(sgemm_benchmark PROPERTIES
148+
CUDA_ARCHITECTURES ${GPU_ARCH})
149+
```
150+
151+
### GPU Architecture Support
152+
153+
| GPU | Architecture | Flag |
154+
|-----|-------------|------|
155+
| V100 | Volta | `sm_70` |
156+
| RTX 3090/A100 | Ampere | `sm_86` |
157+
| RTX 4090 | Ada | `sm_89` |
158+
| H100 | Hopper | `sm_90` |
159+
160+
## References
161+
162+
- [RFC 0001: Core Architecture](../specs/rfc/0001-core-architecture.md)
163+
- [RFC 0002: Implementation Roadmap](../specs/rfc/0002-implementation-roadmap.md)
164+
- [CUDA Programming Guide](https://docs.nvidia.com/cuda/)

0 commit comments

Comments
 (0)