File contents Kernel Benchmark
对 CUDA kernel 执行正确性验证 + 压测,最后汇总结果。
执行流程
所有命令均在项目根目录 中执行。
进度追踪
复制如下 checklist 并实时更新:
Task Progress:
- [ ] Step 1: 正确性验证 + 性能压测 (benchmark.py)
- [ ] Step 2: 汇总输出结果
Step 1: 正确性验证 + 性能压测
benchmark.py 在有 --ref 时会先做正确性校验,不通过则直接退出(exit code 非 0) ,通过后再分别对 ref 和 kernel 压测并打印汇总。
python3 skills/kernel-benchmark/scripts/benchmark.py <cu_file> \
--ref=<ref_file> [--PARAM=VALUE ...] --repeat=20
示例 (矩阵转置):
python3 skills/kernel-benchmark/scripts/benchmark.py kernel/MatrixTranspose/solution.cu \
--ref=kernel/MatrixTranspose/transpose_ref.py --M=10000 --N=1000 --repeat=20
若校验失败 (exit code 非 0 或输出含 FAIL),停止后续步骤,将错误信息反馈给用户。
若校验通过 (ALL PASS ✓),继续 Step 2。
参数推断规则
参数
推断方式
<cu_file>
用户提供的 .cu 文件路径
<ref_file>
用户提供;若未指定,在 .cu 文件同级目录下查找 *_ref.py(如 matmul_ref.py、vector_add_ref.py、transpose_ref.py)
维度参数 (--M, --N, --K 等)
从 extern "C" void solve(...) 签名推断参数名;未指定时用合理默认值(矩阵乘法 M=K=N=4096,向量加法 N=1000000)
--repeat
默认 20
Step 2: 汇总输出
## Kernel 验证报告
### 基本信息
- **Kernel 文件**: `<cu_file>`
- **参考实现**: `<ref_file>`
- **维度参数**: M=..., N=... (等)
- **GPU**: <GPU name>
### 1. 正确性验证
- **结果**: ✅ ALL PASS / ❌ FAILED
- (如失败,附上错误信息)
### 2. 性能压测
| 指标 | Kernel | Reference |
|------|--------|-----------|
| Average | X.XXXX ms | X.XXXX ms |
| Median | X.XXXX ms | X.XXXX ms |
| Min | X.XXXX ms | X.XXXX ms |
| Max | X.XXXX ms | X.XXXX ms |
| ~Bandwidth | XX.XX GB/s | XX.XX GB/s |
| Speedup | X.XXx vs ref | — |
Source: gxinlong/cuda-optimization-skill — distributed by TomeVault .
1 --- 2 name: gxinlong-cuda-optimization-skill-cuda-optimization-skill 3 description: Kernel Benchmark 4 --- 5 6 # Kernel Benchmark 7 8 对 CUDA kernel 执行正确性验证 + 压测,最后汇总结果。 9 10 ## 执行流程 11 12 所有命令均在项目**根目录**中执行。 13 14 ### 进度追踪 15 16 复制如下 checklist 并实时更新: 17 18 ``` 19 Task Progress: 20 - [ ] Step 1: 正确性验证 + 性能压测 (benchmark.py) 21 - [ ] Step 2: 汇总输出结果 22 ``` 23 24 --- 25 26 ### Step 1: 正确性验证 + 性能压测 27 28 `benchmark.py` 在有 `--ref` 时会先做正确性校验,**不通过则直接退出(exit code 非 0)**,通过后再分别对 ref 和 kernel 压测并打印汇总。 29 30 ```bash 31 python3 skills/kernel-benchmark/scripts/benchmark.py <cu_file> \ 32 --ref=<ref_file> [--PARAM=VALUE ...] --repeat=20 33 ``` 34 35 **示例**(矩阵转置): 36 37 ```bash 38 python3 skills/kernel-benchmark/scripts/benchmark.py kernel/MatrixTranspose/solution.cu \ 39 --ref=kernel/MatrixTranspose/transpose_ref.py --M=10000 --N=1000 --repeat=20 40 ``` 41 42 - 若校验**失败**(exit code 非 0 或输出含 `FAIL`),停止后续步骤,将错误信息反馈给用户。 43 - 若校验**通过**(`ALL PASS ✓`),继续 Step 2。 44 45 --- 46 47 ## 参数推断规则 48 49 | 参数 | 推断方式 | 50 |------|---------| 51 | `<cu_file>` | 用户提供的 .cu 文件路径 | 52 | `<ref_file>` | 用户提供;若未指定,在 `.cu` 文件同级目录下查找 `*_ref.py`(如 `matmul_ref.py`、`vector_add_ref.py`、`transpose_ref.py`) | 53 | 维度参数 (`--M`, `--N`, `--K` 等) | 从 `extern "C" void solve(...)` 签名推断参数名;未指定时用合理默认值(矩阵乘法 M=K=N=4096,向量加法 N=1000000) | 54 | `--repeat` | 默认 20 | 55 56 --- 57 58 ## Step 2: 汇总输出 59 60 ```markdown 61 ## Kernel 验证报告 62 63 ### 基本信息 64 - **Kernel 文件**: `<cu_file>` 65 - **参考实现**: `<ref_file>` 66 - **维度参数**: M=..., N=... (等) 67 - **GPU**: <GPU name> 68 69 ### 1. 正确性验证 70 - **结果**: ✅ ALL PASS / ❌ FAILED 71 - (如失败,附上错误信息) 72 73 ### 2. 性能压测 74 | 指标 | Kernel | Reference | 75 |------|--------|-----------| 76 | Average | X.XXXX ms | X.XXXX ms | 77 | Median | X.XXXX ms | X.XXXX ms | 78 | Min | X.XXXX ms | X.XXXX ms | 79 | Max | X.XXXX ms | X.XXXX ms | 80 | ~Bandwidth | XX.XX GB/s | XX.XX GB/s | 81 | Speedup | X.XXx vs ref | — | 82 ``` 83 84 --- 85 > Source: [gxinlong/cuda-optimization-skill](https://github.com/gxinlong/cuda-optimization-skill) — distributed by [TomeVault](https://tomevault.io). 86 <!-- tomevault:4.0:skill_md:2026-06-29 -->
tomevault-io/skills-registry/tree/main/gxinlong--cuda-optimization-skill--cuda-optimization-skill commit 72c87bcfd3
Frequently asked questions How do I install the Gxinlong Cuda Optimization Skill Cuda Optimization Skill skill? Run npx get-skill add tomevault-io/gxinlong-cuda-optimization-skill-cuda-optimization-skill in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Gxinlong Cuda Optimization Skill Cuda Optimization Skill skill do? Kernel Benchmark It is listed under AI & ML on SkillMD.
Is Gxinlong Cuda Optimization Skill Cuda Optimization Skill safe to use? This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Gxinlong Cuda Optimization Skill Cuda Optimization Skill? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Gxinlong Cuda Optimization Skill Cuda Optimization Skill free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Gxinlong Cuda Optimization Skill Cuda Optimization Skill? tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.