Compiling with OpenMP, Directive Format, and Diagnostics

To run the Intel® compiler in OpenMP mode, invoke the compiler with the -openmp (Linux*) or /Qopenmp (Windows*) option using a command structured similar to the following:

Platform

Description

Linux

icpc -openmp input_file

Windows

icl /Qopenmp input_file

Before you run the multithreaded code, you can set the number of desired threads in the OpenMP environment variable, OMP_NUM_THREADS. For more information, see the OpenMP Environment Variablessection. The Intel Extension Routines topic describes the OpenMP extensions to the specification that have been added by Intel to the Intel® compiler.

OpenMP Option

The -openmp (Linux*) or /Qopenmp (Windows*) option enables the parallelizer to generate multithreaded code based on the OpenMP directives. The code can be executed in parallel on both uniprocessor and multiprocessor systems.

The -openmp (Linux) or /Qopenmp (Windows) option works with both -O0 (Linux) and /Od (Windows), or with any optimization level of -O1, -O2 and -O3. (Linux) or /O1, /O2 and /O3 (Windows). Specifying -O0 (Linux) or /Od (Windows) with the OpenMP option helps to debug OpenMP applications.

When you use the openmp option, the compiler sets the -auto (Linux) or /Qauto (Windows) option, which causes all variables to be allocated on the stack, rather than in local static storage.

OpenMP Directive Format and Syntax

The OpenMP directives use the following format:

Example

#pragma omp directive-name [clause, ...] newline

where:

OpenMP Diagnostic Reports

The -openmp-report (Linux) or /Qopenmp-report (Windows) option controls the OpenMP* parallelizer's diagnostic levels 0, 1, or 2 as follows:

Windows*

Linux*

Description

/Qopenmp-report0

-openmp-report0

No diagnostic information is displayed.

/Qopenmp-report1

-openmp-report1

Display diagnostics indicating loops, regions, and sections successfully parallelized.

/Qopenmp-report2

-openmp-report2

Same as specifying 1 plus diagnostics indicating constructs like MASTER, SINGLE, CRITICAL, ORDERED, ATOMIC directives, and so forth are successfully handled.

For more information about the option behaviors listed above, see the following topic in Compiler Options: