Skip to content

Commit 31756a3

Browse files
committed
fix: 修正 benchmark 类型分叉、文档路径错误,移除死代码
- aos_soa_bench.cpp 改用 particle_types.hpp 规范类型,消除与 example 的重复定义 - CLAUDE.md benchmark 路径修正为实际构建产物路径 - 删除从未在 CI 执行的 Python 集成测试(tests/integration/) - getting-started.md 同步移除 integration/ 目录引用
1 parent 548ec4a commit 31756a3

6 files changed

Lines changed: 8 additions & 447 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ cmake --preset=ubsan && cmake --build build/ubsan && ctest --preset=ubsan
4444

4545
# Benchmarks
4646
cmake --preset=release && cmake --build build/release
47-
./build/release/benchmarks/<benchmark_name> --benchmark_time_unit=us
47+
./build/release/examples/<module-dir>/<benchmark_name> --benchmark_time_unit=us
48+
# 例: ./build/release/examples/02-memory-cache/aos_vs_soa_bench --benchmark_time_unit=us
4849

4950
# Utilities
5051
./scripts/format.sh

docs/zh/getting-started.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ include/hpc/ # 公共头文件 (core.hpp, simd.hpp)
8181
tests/
8282
unit/ # 单元测试 (Google Test)
8383
property/ # 属性测试
84-
integration/ # 集成测试 (Python)
8584
benchmarks/common/ # 基准测试公共工具
8685
docs/ # VitePress 文档站
8786
scripts/ # 辅助脚本 (format, setup)

examples/02-memory-cache/bench/aos_soa_bench.cpp

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,12 @@
1111
#include <random>
1212
#include <vector>
1313

14-
namespace {
15-
16-
//------------------------------------------------------------------------------
17-
// AOS Implementation
18-
//------------------------------------------------------------------------------
19-
20-
struct ParticleAOS {
21-
float x, y, z;
22-
float vx, vy, vz;
23-
};
24-
25-
void update_aos(std::vector<ParticleAOS>& particles, float dt) {
26-
for (auto& p : particles) {
27-
p.x += p.vx * dt;
28-
p.y += p.vy * dt;
29-
p.z += p.vz * dt;
30-
}
31-
}
32-
33-
//------------------------------------------------------------------------------
34-
// SOA Implementation
35-
//------------------------------------------------------------------------------
14+
#include "particle_types.hpp"
3615

37-
struct ParticleSOA {
38-
std::vector<float> x, y, z;
39-
std::vector<float> vx, vy, vz;
40-
41-
void resize(size_t n) {
42-
x.resize(n);
43-
y.resize(n);
44-
z.resize(n);
45-
vx.resize(n);
46-
vy.resize(n);
47-
vz.resize(n);
48-
}
16+
namespace {
4917

50-
size_t size() const { return x.size(); }
51-
};
52-
53-
void update_soa(ParticleSOA& particles, float dt) {
54-
const size_t n = particles.size();
55-
for (size_t i = 0; i < n; ++i)
56-
particles.x[i] += particles.vx[i] * dt;
57-
for (size_t i = 0; i < n; ++i)
58-
particles.y[i] += particles.vy[i] * dt;
59-
for (size_t i = 0; i < n; ++i)
60-
particles.z[i] += particles.vz[i] * dt;
61-
}
18+
using hpc::memory::ParticleAOS;
19+
using hpc::memory::ParticleSOA;
6220

6321
//------------------------------------------------------------------------------
6422
// Initialization
@@ -102,7 +60,7 @@ static void BM_AOS_Update(benchmark::State& state) {
10260
init_aos(particles, n);
10361

10462
for (auto _ : state) {
105-
update_aos(particles, 0.01f);
63+
hpc::memory::update_particles_aos(particles, 0.01f);
10664
benchmark::DoNotOptimize(particles.data());
10765
benchmark::ClobberMemory();
10866
}
@@ -117,7 +75,7 @@ static void BM_SOA_Update(benchmark::State& state) {
11775
init_soa(particles, n);
11876

11977
for (auto _ : state) {
120-
update_soa(particles, 0.01f);
78+
hpc::memory::update_particles_soa(particles, 0.01f);
12179
benchmark::DoNotOptimize(particles.x.data());
12280
benchmark::ClobberMemory();
12381
}

tests/integration/build_configuration_test.py

Lines changed: 0 additions & 107 deletions
This file was deleted.

0 commit comments

Comments
 (0)