Application Development¶
Compilers¶
The Intel, GNU and Portland Group (PGI) C, C++ and Fortran compilers are installed and can be used to create OpenMP, MPI, hybrid and serial programs. The commands you should use to create each of these types of programs are shown in the table below.
Intel compilers are loaded by default, codes can be compiled according to the following chart:
Intel Compiler Commands
| Serial Codes | MPI Codes | OpenMP Codes | Hybrid Codes | |
|---|---|---|---|---|
| Fortran | ifort | mpiifort | ifort -openmp | mpiifort -openmp |
| C | icc | mpiicc | icc -openmp | mpiicc -openmp |
| C++ | icpc | mpiicpc | icpc -openmp | mpiicpc -openmp |
GNU Compiler Commands
| Serial Codes | MPI Codes | OpenMP Codes | Hybrid Codes | |
|---|---|---|---|---|
| Fortran | gfortran | mpif90 | gfortran -fopenmp | mpif90 -fopenmp |
| C | gcc | mpicc | gcc -fopenmp | mpicc -fopenmp |
| C++ | g++ | mpiCC | g++ -fopenmp | mpiCC -fopenmp |
PGI Compiler Commands
| Serial Codes | MPI Codes | OpenMP Codes | Hybrid Codes | |
|---|---|---|---|---|
| Fortran | pgf90 | mpif90 | pgf90 -mp | mpif90 -mp |
| C | pgcc | mpicc | pgcc -mp | mpicc -mp |
| C++ | pgCC | mpiCC | pgCC -mp | mpiCC -omp |
Default MPI: Intel MPI 2021.5.1 compiled with Intel compiler version 2021.5.0
To compile a serial program, the syntax is: <your choice of compiler> <compiler flags> <source file name> . For example, the command below compiles the source file _mysource.f90_ and generate the executable _myexec_.
ifort -o myexec mysource.f90
To compile a MPI program, the syntax is the same, except that one needs to replace the serial compiler with an MPI one listed in the table above:
mpif90 -o myexec_par my_parallel_source.f90
GPU Programming¶
CUDA Programming¶
NVIDIA's CUDA compiler and libraries are accessed by loading the CUDA module:
module load cuda
Use the nvcc compiler on the head node to compile code, and run executables on nodes with GPUs - there are no GPUs on the head nodes.
K20's GPUs are compute capability 2.0 devices. When compiling your code, make sure to specify this level of capability with:
nvcc -arch=compute_20 -code=sm_20 ...
A100's GPUs are compute capability 8.0 devices
nvcc -arch=compute_80 -code=sm_80 ...
GPU nodes are accessible through the gpu partition for production work.
OpenACC Programming¶
OpenACC is the name of an application program interface (API) that uses a collection of compiler directives to accelerate applications that run on multicore and GPU systems.
The OpenACC compiler directives specify regions of code that can be offloaded from a CPU to an attached accelerator.
A quick reference guide is available here.
Currently, only the Portland Group compilers can be used to compile C and Fortran code annotated with OpenACC directives.
To load the PGI compilers:
module load pgi
To compile a C code annotated with OpenACC directives:
pgcc -acc -ta=nvidia -Minfo=accel code.c -o code.exe