Skip to content

Commit c867771

Browse files
committed
fix(build): parallel_stl_bench 编译定义加 TARGET 守卫
asan/tsan 等 preset 的 HPC_BUILD_BENCHMARKS=OFF 不创建 bench 目标, 无条件 target_compile_definitions(parallel_stl_bench) 导致配置失败。 该隐患自 TBB 接入后暴露(此前 TBB_FOUND=0 不会走到该分支)。 asan 全量 119 项测试恢复通过。 同批:文档站导航补齐 CPU 微架构/GEMM 案例/基准方法论专题, getting-started/首页/README 同步 08、09 模块
1 parent 78dca49 commit c867771

6 files changed

Lines changed: 21 additions & 5 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
- 并发与无锁基础、线程亲和与 NUMA
3232
- 分布式内存与 MPI(可选模块)
3333
- 文件 I/O 性能(read/pread/mmap 与写缓冲)
34-
- 基于 benchmark 与 profiling 的性能分析
34+
- CPU 微架构(分支预测、ILP、PMU 计数器)
35+
- 端到端优化案例(GEMM:tiling → SIMD → OpenMP)
36+
- 基于 benchmark 与 profiling 的性能分析与测量方法论
3537

3638
每个主题都尽量做到 **可阅读、可构建、可测量**。
3739

@@ -46,6 +48,8 @@
4648
| `examples/05-concurrency/` | 原子操作、无锁队列、OpenMP、线程亲和、NUMA |
4749
| `examples/06-distributed-mpi/` | MPI 点对点、集合通信、域分解(可选:`-DHPC_ENABLE_MPI=ON`) |
4850
| `examples/07-io-performance/` | read/pread/mmap 读路径对照、写缓冲开销(Linux) |
51+
| `examples/08-cpu-microarch/` | 分支预测、延迟链 vs ILP、perf_event_open PMU 计数器 |
52+
| `examples/09-matrix-multiply/` | GEMM 四阶段:naive → tiling → SIMD(FMA) → OpenMP |
4953
| `docs/` | VitePress 文档站,覆盖深度专题 / 实战指南 / API 参考 |
5054

5155
## 快速开始

‎docs/.vitepress/config.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ export default defineConfig({
6767
text: '深度专题',
6868
items: [
6969
{ text: '内存布局与缓存', link: '/zh/deep-dives/memory-layout' },
70+
{ text: 'CPU 微架构', link: '/zh/deep-dives/cpu-microarch' },
7071
{ text: 'SIMD 向量化', link: '/zh/deep-dives/simd-internals' },
72+
{ text: 'GEMM 案例研究', link: '/zh/deep-dives/gemm-case-study' },
7173
{ text: 'MPI 分布式并行', link: '/zh/deep-dives/mpi-distributed' },
7274
{ text: '无锁并发', link: '/zh/deep-dives/lock-free-queue' },
7375
{ text: '线程亲和与 NUMA', link: '/zh/deep-dives/thread-affinity-numa' },
@@ -81,6 +83,7 @@ export default defineConfig({
8183
text: '实战指南',
8284
items: [
8385
{ text: '性能分析实战', link: '/zh/guides/profiling' },
86+
{ text: '基准测试方法论', link: '/zh/guides/benchmark-methodology' },
8487
{ text: '优化决策手册', link: '/zh/guides/optimization-playbook' },
8588
],
8689
},

‎docs/zh/deep-dives/modern-cpp-perf.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ vec.resize(10); // capacity≥10, size=10 — 已值初始化,可下标访
229229
对象**同生共死**(解析/构建/渲染阶段、请求作用域临时数据),正确工具是
230230
arena(单调分配器):
231231

232-
- `hpc::mem::Arena`([`include/hpc/arena.hpp`](../../../include/hpc/arena.hpp)):
232+
- `hpc::mem::Arena`(`include/hpc/arena.hpp`):
233233
一次 malloc,分配 = 指针递增,释放 = 一次 `reset()`;
234234
- `std::pmr::monotonic_buffer_resource`(C++17 标准库):同样的分配形态,
235235
可直接插入标准容器(`std::pmr::polymorphic_allocator`)。

‎docs/zh/getting-started.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ examples/
7979
05-concurrency/ # 无锁并发、OpenMP、线程亲和与 NUMA
8080
06-distributed-mpi/ # 分布式内存与 MPI(可选,-DHPC_ENABLE_MPI=ON)
8181
07-io-performance/ # 文件 I/O:read/pread/mmap 与写缓冲(Linux)
82+
08-cpu-microarch/ # 分支预测、ILP/依赖链、PMU 计数器
83+
09-matrix-multiply/ # GEMM 四阶段优化案例(tiling/SIMD/OpenMP)
8284
include/hpc/ # 规范头文件库 (core, simd, memory, concurrency, io, modern-cpp 等)
8385
tests/
8486
unit/ # 单元测试 (Google Test)
@@ -91,6 +93,9 @@ scripts/ # 辅助脚本 (format, setup)
9193
## 下一步
9294

9395
- [内存布局与缓存](/zh/deep-dives/memory-layout) — AOS vs SOA、预取、对齐、false sharing
96+
- [CPU 微架构](/zh/deep-dives/cpu-microarch) — 分支预测、延迟 vs 吞吐、Top-Down 方法论
97+
- [GEMM 案例研究](/zh/deep-dives/gemm-case-study) — naive→tiling→SIMD→OpenMP 四步优化
98+
- [基准测试方法论](/zh/guides/benchmark-methodology) — 可信测量的纪律与陷阱
9499
- [SIMD 向量化](/zh/deep-dives/simd-internals) — 手动 intrinsics、NEON 与编译器自动向量化对比
95100
- [MPI 分布式并行](/zh/deep-dives/mpi-distributed) — 点对点、集合通信、域分解与 halo 交换
96101
- [无锁并发](/zh/deep-dives/lock-free-queue) — lock-free queue 实现与基准

‎docs/zh/index.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ hero:
1515

1616
features:
1717
- title: 深度专题
18-
details: 内存布局、SIMD、MPI、无锁并发、I/O、NUMA、GPU 路线,每个专题都从仓库代码出发。
18+
details: 微架构、内存布局、SIMD、GEMM、MPI、无锁并发、I/O、NUMA、GPU 路线,全部从仓库代码出发。
1919
- title: 可运行示例
20-
details: 7 个模块、Google Benchmark 与 MPI 通信基准,克隆即可验证。
20+
details: 9 个模块、Google Benchmark 与 MPI 通信基准,克隆即可验证。
2121
- title: 性能分析实战
2222
details: perf、FlameGraph、Valgrind、VTune 的真实工作流。
2323
- title: 预设驱动构建

‎examples/03-modern-cpp/CMakeLists.txt‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ if(TBB_FOUND)
5757
LIBRARIES TBB::tbb
5858
)
5959
target_compile_definitions(parallel_stl PRIVATE HPC_HAS_TBB)
60-
target_compile_definitions(parallel_stl_bench PRIVATE HPC_HAS_TBB)
60+
# The bench target only exists when HPC_BUILD_BENCHMARKS is ON (the
61+
# sanitizer presets disable it — sanitizers distort timing).
62+
if(TARGET parallel_stl_bench)
63+
target_compile_definitions(parallel_stl_bench PRIVATE HPC_HAS_TBB)
64+
endif()
6165
else()
6266
hpc_add_example(
6367
NAME parallel_stl

0 commit comments

Comments
 (0)