Compiling with OpenMP
Compiler Versions
There is a wide array of compilers and software tools with support for the OpenMP API in C, C++, and Fortran from vendors and the open source community. In Table 1, we provide a subset of available compilers in C, C++, and Fortran with full support for the indicated OpenMP version unless otherwise noted.
OpenMP Version | GNU Compiler Version | Intel Compiler Version |
---|---|---|
4.0 | 4.9.1 | 15.0, 16.0 |
4.5 | 6.1 C/C++ (full support) 7.1 Fortran (partial support) 11.1 Fortran (full support) |
17.0, 18.0, 19.0 |
5.0 | 9.1 C/C++/Fortran (partial support) | 19.1, 2021.1 (subset available)1 |
This is by no means a comprehensive list of available compilers with OpenMP support, but rather a curated list for comparison to what is available on Frontera and Vista. From this table, we can see that Frontera's default modules for the Intel and GCC compilers (19.1.1 and 9.1.0) provide at least partial support for OpenMP versions 5.0 and above. The same is true for Vista's default modules for the GCC and NVIDIA compilers (15.1.0 and 24.7-0). As new compiler versions are released by these vendors, with more complete support of OpenMP 5.0, one can expect they will be made available on these systems as well, so users can take advantage of the latest features.
How To Compile
The compiler flag that determines whether the OpenMP directives are interpreted
by the compiler is -fopenmp
for GCC 4.2 and later for
C, C++, and Fortran. The -qopenmp
flag will work for the Intel icc
(C), icpc
(C++), and ifort
(Fortran) compilers. And the -mp
flag is used for NVIDIA's compilers nvc
(C), nvc++
(C++), and nvfortran
.
Examples of compiling with GNU, Intel, and NVIDIA compilers for a C application with OpenMP would look like this:
The Intel compilers have some additional flags related to OpenMP. -qopenmp-stubs
-qopenmp
-qopenmp-stubs
-qopt-report=n -qopt-report-phase=openmp
CVW material development is supported by NSF OAC awards 1854828, 2321040, 2323116 (UT Austin) and 2005506 (Indiana University)