A small, CMake-driven collection of CUDA examples. Each .cu file under src/ builds into its own executable, preserving the src/ folder structure under build-*/bin/.
src/001-basic: launch basics (streams/events, graph launch, dynamic parallelism, etc.)src/002-device: querying device propertiessrc/003-memory: allocation and host↔device copies, shared memorysrc/004-vector: vector add/copy/dot/sumsrc/005-matrix: matrix multiply/transpose/mat-vec, WMMA examplesrc/006-ptx: PTX-related examples
Build outputs land here (example):
build-release/bin/001-basic/hello-worldbuild-debug/bin/004-vector/vector-add
- NVIDIA GPU + compatible NVIDIA driver
- CUDA Toolkit (provides
nvcc) - CMake >= 3.25
- Ninja
- A C++20-capable compiler toolchain
- VS Code + “Dev Containers” extension
- Docker
- NVIDIA Container Toolkit (so the container can access your GPU)
This repo expects the dependency folder to exist at cpp-bench-utils/ (repo root).
git clone https://github.com/KindRoach/cpp-bench-utils.git- Open this folder in VS Code.
- Run: Dev Containers: Reopen in Container.
- Ensure GPU access works inside the container (you should be able to run
nvidia-smi).
- Install CUDA Toolkit, CMake (>= 3.25), Ninja, and a C++ toolchain.
- Clone this repo.
This repo uses CMake configure presets from CMakePresets.json:
cmake --preset releaseOther useful presets:
cmake --preset debugcmake --preset relwithdebinfo
cmake --build build-releaseFor debug builds:
cmake --build build-debugExecutables are written under build-*/bin/<category>/.
Examples:
./build-release/bin/001-basic/hello-world
./build-release/bin/004-vector/vector-addInstall the “CMake Tools” extension, then:
- Select a configure preset (e.g.
debugorrelwithdebinfo). - Configure + build.
- Set the target executable as the debug program (from
build-*/bin/...).
If you use relwithdebinfo, you get a good balance of debug symbols and runtime speed.