Programming for HPC¶
Learn to write efficient parallel code that exploits modern CPUs and GPUs. This section covers programming models from auto-vectorization to MPI, with practical examples you can run on ARC clusters.
Who This Is For¶
Software developers and scientists who write compute-intensive code and want to:
Exploit SIMD vector units on modern CPUs
Scale across multi-core processors
Accelerate workloads on GPUs (A100, V100, L40S)
Profile and optimize performance bottlenecks
Manage code with version control
Topic Overview¶
Topic |
Key Skill |
|---|---|
Amdahl’s Law, Flynn’s taxonomy, scaling limits |
|
Memory hierarchy, cache-friendly code, DOP vs OOP |
|
CMake/Autotools with MPI, OpenMP, CUDA flags |
|
Version control for HPC projects |
|
SIMD, compiler flags, measuring bandwidth |
|
Thread-level CPU parallelism with |
|
GPU kernels, device memory, transfers |
|
GPU-accelerated standard algorithms |
|
GPU programming with |
|
Message passing, distributed computing |
|
Performance portability across CPU/GPU |
|
LIKWID hardware counters, roofline model |
|
Memory errors, data races, cache analysis |
|
Nsight Systems & Nsight Compute |
Getting Started¶
Start with theory — Theory and Hardware explain why parallelism matters and how hardware works
Set up version control — Learn Git basics for managing your code
Build your parallel code — Learn CMake/Autotools with MPI, OpenMP, and CUDA
Try auto-vectorization — autovec shows compiler-driven performance gains
Scale to multi-core — openmp for CPU parallelism
Accelerate with GPUs — cuda, stdpar, and omp-offload for GPU programming
Distribute across nodes — mpi for cluster-scale jobs
Profile and optimize — profiling, valgrind, and nsight to find and fix bottlenecks
Examples¶
Throughout this section, there will be example code. You can either copy and paste them from documentation, or you can download them here
Running Examples on ARC Clusters¶
Each module includes code examples. To run them on ARC clusters:
Clone or copy examples to your home directory
Create a SLURM job script (see Running Jobs)
Request appropriate resources:
CPU jobs:
#SBATCH --cpus-per-task=8(adjust for thread count)GPU jobs:
#SBATCH --gres=gpu:1(Ptolemy, Atlas, or Morrill)
Load required modules:
module load gcc # Or nvhpc for CUDA/stdpar module load cuda # GPU jobs only
See SLURM Job Scripts for complete examples.
Common Benchmark: Stream Triad¶
Most modules use the Stream Triad kernel as a benchmark:
This memory-bound operation lets you compare performance across programming models (serial → OpenMP → CUDA) on the same algorithm.