You can prevent parallelization on a loop-by-loop basis using
the no_parallel directive or pragma. The form of this directive
and pragma is shown in Table 6-4 “Form of no_parallel directive and pragma”.
Table 6-4 Form of no_parallel directive and pragma
| Language | Form |
|---|
| Fortran | C$DIR NO_PARALLEL |
| C | #pragma _CNX no_parallel |
Use these directives to prevent parallelization of the loop
that immediately follows them. Only parallelization is inhibited;
all other loop optimizations are still applied.
Example 6-8 no_parallel
The following Fortran example illustrates the use of no_parallel:
DO I = 1, 1000 C$DIR NO_PARALLEL DO J = 1, 1000 A(I,J) = B(I,J) ENDDO ENDDO |
In this example, parallelization of the J loop is prevented. The I loop can still be parallelized.
The +Onoautopar compiler option is available to disable automatic parallelization
but allows parallelization of directive-specified loops. Refer to Chapter 7 “Controlling
optimization”, and Chapter 9 “Parallel
programming techniques”, for more information on
+Onoautopar.