Sun Studio 12 Update 1: Fortran User's Guide

3.4.149 –xopenmp[={parallel|noopt|none}]

Enable explicit parallelization with Fortran OpenMP Version 3.0 directives.

The flag accepts the following optional keyword suboptions:

parallel
  • Enables recognition of OpenMP pragmas, and the program is parallelized accordingly.

  • The minimum optimization level for -xopenmp=parallel is -xO3. The compiler changes the optimization from a lower level to -xO3 if necessary, and issues a warning.

  • Defines preprocessor token _OPENMP

  • Invokes -stackvar automatically.

noopt
  • Enables recognition of OpenMP pragmas, and the program is parallelized accordingly.

  • The compiler does not raise the optimization level if it is lower than -xO3. If you explicitly set the optimization to a level 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 pragmas are recognized, the program is parallelized accordingly, but no optimization is done.

  • Defines preprocessor token _OPENMP

  • Invokes -stackvar automatically.

none

Disables recognition of OpenMP pragmas and does not change the optimization level. (This is the compiler’s default.)

-xopenmp specified without a suboption keyword is equivalent to -xopenmp=parallel. Note that this default might change in later releases.

To debug OpenMP programs with dbx, compile with -g -xopenmp=noopt to be able to breakpoint within parallel regions and display the contents of variables.

The OpenMP directives are summarized in the OpenMP API User’s Guide.

To run a parallelized program in a multithreaded environment, you must set the PARALLEL (or OMP_NUM_THREADS) environment variable prior to execution. This tells the runtime system the maximum number of threads the program can create. The default is 1. In general, set the PARALLEL or OMP_NUM_THREADS variable to the number of available virtual processors on the target platform.

To enable nested parallelism, you must set the OMP_NESTED environment variable to TRUE. Nested parallelism is disabled by default. See the Sun Studio OpenMP API User’s Guide for details on nested parallelism.

OpenMP requires the definition of the preprocessor symbol _OPENMP to have the decimal value YYYYMM where YYYY and MM are the year and month designations of the version of the OpenMP Fortran API that the implementation supports. For the current Sun Studio release the value is 200830 for OpenMP version 3.0.

When compiling and linking in separate steps, also specify -xopenmp on the link step. This is especially important when compiling libraries that contain OpenMP directives.