Contributing to C++ High Performance Guide
Thank you for your interest in contributing! This document provides guidelines for contributing to this project.
Getting Started
- Fork the repository
- Clone your fork:
git clone https://github.com/<your-username>/cpp-high-performance-guide.git - Create a feature branch:
git checkout -b feature/your-feature-name
Build & Test
# Debug build with tests
cmake --preset=debug
cmake --build build/debug
ctest --preset=debug
# Release build with benchmarks
cmake --preset=release
cmake --build build/release
ctest --preset=release
Code Style
- Follow the
.clang-formatconfiguration in the project root - Format your code before committing:
find examples tests benchmarks -name "*.cpp" -o -name "*.hpp" | xargs clang-format -i - Use
#pragma oncefor header guards - Place code in the
hpc::namespace hierarchy
Adding a New Example Module
- Create a new directory under
examples/following the naming convention:XX-topic-name/ - Use the standard structure:
examples/XX-topic-name/ ├── src/ # Source files with demo main() ├── bench/ # Google Benchmark files ├── include/ # Header-only utilities (optional) ├── CMakeLists.txt # Use hpc_add_example() from ExampleTemplate.cmake └── README.md # Module documentation - Register the subdirectory in
examples/CMakeLists.txt - Add corresponding tests under
tests/
Testing Requirements
Before submitting a pull request, ensure:
All tests pass:
cmake --preset=debug && cmake --build build/debug && ctest --preset=debugNo AddressSanitizer errors:
cmake --preset=asan && cmake --build build/asan && ctest --preset=asanNo ThreadSanitizer errors (for concurrency code):
cmake --preset=tsan && cmake --build build/tsan && ctest --preset=tsanNo UndefinedBehaviorSanitizer errors:
cmake --preset=ubsan && cmake --build build/ubsan && ctest --preset=ubsan
Commit Messages
Use clear, descriptive commit messages:
feat: add matrix multiplication SIMD examplefix: resolve false sharing in concurrent counterdocs: update learning path with new modulebench: add parameterized benchmark for prefetch distancetest: add property tests for lock-free queue
Pull Request Process
- Ensure your branch is up to date with
main - All CI checks must pass
- Include a clear description of what your PR adds or fixes
- Reference any related issues
License
By contributing, you agree that your contributions will be licensed under the MIT License.