HP Fortran Programmer's Guide (March 2010)
Performance and optimization
Parallelizing HP Fortran programs
Chapter 6 169
You can use the DIR$ NO SIDE EFFECTS directive to force the compiler to ignore side effects
when determining whether to parallelize the loop. For information about this directive, see .
NOTE A subroutine (but not a function) is always expected to have side effects. If you
apply this directive to a subroutine call, the optimizer assumes that the call has
no effect on program results and can eliminate the call to improve performance.
Indeterminate iteration counts
If the compiler finds that a runtime determination of a loop's iteration count cannot be made
before the loop starts to execute, the compiler will not parallelize the loop. The reason for this
precaution is that the runtime code must know the iteration count in order to determine how
many iterations to distribute to the executing processors.
The following conditions can prevent a runtime count:
• The loop is a DO-forever construct.
•An EXIT statement appears in the loop.
• The loop contains a conditional GO TO statement that exits from the loop.
• The loop modifies either the loop-control or loop-limit variable.
• The loop is a DO WHILE construct and the condition being tested is defined within the loop.
Data dependences
When a loop is parallelized, the iterations are executed independently on different processors,
and the order of execution will differ from the serial order when executing on a single
processor. This difference is not a problem if the iterations can occur in any order with no
effect on the results. Consider the following loop:
DO I = 1, 5
A(I) = A(I) * B(I)
END DO
In this example, the array A will always end up with the same data regardless of whether the
order of execution is 1-2-3-4-5, 5-4-3-2-1, 3-1-4-5-2, or any other order. The independence of
each iteration from the others makes the loop an eligible candidate for parallel execution.
Such is not the case in the following:
DO I = 2, 5
A(I) = A(I-1) * B(I)
END DO