OpenMP¶
OpenMP is an industry-standard API for shared-memory parallel programming in C/C++/Fortran. For fundamentals, specifications, tutorials, and examples, see the OpenMP Resources page.
This page covers NERSC-specific details for compiling and running OpenMP code on Perlmutter.
Compiling OpenMP Code¶
CPU Threading¶
Depending on the compiler suite used, a different flag is needed to use OpenMP:
| Vendor | PrgEnv | Language(s) | OpenMP flag |
|---|---|---|---|
| GNU | PrgEnv-gnu | C/C++/Fortran | -fopenmp |
| NVIDIA | PrgEnv-nvidia | C/C++/Fortran | -mp |
| HPE | PrgEnv-cray | C/C++ | -fopenmp |
| HPE | PrgEnv-cray | Fortran | -homp |
GPU Offload¶
GPU target must be set
Either load the cudatoolkit and craype-accel-nvidia80 modules or use the "target" flags below. These are loaded by default on Perlmutter.
PrgEnv-nvidia¶
Use the -mp=gpu option for GPU offload.
See the NVIDIA HPC SDK Compiler User Guide for detailed documentation.
PrgEnv-cray¶
| Language(s) | OpenMP flag | Target flags |
|---|---|---|
| C/C++ | -fopenmp | -fopenmp-targets=nvptx64 -Xopenmp-target=nvptx64 -march=sm_80 |
| Fortran | -homp -hnoacc | -haccel=nvidia80 |
PrgEnv-gnu¶
PrgEnv-gnu is not recommended for OpenMP GPU offloading.
Tools¶
Cray Reveal is an integrated performance analysis and code optimization tool that can suggest OpenMP directives based on dependency information and provide variable scoping feedback.
Learning Resources¶
The OpenMP Resources page provides comprehensive learning materials:
- Specifications and Reference Guides - Official API specifications
- Examples Document - OpenMP API examples
- Compilers & Tools - Support matrix for compilers and tools
- Videos & Presentations - Tutorials and conference talks
- Books - From beginner to advanced levels
- NVIDIA HPC SDK OpenMP Documentation