Auto-parallelization: Enabling, Options, Directives, and Environment Variables

To enable the auto-parallelizer, use the -parallel (Linux* and Mac OS* X) or /Qparallel (Windows*) option. This option detects parallel loops capable of being executed safely in parallel and automatically generates multi-threaded code for these loops.

Note iconNote

You might need to set the KMP_STACKSIZE environment variable to an appropriately large size to enable parallelization with this option.

An example of the command using auto-parallelization is as follows:

Operating System

Description

Linux and Mac OS X

ifort -c -parallel myprog.f

Windows

ifort -c /Qparallel myprog.f

Auto-parallelization uses two specific directives, !DEC$ PARALLEL and !DEC$ NO PARALLEL.

Auto-parallelization Directives Format and Syntax

The format of an auto-parallelization compiler directive is:

Syntax

<prefix> <directive>

where the brackets above mean:

The prefix is followed by the directive name; for example:

Syntax

!DEC$ PARALLEL

Since auto-parallelization directives begin with an exclamation point, the directives take the form of comments if you omit the -parallel (Linux) or /Qparallel (Windows) option.

The !DEC$ PARALLEL directive instructs the compiler to ignore dependencies that it assumes may exist and which would prevent correct parallelization in the immediately following loop. However, if dependencies are proven, they are not ignored.

The !DEC$ NOPARALLEL directive disables auto-parallelization for the following loop:

Example

program main

parameter (n=100

integer x(n),a(n)

!DEC$ NOPARALLEL

do i=1,n

x(i) = i

enddo

!DEC$ PARALLEL

do i=1,n

a( x(i) ) = i

enddo

end

Auto-parallelization Environment Variables

Auto-parallelization uses the following OpenMP* environment variables.

See OpenMP* Environment Variables for more information about the default settings and how to use these variables.