Go to main content
Oracle® Developer Studio 12.5: OpenMP API User's Guide

Exit Print View

Updated: July 2016

2.1 Compiler Options

To enable explicit parallelization with OpenMP directives, compile your program with the cc, CC, or f95 compiler option -xopenmp. The f95 compiler accepts both -xopenmp and -openmp as synonyms.

The -xopenmp flag accepts the keyword sub-options listed in the following table.

Enables recognition of OpenMP directives.
The minimum optimization level for -xopenmp=parallel is -xO3.
If the optimization level is lower than -xO3, the compiler raises the optimization level to -xO3 and issues a warning.
Enables recognition of OpenMP directives.
The compiler does not raise the optimization level if it is lower than -xO3.
If you explicitly set the optimization level with -xopenmp=noopt lower than -xO3, as in -xO2 -xopenmp=noopt, the compiler will issue an error.
If you do not specify an optimization level with -xopenmp=noopt, the OpenMP directives are recognized and the program is parallelized accordingly, but no optimization is done.
This option is no longer supported.
For C and C++ programs only:
An OpenMP stubs library is provided for users’ convenience. To compile an OpenMP program that calls OpenMP runtime routines but ignores the OpenMP directives, compile the program without the -xopenmp option and link the object files with the libompstubs.a library. For example,
% cc omp_ignore.c -lompstubs

Note -  Linking with both libompstubs.a and the OpenMP runtime library, libmtsk.so, is unsupported and may result in unexpected behavior.

Disables recognition of OpenMP directives and does not change the optimization level.

Note the following additional points:

  • If you do not specify -xopenmp on the command line, the compiler assumes –xopenmp=none (disable recognition of OpenMP directives) by default.

  • If you specify -xopenmp but without a keyword sub-option, the compiler assumes –xopenmp=parallel.

  • Specifying -xopenmp=parallel or -xopenmp=noopt will define the _OPENMP macro to have the decimal value 201307L in C/C++ and 201307 in Fortran, where 2013 is the year and 07 is the month of the OpenMP 4.0 specification.

  • When debugging OpenMP programs with dbx, compile with -xopenmp=noopt -g to enable full debugging capabilities.

  • To avoid compilation warning messages, specify an appropriate optimization level explicitly rather than relying on the default value, which is subject to change.

  • With Fortran, compiling with -xopenmp, -xopenmp=parallel, or -xopenmp=noopt implies -stackvar. See Stacks and Stack Sizes.

  • When compiling and linking an OpenMP program in separate steps, include -xopenmp in each of the compile and the link steps.

  • Use the -xvpara option with the -xopenmp option to display compiler warnings about potential OpenMP programming problems (see Scope Checking).