Visible to Intel only — GUID: GUID-BCE9B8E0-A8C3-4E5D-BC3E-EC0A17F38283
Visible to Intel only — GUID: GUID-BCE9B8E0-A8C3-4E5D-BC3E-EC0A17F38283
PARALLEL and NOPARALLEL General Directives
General Compiler Directives: PARALLEL facilitates auto-parallelization by assisting the compiler's dependence analysis of the immediately following DO loop. NOPARALLEL prevents this auto-parallelization. This feature is only available for ifort.
!DIR$ PARALLEL [clause[[,] clause] ... ]
!DIR$ NOPARALLEL
clause |
Is one or more of the following:
|
list |
Is one or more items in the form: var [:expr]…. Each list item must be separated by a comma. |
var |
Is a scalar or array variable. The following rules apply:
|
expr |
Is an integer expression denoting the number of array elements to privatize. When expr is specified, var must be an array or a pointer variable. The following rules also apply:
|
PARALLEL helps the compiler to resolve dependencies, facilitating auto-parallelization of the immediately following DO loop. It instructs the compiler to ignore dependencies that it assumes may exist and which would prevent correct parallelization in the loop. However, if dependencies are proven, they are not ignored.
In addition, PARALLEL ALWAYS overrides the compiler heuristics that estimate the likelihood that parallelization of a loop will increase performance. It allows a loop to be parallelized even if the compiler thinks parallelization may not improve performance. If the ASSERT keyword is added, the compiler will generate an error-level assertion message saying that the compiler analysis and cost model indicate that the loop cannot be parallelized.
NOPARALLEL prevents auto-parallelization of the immediately following DO loop.
These directives take effect only if you specify the compiler option that enables auto-parallelization.
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.
program main
parameter (n=100)
integer x(n), a(n), k
!DIR$ NOPARALLEL
do i=1,n
x(i) = i
enddo
!DIR$ PARALLEL LASTPRIVATE (k)
do i=1,n
a( x(i) ) = i
k = x(i)
enddo
print *, k ! print 100, the value of x(n)
end