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.

Table 1: Based on the list available from OpenMP as of this writing (August 2025).

1This column refers to versions of Intel Compiler Classic (icc, icpc, ifort). To use the subset of OpenMP 5.0 and 5.1 available in Intel's newer, LLVM-based "oneAPI" compilers (ifx, icx, icpx, dpcpp), compile with -fiopenmp -fopenmp-targets=spir64.
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 is useful for compiling and linking code that contains calls to the OpenMP runtime library for serial execution. In other words, if you have calls to OpenMP runtime library functions in your code and you are using an Intel compiler, you should either use -qopenmp to build for parallel execution or -qopenmp-stubs to build for serial execution. The flags, -qopt-report=n -qopt-report-phase=openmp, control reporting on what OpenMP constructs have been compiled. With n=1, this reports on work-sharing constructs. Level 0 turns off all reporting on OpenMP from the compiler and level 2 adds information about the control directives compiled.

 
©  |   Cornell University    |   Center for Advanced Computing    |   Copyright Statement    |   Access Statement
CVW material development is supported by NSF OAC awards 1854828, 2321040, 2323116 (UT Austin) and 2005506 (Indiana University)