Skip to content

Commit f9f438a

Browse files
committed
fix: correct benchmark paths and improve code quality
- Fix benchmark paths in documentation (aos_vs_soa_bench) - Pin RapidCheck to v1.1.2 for reproducible builds - Use std::hardware_destructive_interference_size for cache line size - Fix AlignedArray move constructor with std::exchange - Add ARM platform compatibility for SIMD tests
1 parent 75ad94d commit f9f438a

11 files changed

Lines changed: 34 additions & 20 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ ctest --preset=release
8989
### Run Your First Benchmark
9090

9191
```bash
92-
./build/release/examples/02-memory-cache/bench/aos_soa_bench
92+
./build/release/examples/02-memory-cache/aos_vs_soa_bench
9393
```
9494

9595
See 2-20x speedup between AOS and SOA data layouts!

README.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ ctest --preset=release
8989
### 运行你的第一个基准测试
9090

9191
```bash
92-
./build/release/examples/02-memory-cache/bench/aos_soa_bench
92+
./build/release/examples/02-memory-cache/aos_vs_soa_bench
9393
```
9494

9595
见证 AOS 与 SOA 数据布局之间 2-20 倍的性能提升!

cmake/Dependencies.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ endfunction()
5757
#------------------------------------------------------------------------------
5858
function(hpc_fetch_rapidcheck)
5959
message(STATUS "Fetching RapidCheck...")
60-
60+
6161
FetchContent_Declare(
6262
rapidcheck
6363
GIT_REPOSITORY https://github.com/emil-e/rapidcheck.git
64-
GIT_TAG master
64+
GIT_TAG v1.1.2
6565
GIT_SHALLOW TRUE
6666
)
6767

docs/en/getting-started/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ cmake --build build/release
171171
ctest --preset=release
172172

173173
# Run a benchmark
174-
./build/release/examples/02-memory-cache/bench/aos_soa_bench
174+
./build/release/examples/02-memory-cache/aos_vs_soa_bench
175175
```
176176

177177
---

docs/en/getting-started/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ctest --preset=release
5454
### 5. Run a Benchmark
5555

5656
```bash
57-
./build/release/examples/02-memory-cache/bench/aos_soa_bench
57+
./build/release/examples/02-memory-cache/aos_vs_soa_bench
5858
```
5959

6060
---

docs/zh/getting-started/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ cmake --build build/release
171171
ctest --preset=release
172172

173173
# 运行基准测试
174-
./build/release/examples/02-memory-cache/bench/aos_soa_bench
174+
./build/release/examples/02-memory-cache/aos_vs_soa_bench
175175
```
176176

177177
---

docs/zh/getting-started/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ctest --preset=release
5454
### 5. 运行基准测试
5555

5656
```bash
57-
./build/release/examples/02-memory-cache/bench/aos_soa_bench
57+
./build/release/examples/02-memory-cache/aos_vs_soa_bench
5858
```
5959

6060
---

examples/02-memory-cache/include/memory_utils.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@ namespace hpc::memory {
1919
// Constants
2020
//------------------------------------------------------------------------------
2121

22-
/// Typical cache line size on modern x86 processors
23-
constexpr std::size_t CACHE_LINE_SIZE = 64;
22+
/// Cache line size - use std::hardware_destructive_interference_size when available
23+
#if defined(__cpp_lib_hardware_interference_size)
24+
constexpr std::size_t CACHE_LINE_SIZE = std::hardware_destructive_interference_size;
25+
#else
26+
/// Fallback: typical cache line size on x86/ARM (64 bytes)
27+
/// Note: Some ARM systems may have 128-byte cache lines
28+
constexpr std::size_t CACHE_LINE_SIZE = 64;
29+
#endif
2430

2531
/// Page size on most systems
2632
constexpr std::size_t PAGE_SIZE = 4096;

examples/02-memory-cache/src/alignment.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ class AlignedArray {
5555

5656
// Movable
5757
AlignedArray(AlignedArray&& other) noexcept
58-
: size_(other.size_), data_(other.data_)
59-
{
60-
other.size_ = 0;
61-
other.data_ = nullptr;
62-
}
58+
: size_(std::exchange(other.size_, 0))
59+
, data_(std::exchange(other.data_, nullptr))
60+
{}
6361

6462
T* data() { return data_; }
6563
const T* data() const { return data_; }

examples/05-concurrency/include/concurrency_utils.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <vector>
66
#include <functional>
77
#include <chrono>
8+
#include <new> // for std::hardware_destructive_interference_size
89

910
namespace hpc::concurrency {
1011

@@ -14,8 +15,13 @@ inline unsigned int hardware_concurrency() {
1415
return n > 0 ? n : 1;
1516
}
1617

17-
/// Cache line size for alignment
18-
constexpr size_t CACHE_LINE_SIZE = 64;
18+
/// Cache line size for alignment - use std::hardware_destructive_interference_size when available
19+
#if defined(__cpp_lib_hardware_interference_size)
20+
constexpr size_t CACHE_LINE_SIZE = std::hardware_destructive_interference_size;
21+
#else
22+
/// Fallback: typical cache line size on x86/ARM (64 bytes)
23+
constexpr size_t CACHE_LINE_SIZE = 64;
24+
#endif
1925

2026
/// Aligned atomic counter to avoid false sharing
2127
struct alignas(CACHE_LINE_SIZE) AlignedCounter {

0 commit comments

Comments
 (0)