PARALLEL and NOPARALLEL Loop Directives

General Compiler Directives: PARALLEL enables auto-parallelization for an immediately following DO loop. NOPARALLEL (the default) disables this auto-parallelization.

Syntax

cDEC$ PARALLEL [ALWAYS]
cDEC$ NOPARALLEL


c
Is one of the following: C (or c), !, or *. (See Syntax Rules for Compiler Directives.)

Description

PARALLEL 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. PARALLEL ALWAYS instructs the compiler to ignore dependencies even if they can be proven to exist.

Caution

The directive PARALLEL ALWAYS should be used with care. Overriding the heuristics of the compiler should only be done if you are absolutely sure the parallelization will improve performance.

See Also

Rules for General Directives that Affect DO Loops

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