GPGPU-Sim / Accel-Sim / gem5-GPU Compute Modeling 研究笔记
用途:G5 仿真引擎设计参考,聚焦 SM/CU 层级的 cycle-approximate 建模方法论。 不含 memory hierarchy / systolic array / 解析 roofline 内容。
1. GPGPU-Sim:建模粒度与 SM 建模方法
粒度:warp 指令级 (Warp-Instruction-Level)
GPGPU-Sim 是指令级 cycle-level 仿真器,以 warp(32 线程)为调度单元,每个 warp 每周期最多 issue 一条指令。 核心流水线为 6-stage 前端(Fetch → Decode → I-Buffer → Schedule → Issue → Execute),后端按执行类型(ALU/SFU/MEM/TC)并行。
关键建模细节:
- Superpipelining 抽象:硬件 1.3 GHz shader clock 在仿真中以 325 MHz(1/4 频率)32-wide 流水线等效建模。每个 cycle 仿真处理整个 warp 的同一条指令,省去 SIMD 内 32 条线程的逐线程微操作。
- I-Buffer:每个 warp 持有 2 条已 fetch/decode 的指令条目,含 valid bit + ready bit。ready bit 由 scoreboard 和资源检查在 Schedule/Issue 阶段置位。
- Warp Scheduler:支持多策略(GTO — Greedy Then Oldest;CCWS;PDOM SIMT Stack;DWF — Dynamic Warp Formation)。GTO 默认策略:选最老的未阻塞且无数据依赖的 warp issue 指令。SIMT 栈处理分支 divergence/reconvergence。
- Occupancy 建模:受两个硬件上限约束——寄存器数量(
-gpgpu_shader_registers,默认 8192/SM)和 CTA 数(-gpgpu_shader_cta,默认 8 CTA/SM)。仿真器按 cycle 统计每 SM 活跃 warp 数分布(W1–W32)。 - IPC 计算:
gpu_ipc = gpu_sim_insn / gpu_sim_cycle,对比 GeForce 8600GT 硬件的 correlation coefficient = 0.899(ISPASS 2009)。
2. Accel-Sim:与 GPGPU-Sim 的差异
Accel-Sim(ISCA 2020)= 新前端 + 大幅更新的 GPGPU-Sim 4.0 后端,并非独立仿真器。
核心差异:
| 维度 | GPGPU-Sim 3.x | Accel-Sim(GPGPU-Sim 4.0) |
|---|---|---|
| 指令集 | PTX 虚拟 ISA(执行驱动) | SASS 机器 ISA(trace 驱动为主) |
| 前端模式 | Execution-driven(动态计算地址 / active mask) | Trace-driven(预嵌 address + active mask)或兼容 execution-driven |
| 速度 | baseline | 12.5k warp-instr/s,快 4.3× |
| 精度(Volta) | 基准 | 误差降低 79%;内存带宽利用率 82% vs 硬件 85%(GPGPU-Sim 3.x 为 62%) |
| 目标硬件 | Fermi/Kepler 时代 | Volta/Turing 等现代架构 |
SASS trace-driven 的精度来源:使用编译器实际生成的机器指令(含寄存器分配、指令合并等优化),避免了 PTX→硬件的语义 gap;active mask 和内存地址提前固化在 trace 里,减少仿真分歧。
SM 内的调度/occupancy 建模框架与 GPGPU-Sim 基本一致(warp 指令级粒度),主要改进在后端 memory subsystem 和新硬件特性(TensorCore、HBM dual-bus)。
3. gem5 GCN3 GPU 模型
gem5 的 AMD GCN3 模型(AMD gem5 APU Simulator)是 cycle-level、instruction-level 仿真,建模粒度与 GPGPU-Sim 类似,但面向 AMD OpenCL wavefront(64 线程)。
流水线:4 stage — Fetch → Scoreboard Check → Schedule → Execute。
- Wavefront(= AMD warp)= 64 线程,64-wide SIMD 单周期 issue。
- Schedule 阶段对每个执行单元类型(Vector/Scalar/Branch/Memory)分别做 wavefront arbitration。
- Occupancy:动态策略最多 40 wavefront/CU,受寄存器可用量约束。
精度状况(GAP 论文,YARCH 2024):
- 计算核心(CU microarch)误差在 5–10% 以内("relatively accurate")。
- 内存子系统误差严重:latency 平均偏差 272%(最大 645%),bandwidth 平均偏差 70%(最大 693%)。
- 经 GAP 工具修复后:latency 误差降至约 25%,bandwidth 误差降至约 16%。
结论:gem5 GCN3 是 cycle-level 仿真(不是 cycle-approximate 解析模型),精度的主要问题在内存子系统而非计算核心建模。
4. 三者对比总结
| 属性 | GPGPU-Sim | Accel-Sim | gem5 GCN3 |
|---|---|---|---|
| 架构对象 | NVIDIA CUDA GPU | NVIDIA CUDA GPU(Volta+) | AMD GCN3/Vega GPU |
| 建模粒度 | Warp 指令级 cycle-level | Warp 指令级 cycle-level(SASS trace) | Wavefront 指令级 cycle-level |
| 调度单元 | 32-thread warp | 32-thread warp | 64-thread wavefront |
| 前端驱动 | Execution-driven (PTX) | Trace-driven (SASS) + exec-driven | Execution-driven (GCN3 ISA) |
| SM/CU occupancy | 寄存器 + CTA 上限,cycle 统计 | 同 GPGPU-Sim 框架 | 寄存器上限,最多 40 wavefront/CU |
| 精度声明 | corr 0.899 (G8600GT, 2009) | 误差 -79% vs GPGPU-Sim 3.x (Volta) | 计算 5-10% 误差 (CU core) |
| 速度 | 慢(execution-driven) | 4.3× 快于 GPGPU-Sim 3.x | 慢(full execution-driven) |
5. 关键文献
- Bakhoda et al., "Analyzing CUDA Workloads Using a Detailed GPU Simulator," ISPASS 2009. DOI/URL: https://ieeexplore.ieee.org/document/4919648
- Khairy et al., "Accel-Sim: An Extensible Simulation Framework for Validated GPU Modeling," ISCA 2020. PDF: https://mkhairy.github.io/Docs/Accel-Sim.pdf ACM DL: https://dl.acm.org/doi/10.1109/ISCA45697.2020.00047
- Vramadas et al., "Further Closing the GAP: Improving the Accuracy of gem5's GPU Models," YARCH 2024 (Workshop). NSF Pages: https://par.nsf.gov/biblio/10542852-further-closing-gap-improving-accuracy-gem5-gpu-models
- gem5 GCN3 GPU Model 官方文档. URL: https://gem5.googlesource.com/public/gem5-website/+/998b03de242de1d9296c46108863d3af20ea2b7b/_pages/documentation/general_docs/gpu_models/gcn3.md
- GPGPU-Sim Manual v1.0 (UWisc mirror). URL: https://pages.cs.wisc.edu/~chen-han/doc/GPGPU-Sim_Manual.html