Sun Studio 12 Update 1: C++ User's Guide

A.2.158 -xopenmp[=i]

Use the -xopenmp option to enable explicit parallelization with OpenMP directives. To run a parallelized program in a multithreaded environment, you must set the OMP_NUM_THREADS environment variable prior to execution.

To enable nested parallelism, you must set the OMP_NESTED environment variable to TRUE. Nested parallelism is disabled by default.

A.2.158.1 Values

The following table lists the values for i:

Table A–41 The -xopenmp Values

Values 

Meaning  

parallel

Enables recognition of OpenMP pragmas. The minimum optimization level under -xopenmp=parallel is -x03. The compiler changes the optimization from a lower level to -x03 if necessary and issues a warning.

This flag also defines the preprocessor token _OPENMP.

noopt

Enables recognition of OpenMP pragmas. The compiler does not raise the optimization level if it is lower than -O3.

If you explicitly set the optimization lower than -O3, as in CC -O2 -xopenmp=noopt, the compiler issues an error. If you do not specify an optimization level with -xopenmp=noopt, the OpenMP pragmas are recognized, the program is parallelized accordingly, but no optimization is done.

This flag also defines the preprocessor token _OPENMP.

none

This flag is the default and disables recognition of OpenMP pragmas, does not change the optimization level of your program, and does not predefine any preprocessor tokens. 

Defaults

If you do not specify -xopenmp, the compiler sets the option to -xopenmp=none.

If you specify -xopenmp, but without an argument, the compiler sets the option to -xopenmp=parallel.

Interactions

If you are debugging an OpenMP program with dbx, compile with -g and -xopenmp=noopt so you can breakpoint within parallel regions and display the contents of variables.

Warnings

Do not specify -xopenmp, with either -xexplicitpar, or -xparallel.

The default for -xopenmp might change in future releases. You can avoid warning messages by explicitly specifying an appropriate optimization.

If you compile and link in separate steps, specify -xopenmp in both the compilation step and the link step. This is important if you are building a shared object. The compiler which was used to compile the executable must not be any older than the compiler that built the .so with -xopenmp. This is especially important when you compile libraries that contain OpenMP directives. See 3.3.3 Compile-Time and Link-Time Options for a complete list of options that must be specified at both compile time and line time.

Make sure that the latest patch of the OpenMP runtime library, libmtsk.so, is installed on the system for best performance.

See also

For a complete summary of the OpenMP Fortran 95, C, and C++ application program interface (API) for building multiprocessing applications, see the Sun Studio OpenMP API User’s Guide.