Skip to content
nptmpl @ nguyenpanda.com v1.1.0

cpp/native_cuda

A high-performance modern template for local GPU development using CUDA and OpenMP. Optimized for single-node workloads with a professional build system (CMake/Makefile). Includes custom pinned memory allocators, type-safe environment variable loading, and ANSI-colorized logging.

Downloads today

0

Total downloads

1

Last updated

2026-05-26

v1.0.0 is latest

Versions

1

0 removed

Download v1.0.0

Clone with the CLI

nptmpl clone http://nptmpl.nguyenpanda.com/api/v1/templates/cpp/native_cuda

No @version resolves to the latest release (v1.0.0).

Maintainer nguyenpanda License MIT

Downloads over time

0 in the selected range

Files 14
README.md

Professional Native CUDA + OpenMP Template

A high-performance, modern template for local GPU development using CUDA and OpenMP. Optimized for single-node performance with a professional build system and developer-friendly utilities.

Features

  • Modern CMake: Target-based configuration with C++17, CUDA 11+, and OpenMP support.
  • Hybrid Computing: Utilize both GPU (CUDA) and CPU (OpenMP) parallelism on a single node.
  • Environment Configuration: Type-safe environment variable loading via .env files.
  • Optimized Memory: Custom PinnedAllocator for fast Host-to-Device (H2D) and Device-to-Host (D2H) transfers.
  • Cross-Platform Makefile: Simple, standardized commands for building, running, and formatting.
  • Utility Suite: ANSI colors, CUDA error checking macros, and environment parsing.

Directory Structure

  • src/: Source files (.cpp, .cu).
  • include/: Public headers.
  • utils/: Internal utility headers (allocators, colors, etc.).
  • examples/: Main application entry points and demonstrations.
  • lib/: Third-party libraries (submodules).

Getting Started

1. Configure

Create your local environment file:

cp .env.example .env

2. Build

make build

3. Run

make run

4. Format Code

Maintain consistent styling using clang-format:

make format

Environment Variables (.env)

Variable Description Default
HPC_LOCAL_N Workload size (e.g., number of elements) 1048576
CUDA_ARCH GPU Compute Capability (e.g., 75, 80) 75
APP_DEBUG Build with debug symbols (true/false) false
LOG_LEVEL Logging verbosity (info, debug, error) info
OMP_NUM_THREADS Number of OpenMP CPU threads System Default

Customization

  • Project Name: Edit project(CUDA_Project ...) in CMakeLists.txt.
  • Target Architecture: The build system uses the -real suffix (e.g., 75-real) to ensure compatibility and performance.
  • GPU Monitoring: Use make gpu-status to monitor usage via nvidia-smi.

Author

nguyenpanda
Email: [email protected]
Website: https://nguyenpanda.com

License

MIT License

Version history

Every release ever published, newest first.

v1.0.0 latest 1 downloads

Published 2026-05-26 08:53:06 by nguyenpanda

Related templates