Skip to content

Commit d85ba78

Browse files
committed
feat(docs): add bilingual English/Chinese documentation support
- Add language switcher with page-pair metadata (lang, page_key, lang_ref) - Create zh/ directory with Chinese counterparts for all public pages - Refresh README.md and README.zh-CN.md with unified structure - Update _config.yml for bilingual navigation - Add language-toggle.js and switcher styles - Update pages.yml workflow triggers for zh/** and _includes/** OpenSpec change: bilingual-docs-closeout
1 parent a1513bd commit d85ba78

35 files changed

Lines changed: 2133 additions & 72 deletions

.github/workflows/pages.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ on:
1212
- 'CONTRIBUTING.md'
1313
- 'index.md'
1414
- '_config.yml'
15+
- '_includes/**'
1516
- 'docs/**'
17+
- 'zh/**'
1618
- 'specs.md'
1719
- 'assets/**'
1820
- '_sass/**'

README.md

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@
22

33
[![CI](https://github.com/LessUp/sgemm-optimization/actions/workflows/ci.yml/badge.svg)](https://github.com/LessUp/sgemm-optimization/actions/workflows/ci.yml)
44
[![Pages](https://github.com/LessUp/sgemm-optimization/actions/workflows/pages.yml/badge.svg)](https://lessup.github.io/sgemm-optimization/)
5-
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE.md)
5+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
66
![CUDA](https://img.shields.io/badge/CUDA-11.0+-76B900?logo=nvidia&logoColor=white)
77
![C++](https://img.shields.io/badge/C%2B%2B-17-00599C?logo=c%2B%2B&logoColor=white)
88

99
English | [简体中文](README.zh-CN.md)
1010

11-
Progressive CUDA SGEMM tutorial and reference implementation. The repository contains five hand-written kernel variants, cuBLAS-backed verification, a benchmark harness, and OpenSpec-governed repository rules for keeping the project compact and trustworthy.
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.
1212

1313
## Why this repository exists
1414

15-
- **Show the optimization ladder clearly**: naive -> tiled -> bank-conflict-free -> double-buffered -> Tensor Core WMMA
16-
- **Stay readable**: each optimization lives in its own kernel file and keeps a consistent launch interface
17-
- **Stay verifiable**: kernels are checked against cuBLAS, with separate tolerances for FP32 and Tensor Core paths
18-
- **Stay maintainable**: the repository uses OpenSpec to keep docs, workflow, and validation rules aligned
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
1919

20-
## Kernel progression
20+
## Optimization ladder
2121

22-
| Stage | File | Main idea |
23-
|-------|------|-----------|
24-
| Naive | `src/kernels/naive_sgemm.cuh` | Baseline triple-loop mapping |
25-
| Tiled | `src/kernels/tiled_sgemm.cuh` | Shared-memory blocking |
26-
| Bank-Free | `src/kernels/bank_conflict_free_sgemm.cuh` | `[TILE_SIZE][TILE_SIZE+1]` padding |
27-
| Double Buffer | `src/kernels/double_buffer_sgemm.cuh` | Tile staging overlap and latency hiding |
28-
| Tensor Core | `src/kernels/tensor_core_sgemm.cuh` | WMMA path with safe FP32 fallback |
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 |
2929

3030
## Quick start
3131

@@ -47,21 +47,22 @@ make benchmark
4747
make test
4848
```
4949

50-
## Validation model
50+
## Where to start
5151

52-
- **Local GPU machine**: runtime tests, correctness checks, and benchmarking
53-
- **GitHub Actions**: format/style, CUDA compile validation, OpenSpec/repository checks, and Pages deployment
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) |
5459

55-
Standard FP32 kernels use `rtol=1e-3`, `atol=1e-4`. The Tensor Core path uses `rtol=5e-2`, `atol=1e-2`.
60+
## Validation boundary
5661

57-
## Read next
62+
- **Local GPU machine**: runtime tests, correctness checks, benchmarking
63+
- **GitHub Actions**: format/style, CUDA compile, OpenSpec checks, Pages deployment
5864

59-
- [Getting Started](docs/getting-started.md)
60-
- [Learning Path](docs/learning-path.md)
61-
- [Architecture Overview](docs/architecture.md)
62-
- [Benchmark Notes](docs/benchmark-results.md)
63-
- [Specifications Index](specs.md)
64-
- [GitHub Pages site](https://lessup.github.io/sgemm-optimization/)
65+
Standard FP32 kernels: `rtol=1e-3`, `atol=1e-4`. Tensor Core path: `rtol=5e-2`, `atol=1e-2`.
6566

6667
## Repository layout
6768

@@ -72,22 +73,22 @@ src/
7273
└── main.cu # Benchmark entry point
7374
tests/
7475
└── test_sgemm.cu # Google Test suite
75-
docs/ # Public learning-oriented documentation
76-
openspec/ # Stable specs, changes, and workflow guidance
76+
docs/ # Learning-oriented documentation
77+
openspec/ # Stable specs, changes, workflow guidance
7778
```
7879

79-
## Development workflow
80+
## Project status
8081

81-
Non-trivial repository changes are expected to follow:
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:
8283

83-
1. `/opsx:explore`
84-
2. `/opsx:propose "description"`
85-
3. `/opsx:apply`
86-
4. `/review`
87-
5. `/opsx:archive`
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
8889

89-
The stable authoritative specs live under `openspec/specs/`. Active implementation plans live under `openspec/changes/<change>/`.
90+
Stable specs: `openspec/specs/`. Active changes: `openspec/changes/<change>/`.
9091

9192
## License
9293

93-
MIT. See [LICENSE.md](LICENSE.md).
94+
MIT. See [LICENSE](LICENSE).

README.zh-CN.md

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@
88

99
[English](README.md) | 简体中文
1010

11-
这是一个渐进式 CUDA SGEMM 教程与参考实现仓库。项目用 5 个手写 kernel 展示从最朴素矩阵乘法到 Tensor Core WMMA 的优化路径,并配套 cuBLAS 对标验证、benchmark 工具,以及基于 OpenSpec 的仓库治理流程
11+
渐进式 CUDA SGEMM 教程与参考实现,从朴素 kernel Tensor Core WMMA。包含 cuBLAS 对标验证、benchmark 工具,以及 OpenSpec 仓库治理流程
1212

1313
## 为什么值得看
1414

15-
- **优化链条完整**:naive -> tiled -> bank-conflict-free -> double-buffer -> Tensor Core
16-
- **代码可读性强**每一级优化都独立成文件,并保持统一的 launch 接口
17-
- **验证链路完整**cuBLAS 做正确性对照,并区分标准 FP32 与 Tensor Core 容差
18-
- **工程边界清晰**仓库通过 OpenSpec 管理规范、文档、workflow 和收尾整理
15+
- **优化链条完整**:naive tiled bank-conflict-free double-buffer Tensor Core WMMA
16+
- **代码可读性强**每级优化独立成文件,保持统一的 launch 接口
17+
- **验证链路完整**:cuBLAS 正确性对照,区分标准 FP32 与 Tensor Core 容差
18+
- **工程边界清晰**:OpenSpec 管理规范、文档、workflow 和收尾整理
1919

20-
## Kernel 演进
20+
## 优化阶梯
2121

22-
| 阶段 | 文件 | 核心思路 |
23-
|------|------|----------|
24-
| Naive | `src/kernels/naive_sgemm.cuh` | 基础三层循环映射 |
25-
| Tiled | `src/kernels/tiled_sgemm.cuh` | 共享内存分块 |
26-
| Bank-Free | `src/kernels/bank_conflict_free_sgemm.cuh` | `[TILE_SIZE][TILE_SIZE+1]` padding 消除 bank 冲突 |
27-
| Double Buffer | `src/kernels/double_buffer_sgemm.cuh` | tile staging 重叠与延迟隐藏 |
28-
| Tensor Core | `src/kernels/tensor_core_sgemm.cuh` | WMMA 路径与安全 FP32 回退 |
22+
| 阶段 | Kernel | 学习重点 |
23+
|-----:|--------|----------|
24+
| 1 | [Naive](zh/docs/kernel-naive) | 线程到输出的映射与基线代价 |
25+
| 2 | [Tiled](zh/docs/kernel-tiled) | 共享内存分块与数据复用 |
26+
| 3 | [Bank-Free](zh/docs/kernel-bank-free) | Padding 消除 32 路 bank 冲突 |
27+
| 4 | [Double Buffer](zh/docs/kernel-double-buffer) | 分阶段 tile 加载与延迟隐藏 |
28+
| 5 | [Tensor Core](zh/docs/kernel-tensor-core) | WMMA 使用与安全的 FP32 回退 |
2929

3030
## 快速开始
3131

@@ -47,21 +47,22 @@ make benchmark
4747
make test
4848
```
4949

50-
## 验证边界
50+
## 从哪里开始
5151

52-
- **本地 GPU 机器**:运行时测试、正确性验证、benchmark
53-
- **GitHub Actions**:格式/风格、CUDA 编译验证、OpenSpec/仓库结构校验、Pages 部署
52+
| 如果你想... | 从这里开始 |
53+
|-------------|-----------|
54+
| 编译运行一次 | [快速上手](zh/docs/getting-started) |
55+
| 学习优化路径 | [学习路径](zh/docs/learning-path) |
56+
| 了解仓库结构 | [架构概览](zh/docs/architecture) |
57+
| 查看性能数据 | [Benchmark 结果](zh/docs/benchmark-results) |
58+
| 查看治理规则 | [规范索引](zh/specs) |
5459

55-
标准 FP32 kernel 使用 `rtol=1e-3``atol=1e-4`;Tensor Core 路径使用 `rtol=5e-2``atol=1e-2`
60+
## 验证边界
5661

57-
## 建议继续阅读
62+
- **本地 GPU 机器**:运行时测试、正确性验证、benchmark
63+
- **GitHub Actions**:格式/风格、CUDA 编译、OpenSpec 校验、Pages 部署
5864

59-
- [快速上手](docs/getting-started.md)
60-
- [学习路径](docs/learning-path.md)
61-
- [架构概览](docs/architecture.md)
62-
- [Benchmark 说明](docs/benchmark-results.md)
63-
- [规范索引](specs.md)
64-
- [GitHub Pages 站点](https://lessup.github.io/sgemm-optimization/)
65+
标准 FP32 kernel:`rtol=1e-3``atol=1e-4`。Tensor Core 路径:`rtol=5e-2``atol=1e-2`
6566

6667
## 仓库结构
6768

@@ -76,17 +77,17 @@ docs/ # 面向读者的学习型文档
7677
openspec/ # 稳定 specs、变更和流程说明
7778
```
7879

79-
## 开发流程
80+
## 项目状态
8081

81-
涉及仓库结构、规范或文档的非小改动,默认遵循
82+
本仓库处于**归档就绪**状态。所有 kernel 实现已完成,测试通过,文档对齐。非小改动遵循 OpenSpec 工作流
8283

83-
1. `/opsx:explore`
84-
2. `/opsx:propose "description"`
85-
3. `/opsx:apply`
86-
4. `/review`
87-
5. `/opsx:archive`
84+
1. `/opsx:explore` — 明确范围与权衡
85+
2. `/opsx:propose "描述"` — 创建变更文档
86+
3. `/opsx:apply` — 实施任务
87+
4. `/review` — 质量门禁
88+
5. `/opsx:archive` — 合并并关闭
8889

89-
稳定规范位于 `openspec/specs/`,活动实现计划位于 `openspec/changes/<change>/`
90+
稳定规范:`openspec/specs/`。活动变更:`openspec/changes/<change>/`
9091

9192
## 许可证
9293

_config.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ plugins:
1212

1313
title: SGEMM Optimization
1414
description: >-
15-
Learn CUDA SGEMM optimization from a readable baseline to Tensor Core WMMA,
16-
with verification, benchmarks, and compact engineering guidance.
15+
Bilingual CUDA SGEMM optimization tutorial and reference implementation,
16+
from naive kernels to Tensor Core WMMA.
1717
repository: LessUp/sgemm-optimization
1818
author: LessUp
1919
lang: en
@@ -31,7 +31,9 @@ aux_links_new_tab: true
3131
aux_links:
3232
"GitHub":
3333
- "//github.com/LessUp/sgemm-optimization"
34-
"README (中文)":
34+
"English README":
35+
- "//github.com/LessUp/sgemm-optimization/blob/master/README.md"
36+
"中文 README":
3537
- "//github.com/LessUp/sgemm-optimization/blob/master/README.zh-CN.md"
3638

3739
nav_external_links:

_includes/head_custom.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<script src="{{ '/assets/js/language-toggle.js' | relative_url }}" defer></script>

_includes/nav_footer_custom.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<div class="language-switcher"
2+
data-page-key="{{ page.page_key | default: 'unknown' }}"
3+
data-lang="{{ page.lang | default: 'en' }}"
4+
data-lang-ref="{{ page.lang_ref | default: '' }}">
5+
<span class="language-switcher-label">Lang:</span>
6+
<button type="button" data-lang-choice="en"
7+
class="{% if page.lang == 'en' or page.lang == nil %}is-active{% endif %}">
8+
EN
9+
</button>
10+
<button type="button" data-lang-choice="zh-CN"
11+
class="{% if page.lang == 'zh-CN' %}is-active{% endif %}">
12+
中文
13+
</button>
14+
</div>

_sass/custom/custom.scss

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,3 +651,59 @@ div.aux-nav {
651651
grid-template-columns: 1fr;
652652
}
653653
}
654+
655+
// ============================================
656+
// LANGUAGE SWITCHER
657+
// ============================================
658+
659+
.language-switcher {
660+
display: flex;
661+
align-items: center;
662+
gap: 0.5rem;
663+
margin: 0.75rem 0;
664+
padding: 0.5rem;
665+
background-color: var(--bg-tertiary);
666+
border-radius: 6px;
667+
border: 1px solid var(--border-subtle);
668+
}
669+
670+
.language-switcher-label {
671+
color: var(--text-muted);
672+
font-size: 0.75rem;
673+
text-transform: uppercase;
674+
letter-spacing: 0.05em;
675+
margin-right: 0.25rem;
676+
}
677+
678+
.language-switcher button {
679+
padding: 0.25rem 0.75rem;
680+
border: 1px solid var(--border-subtle);
681+
border-radius: 4px;
682+
background: transparent;
683+
color: var(--text-secondary);
684+
cursor: pointer;
685+
font-size: 0.875rem;
686+
font-weight: 500;
687+
transition: all 0.2s ease;
688+
}
689+
690+
.language-switcher button:hover {
691+
border-color: var(--nvidia-green);
692+
color: var(--nvidia-green);
693+
background-color: rgba(118, 185, 0, 0.05);
694+
}
695+
696+
.language-switcher button.is-active {
697+
border-color: var(--nvidia-green);
698+
color: var(--nvidia-green);
699+
background-color: rgba(118, 185, 0, 0.1);
700+
font-weight: 600;
701+
}
702+
703+
// Mobile adjustments for language switcher
704+
@media (max-width: 800px) {
705+
.language-switcher {
706+
justify-content: center;
707+
margin: 1rem 0;
708+
}
709+
}

0 commit comments

Comments
 (0)