Imported from phaus/memory-vibes (
AGENTS.md). Install upstream withnpx skills add phaus/memory-vibes. Copyright stays with the author.
Project Agents & Development Guidelines
This repository provides a small set of agents (convention‑based scripts) that automate common development workflows. In addition, the file defines the coding style and tooling expectations for contributors and for any automated coding agents that operate on this codebase.
Table of Contents
- Agents Overview
- Build Agent
- Build Troubleshooting
- Lint / Formatting Agent
- Test Agent
- Run Agent
- CI/CD Monitoring
- Code Style Guidelines
- - General C++ Conventions
- - Naming Conventions
- - Headers & Includes
- - Formatting Rules
- - Error Handling & Exceptions
- - Types & Const‑correctness
- - Testing Practices
- Cursor / Copilot Rules
- Agent Invocation Cheat‑Sheet
Agents Overview
| Agent | Purpose | Typical Command |
|---|---|---|
| Build | Configure and compile the project (Release by default). | ./scripts/build.sh or the inline snippet below. |
| Lint | Enforce formatting with clang‑format and static analysis with clang‑tidy. |
./scripts/lint.sh |
| Test | Run the full test suite with CTest, or a single test executable. | ctest --output-on-failure / ./build/test_alignment |
| Run | Execute the benchmark binary with optional arguments. | ./mem_band [options] |
| DocUpdate | Update README / spec files and commit. | ./scripts/doc_update.sh |
All agents are thin wrappers around standard commands; they exist to give agents a predictable entry‑point.
Build Agent
# Build the project in Release mode (default)
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
*The resulting executable is ./mem_band (Linux/macOS) or Release\\mem_band.exe (Windows).
Optional flags:
-DENABLE_SIMD=ON– enable AVX2 SIMD kernels (requires compatible compiler).-DCMAKE_BUILD_TYPE=Debug– for local debugging and symbol generation.
Build configurations:
- Default (core only): No external dependencies. Build works out-of-the-box.
- With SIMD:
-DENABLE_SIMD=ON. Enables AVX2/SSE2/Altivec kernels. - With CUDA:
-DENABLE_CUDA=ON. Buildsmem_band_cudaexecutable (requires CUDA toolkit). - With ROCm:
-DENABLE_ROCM=ON. Buildsmem_band_rocmexecutable (requires ROCm toolkit). - With JSON:
-DENABLE_JSON_OUTPUT=ON. Enables JSON output format (requires nlohmann/json via CMake). - With SQLite:
-DENABLE_SQLITE_OUTPUT=ON. Enables SQLite persistence (requires SQLite3 via CMake).
One‑liner shortcut (available as ./scripts/build.sh):
#!/usr/bin/env bash
set -e
mkdir -p build && cd build
cmake .. "${@:- -DCMAKE_BUILD_TYPE=Release}" && cmake --build .
Build Troubleshooting
Common Build Issues
-
Missing CMakeLists.txt
- Error:
CMake Error: The source directory does not exist - Solution: Ensure you're in the project root directory with
CMakeLists.txt
- Error:
-
Compiler not found
- Error:
CMake Error: Cannot find CMAKE_C_COMPILER - Solution: Install a C++17-compatible compiler (gcc 7+, clang 5+, MSVC 2017+)
- Error:
-
Missing dependencies
- Error:
Could NOT find CUDA,Could NOT find ROCm, etc. - Solution: Install the required toolkit or disable the feature with
-DENABLE_*_FEATURE=OFF
- Error:
-
Permission denied on Linux
- Error:
/sys/bus/pci/devicesaccess denied - Solution: Add user to
plugdevgroup:sudo usermod -a -G plugdev $USER
- Error:
-
Windows HMODULE cast error
- Error:
C2664: 'FreeLibrary': cannot convert argument 1 from 'void *' to 'HMODULE' - Solution: Use
static_cast<HMODULE>(handle)when callingFreeLibrary()on Windows
- Error:
-
C++17 support required
- Error:
error: parallel algorithms require -std=c++17 or later - Solution: Ensure compiler supports C++17 or use
set(CMAKE_CXX_STANDARD 17)in CMakeLists.txt
- Error:
Platform-Specific Notes
Linux:
- May require additional packages:
libdl-devfor dynamic loading - For PCIe device detection: read access to
/sys/bus/pci/devices
macOS:
- Use Xcode 11+ for C++17 support
- CoreFoundation framework required for platform detection
Windows:
- Use Visual Studio 2017+ or VS Build Tools 2017+
- WMI access required for platform detection (standard on modern Windows)
Lint / Formatting Agent
The project follows the LLVM/Google C++ style with a 2‑space indent.
# Run clang‑format on all source files (auto‑fix)
find src tests -name "*.cpp" -o -name "*.hpp" | xargs clang-format -i -style=file
# Run clang‑tidy (no‑fix) to surface warnings
cmake -B build -S . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
clang-tidy -p build $(git ls-files "*.cpp" "*.hpp")
The repository contains a .clang-format file (generated by clang-format -style=Google). Ensure it is present; otherwise the default Google style is used.
Test Agent
Full Test Suite
# Run all CTest tests with verbose output
ctest --output-on-failure
Single Test Executable
You can execute any test binary directly, which is useful for quick iteration:
./build/test_alignment # alignment sanity test
./build/test_benchmark # benchmark unit test
./build/test_double # double‑precision kernel test
Adding New Tests
- Create a
tests/<name>.cppthat includes<gtest/gtest.h>(GoogleTest is already a dependency). - Add the source to
CMakeLists.txtwithadd_executable(test_<name> tests/<name>.cpp). - Register the test using
add_test(NAME <Name> COMMAND test_<name>). - Re‑run the Build Agent to generate the new binary.
Run Agent
# Default run (copies 256 MiB, 20 iterations, float)
./mem_band
# Custom example – 1 GiB, 30 iterations, double precision, SIMD enabled
./mem_band --size 1024 --iters 30 --type double -S
All options are listed by ./mem_band --help.
CI/CD Monitoring
Checking Build Status
The CI/CD pipeline runs on every push to maintain code quality across all platforms (Linux, macOS, Windows).
View current build status:
# Visit GitHub Actions for this repository
open https://github.com/phaus/memory-vibes/actions
Or use GitHub CLI:
gh run list --limit 10
Understanding CI/CD Results
The CI/CD workflow runs:
- Linux: gcc and clang with various build configurations
- macOS: Latest Xcode toolchain
- Windows: Visual Studio 2022 (MSVC)
Status Indicators:
- ✓ Green: All platform builds and tests passed
- ⚠ Yellow: Warning-only builds (may indicate deprecation warnings)
- ✗ Red: Build or test failure requiring immediate attention
Troubleshooting CI Failures
- Click on the failed workflow run in the GitHub Actions UI
- Expand the failed job (Linux/macOS/Windows)
- Inspect the error in the build logs
- Local reproduction: Build with the same compiler flags locally
Common issues:
- Header include paths: Verify paths in
CMakeLists.txtand#includedirectives - Platform-specific code: Use
#ifdef _WIN32,#ifdef __APPLE__,#ifdef __linux__ - Compiler-specific warnings: Add
-Wno-<warning>in CMakeLists.txt for known issues
Expected CI Behavior After Changes
- New feature added: All tests pass, new tests added
- Bug fix: Existing tests pass, regression test added
- Refactoring: No functional changes, all tests pass
- Platform support: All three platforms (Linux/macOS/Windows) build and test
CI Build Matrix
The CI pipeline tests multiple configurations across three platforms:
| Platform | Compiler | Config | Notes |
|---|---|---|---|
| Linux (ubuntu-latest) | gcc, clang | Release | Default build with all optional features disabled |
| Linux | gcc | Release + SIMD | Tests AVX2/SSE2/Altivec support |
| Linux | gcc | Release + CUDA | Tests CUDA GPU benchmarking (if available) |
| Linux | gcc | Release + ROCm | Tests ROCm GPU benchmarking (if available) |
| macOS (macos-latest) | Apple Clang | Release | Core build with macOS-specific features |
| Windows (windows-latest) | MSVC 2022 | Release | Tests Windows platform detection and WMI |
Dependency configurations tested:
- Default build: No external dependencies (core functionality only)
- SIMD build: AVX2/SSE2/Altivec enabled via
-DENABLE_SIMD=ON - CUDA build: NVIDIA GPU benchmarking via
-DENABLE_CUDA=ON - ROCm build: AMD GPU benchmarking via
-DENABLE_ROCM=ON - JSON build: JSON output format via
-DENABLE_JSON_OUTPUT=ON - SQLite build: SQLite persistence via
-DENABLE_SQLITE_OUTPUT=ON
Linux platform builds also test legacy configurations:
- PowerPC32/64: Toolchain-based cross-compilation
- i386: 32-bit x86 support
Code Style Guidelines
General C++ Conventions
- Use C++17 language features exclusively; avoid compiler‑specific extensions.
- Prefer standard library over hand‑rolled utilities (e.g.,
std::vector,std::array). - Keep header files self‑contained: include everything they need, guard with
#ifndef/#define. - Each translation unit must compile with
-Wall -Wextra -Werrorin CI.
Naming Conventions
| Entity | Convention |
|---|---|
| Namespaces | lowercase (e.g., mem_band) |
| Classes / Structs | PascalCase (e.g., AlignedAllocator) |
| Functions / Free functions | snake_case (e.g., copy_kernel) |
| Variables | snake_case (e.g., total_bytes) |
| Constants / Macros | UPPER_SNAKE_CASE (e.g., CACHE_LINE_SIZE) |
| Template parameters | typename T – always a single capital letter when appropriate. |
Headers & Includes
- Order: 1) C system headers, 2) C++ standard library, 3) third‑party, 4) project headers.
- Separate each group with a blank line.
- Prefer include‑what‑you‑use; never rely on transitive includes.
- Use
#include "<relative_path>"for project headers.
Formatting Rules
- Indentation: 2 spaces, no tabs.
- Maximum line length: 100 characters (except long literals or URLs).
- Braces follow K&R style:
if (cond) { // ... } else { // ... } - Trailing whitespace is prohibited.
- Files end with a single newline.
- Use
clang-formatwith the repository‑provided.clang-formatfile.
Error Handling & Exceptions
- The codebase does not use exceptions; all error paths return
nullptrorboolwhere appropriate. - For fatal conditions (e.g., allocation failure) return
nullptrand let the caller decide. - Use
assertfor invariant violations that should never happen in production. - Prefer RAII for resource management (
std::unique_ptr, custom deleters).
Types & Const‑correctness
- Pass read‑only parameters by
const T&orconst T*; mutable buffers use non‑const pointers. - Use fixed‑width integer types (
std::uint32_t,std::size_t) for sizes. - Avoid raw
intfor sizes; preferstd::size_t. - Mark functions that do not modify members as
const. - Use
constexprfor compile‑time constants.
Testing Practices
- Keep tests small, deterministic, and fast (< 0.1 s each).
- Use GoogleTest assertions (
EXPECT_EQ,ASSERT_TRUE). - Test edge cases: zero size, non‑multiple‑of‑alignment, allocation failure simulation (mock
aligned_alloc). - Verify SIMD code paths via compile‑time
ENABLE_SIMDflag.
Cursor / Copilot Rules
The repository does not contain a .cursor/ directory or a .github/copilot-instructions.md file, so no special instruction sets are enforced. Agents should follow the general style described above.
Agent Invocation Cheat‑Sheet
| Action | Command |
|---|---|
| Build (Release) | ./scripts/build.sh |
| Build (Debug) | ./scripts/build.sh -DCMAKE_BUILD_TYPE=Debug |
| Build (SIMD) | ./scripts/build.sh -DENABLE_SIMD=ON |
| Build (CUDA) | ./scripts/build.sh -DENABLE_CUDA=ON |
| Build (ROCm) | ./scripts/build.sh -DENABLE_ROCM=ON |
| Build (JSON) | ./scripts/build.sh -DENABLE_JSON_OUTPUT=ON |
| Build (SQLite) | ./scripts/build.sh -DENABLE_SQLITE_OUTPUT=ON |
| Lint / Format | ./scripts/lint.sh |
| Run full tests | ctest --output-on-failure |
| Run a single test | ./build/test_<name> |
| Execute benchmark | ./mem_band --size 512 --iters 10 |
| Show help | ./mem_band --help |
| Check CI status | gh run list --limit 10 |
Add these scripts to package.json or a Makefile if you prefer make‑based shortcuts.
Generated by the OpenCode assistant.