Skip to content
nptmpl @ nguyenpanda.com v1.1.0

cpp/mpi_cuda

A professional high-performance computing (HPC) template for distributed GPU workloads. Integrates inter-node parallelism with MPI, intra-node CPU parallelism with OpenMP, and GPU acceleration with CUDA. Features a robust .env-based configuration, optimized pinned memory allocators, and built-in cluster monitoring tools.

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/mpi_cuda

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

Maintainer nguyenpanda License MIT

Downloads over time

0 in the selected range

Files 16
README.md

MPI + CUDA + OpenMP Professional Template

A high-performance computing template designed for distributed GPU workloads using MPI (Message Passing Interface), CUDA, and OpenMP. This template provides a robust build system, optimized memory management, and easy multi-node configuration.

Features

  • Modern CMake: Target-based configuration with C++17, CUDA 11+, and OpenMP support.
  • Hybrid Parallelism: Seamless integration of MPI (inter-node), OpenMP (intra-node CPU), and CUDA (intra-node GPU).
  • Environment Configuration: Robust workload and build management via .env files.
  • Optimized Memory: Built-in PinnedAllocator for high-performance H2D/D2H transfers.
  • Monitoring Tools: monitor.sh for multi-node GPU monitoring using tmux and ssh.
  • Utility Suite: Colorized logging, type-safe environment parsing, and CUDA error handling.

Directory Structure

  • src/: Core implementation logic (.cpp, .cu).
  • include/: Public headers.
  • utils/: Reusable HPC utilities (allocators, macros, etc.).
  • examples/: Main application entry points.
  • lib/: Third-party submodules (e.g., Google Benchmark).
  • build/: Generated build artifacts.

Quick Start

1. Configure

Create your local environment file from the example:

cp .env.example .env

2. Build

make build

3. Run

make run

Environment Variables (.env)

The template automatically loads variables from .env. These affect both compilation and runtime.

Variable Description Default
HPC_LOCAL_N Workload size (elements per node) 1000000
CUDA_ARCH GPU Compute Capability (e.g., 75, 80) 75
APP_DEBUG Enable debug symbols and disable optimizations false
LOG_LEVEL Application log level (info, debug, error) info
OMP_NUM_THREADS Number of OpenMP threads per process System Default
NP Number of MPI processes 4
MPI_IFACE Network interface for MPI (e.g., eno1, eth0) eno1

Advanced Usage

GPU Architecture

The Makefile and CMakeLists.txt use the -real suffix (e.g., 75-real) to prevent generating PTX code, which avoids "unsupported toolchain" errors on systems with older drivers while maintaining maximum performance.

Multi-node Monitoring

Use the included monitor.sh to watch GPU status across your cluster:

./monitor.sh "watch -n 0.1 nvidia-smi"

Note: Update the HOSTS array in monitor.sh with your node hostnames.

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:15 by nguyenpanda

Related templates