openmp Getting started with openmp Compilation


There are many compilers that support different versions of the OpenMP specification. OpenMP maintains a list here with the compiler that support it and the supported version. In general, to compile (and link) an application with OpenMP support you need only to add a compile flag and if you use the OpenMP API you need to include the OpenMP header (omp.h). While the header file has a fixed name, the compile flag depends on the compiler. The following is a non-exhaustive list of compilers and the flag that enables OpenMP.

  • GCC (including gcc, g++ and gfortran) : -fopenmp
  • LLVM: -fopenmp
  • Intel compiler-suite (including icc, icpc and ifort) : -qopenmp (and -fopenmp for compatibility with GCC/LLVM)
  • IBM XL compiler-suite (including xlc, xlC and xlf) : -xlsmp=omp
  • PGI compiler-suite (including pgcc pgc++ pgfortran) : '-mp'