openmp Getting started with openmp Compilation

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

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'


Got any openmp Question?