CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
NCCL Communicator Examples
Overview
This directory contains minimal examples that demonstrate NCCL communicator lifecycle management (creation, query, and destruction) using different initialization patterns.
Examples
01_multiple_devices_single_process
Multiple Devices Single Process
- Pattern: Single process manages all GPUs
- API:
ncclCommInitAll(no external coordination) - Use case: Simple single-node applications
- Key features:
- Simplest initialization method
- No MPI or threading required
- Automatic rank assignment (0 to n-1)
- Cannot span multiple nodes
Run command:
./01_multiple_devices_single_process/multiple_devices_single_process
02_one_device_per_pthread
One Device per Thread with pthreads
- Pattern: One thread per GPU within single process
- API:
ncclCommInitRankwith pthread coordination - Use case: Single-node multi-GPU, thread-based parallelism
- Key features:
- pthread barriers for synchronization
- Shared memory for unique ID
- Lower overhead than multi-process
- Cannot span multiple nodes
Run command:
[NTHREADS=n] ./02_one_device_per_pthread/one_device_per_pthread
03_one_device_per_process_mpi
One Device per Process with MPI
- Pattern: One MPI process per GPU
- API:
ncclCommInitRankwith MPI coordination - Use case: Multi-node clusters, distributed training
- Key features:
- MPI broadcast for unique ID distribution
- Process-to-GPU mapping by local MPI ranks
- Scalable to multiple nodes
Run command:
mpirun -np <num_processes> ./03_one_device_per_process_mpi/one_device_per_process_mpi
Choosing the Right Approach
| Feature | ncclCommInitAll | pthread | MPI |
|---|---|---|---|
| Multi-node support | ✗ | ✗ | ✓ |
| Process isolation | ✗ | ✗ | ✓ |
| Setup complexity | Low | Medium | High |
| Memory overhead | Low | Medium | High |
| Best for | Simple test | Single-node apps | Clusters |
When to use each:
- ncclCommInitAll: Development, testing, simple single-node apps
- pthread: Single-node with thread-based parallelism needs
- MPI: Production distributed training, multi-node setups
Building
Quick Start
# Build all examples [or single directory]
make [directory]
# Test all examples
make test
Individual Examples
# Build specific example
make 01_multiple_devices_single_process
make 02_one_device_per_pthread
make 03_one_device_per_process_mpi
# Test individual example
cd 01_multiple_devices_single_process && make test
cd 02_one_device_per_pthread && make test
cd 03_one_device_per_process_mpi && make test