This repository is under active development. The canonical header-only library lives in include/hpc/ (consumed via the hpc_headers INTERFACE target); example and demo code lives in examples/ and depends only on the canonical library, never the reverse. Prefer normalization, defect fixing, and removal of stale or low-signal surfaces over accumulating redundant surfaces.
- Target: C++20 (required,
CMAKE_CXX_STANDARD_REQUIRED ON) - Style: enforced via
.clang-format(Google style, 100 chars) - Memory safety: prefer RAII, smart pointers, avoid raw
new/delete - Performance: always measure with benchmarks before claiming improvement
- Concurrency: use
std::atomicwith explicit memory ordering - Header-only design: all library code lives in
include/hpc/(consumed via thehpc_headersINTERFACE target). Platform-specific code is hidden behind preprocessor conditionals within headers.
cpp-high-performance-guide/
├── CMakeLists.txt
├── CMakePresets.json
├── cmake/
├── examples/
├── tests/
├── benchmarks/
├── tools/
├── scripts/
├── docs/ # VitePress site (Chinese only)
├── .githooks/ # Project-managed Git hooks
└── .github/
# Build and test
cmake --preset=debug && cmake --build build/debug && ctest --preset=debug
cmake --preset=release && cmake --build build/release && ctest --preset=release
# Sanitizers
cmake --preset=asan && cmake --build build/asan && ctest --preset=asan
cmake --preset=tsan && cmake --build build/tsan && ctest --preset=tsan
cmake --preset=ubsan && cmake --build build/ubsan && ctest --preset=ubsan
# Benchmarks
cmake --preset=release && cmake --build build/release
./build/release/examples/<module-dir>/<benchmark_name> --benchmark_time_unit=us
# 例: ./build/release/examples/02-memory-cache/aos_vs_soa_bench --benchmark_time_unit=us
# Utilities
./scripts/format.sh
./scripts/setup-hooks.sh- Prefer deleting or archiving stale content instead of preserving redundant surfaces.
- Keep README focused on repository entry and onboarding; use the docs site for the richer narrative.
- Treat GitHub Pages as a project landing page, not a thin README mirror.
- Documentation is Chinese only. Do not reintroduce English documentation surfaces.
- Use CMake presets as the default build and test entry points.
- Keep workflows preset-driven, low-noise, and meaningful.
- Avoid over-engineering with extra plugins, MCP servers, or automation layers unless they clearly reduce maintenance cost.
- CLAUDE.md: Claude Code specific guidance (this file).
- LSP: prefer
clangdbacked bycompile_commands.json. The.clangdconfig at the repo root pointsCompilationDatabasetobuild/debug. - Review model: use
/reviewbefore merge or after major cleanup phases.
The .vscode/ directory is gitignored. Use .clangd, .editorconfig, and CMakePresets.json for machine-readable project conventions.
- non-blocking CI steps that hide real failures
- per-example shim headers that only re-export a canonical
include/hpc/header - wrapper scripts that duplicate
cmake --presetcommands - English documentation surfaces or bilingual parity machinery