OpenMP is a portable, scalable model that gives shared-memory parallel programmers a simple and flexible interface for developing parallel applications for various platforms.
Building OpenMP Applications
The following Intel compiler options can be used for building or analyzing OpenMP applications:
-qopenmp
Enables the parallelizer to generate multithreaded code based on OpenMP directives. The code can be executed in parallel on both uniprocessor and multiprocessor systems. The -openmp option works with both -O0 (no optimization) and any optimization level of -O. Specifying -O0 with -openmp helps to debug OpenMP applications.
-assume cc_omp or -assume nocc_omp
-assume cc_omp enables conditional compilation as defined by the OpenMP Fortran API. That is, when "!$space" appears in free-form source or "c$spaces" appears in column 1 of fixed-form source, the rest of the line is accepted as a Fortran line.
-assume nocc_omp tells the compiler that conditional compilation as defined by the OpenMP Fortran API is disabled unless option -openmp (Linux) or /Qopenmp (Windows) is specified.
-openmp-link dynamic or -openmp-link static
Choosing -openmp-link dynamic tells the compiler to link to dynamic OpenMP run-time libraries.
Choosing -openmp-link static tells the compiler to link to static OpenMP run-time libraries.
Note that the compiler options -static-intel and -shared-intel have no effect on which OpenMP run-time library is linked.
-qopenmp-threadprivate=legacy or -qopenmp-threadprivate=compat
Choose -qopenmp-threadprivate=legacy tells the compiler to use the legacy OpenMP threadprivate implementation used in the previous releases of the Intel(R) compiler. This setting does not provide compatibility with the implementation used by other compilers.
Choose -qopenmp-threadprivate=compat tells the compiler to use the compatibility OpenMP thread private implementation based on applying the thread-local attribute to each threadprivate variable. This setting provides compatibility with the implementation provided by the Microsoft and GNU compilers.
-qopenmp-stubs
Enables compilation of OpenMP programs in sequential mode. The OpenMP directives are ignored and a stub OpenMP library is linked.
-qopt-report-phase=openmp
This option generates optimization reports for the OpenMP phase.
OpenMP Environment Variables
There are a few OpenMP environment variables one can set. The most commonly used are:
OMP_NUM_THREADS num
Sets number of threads for parallel regions. Default is 1 for PBS jobd on NAS systems. Note that you can use ompthreads in the PBS resource request to set values for OMP_NUM_THREADS. For example:
%qsub -I -lselect=1:ncpus=4:ompthreads=4
Job 991014.pbspl1.nas.nasa.gov started on Sun Sep 12 11:33:06 PDT 2010
...
PBS r3i2n9> echo $OMP_NUM_THREADS
4
PBS r3i2n9>
OMP_SCHEDULE type[,chunk]
Sets the run-time schedule type and chunk size. Valid OpenMP schedule types are static, dynamic, guided, or auto. Chunk is a positive integer.
OMP_DYNAMIC true or OMP_DYNAMIC false
Enables or disables dynamic adjustment of threads to use for parallel regions.
OMP_STACKSIZE size
Specifies size of stack for threads created by the OpenMP implementation. Valid values for size (a positive integer) are size, sizeB, sizeK, sizeM, sizeG. If units B, K, M or G are not specified, size is measured in kilobytes (K).
Note that Intel also provides a few additional environment variables. The most commonly used are:
KMP_AFFINITY type
Binds OpenMP threads to physical processors. Available type: compact, disabled, explicit, none, and scatter.
WARNING: There is a conflict between KMP_AFFINITY in Intel 11.x runtime library and dplace, causing all threads to be placed on a single CPU when both are used. It is recommended that KMP_AFFINITY be set to disabled when using dplace.
KMP_MONITOR_STACKSIZE
Sets stack size in bytes for monitor thread.
KMP_STACKSIZE
Sets stack size in bytes for each thread.
For more information, please see the official OpenMP web site.