The UNROLL directive instructs the compiler to attempt loop unrolling where applicable. Loop unrolling replicates the body of the DO loop to reduce the number of iterations required to complete the loop.
You can control loop unrolling for an entire file using the -qunroll compiler option. Specifying the directive for a particular DO loop always overrides the compiler option.
The UNROLL directive must immediately precede a DO loop.
You must not specify the UNROLL directive more than once, or combine the directive with NOUNROLL, STREAM_UNROLL, UNROLL_AND_FUSE, or NOUNROLL_AND_FUSE directives for the same DO construct.
You must not specify the UNROLL directive for a DO WHILE loop or an infinite DO loop.
!IBM* UNROLL(2)
DO I = 1, 1000
A(I) = I
END DO
If the compiler chooses to unroll the previous
loop, the compiler translates the loop so that it is essentially equivalent
to the following: DO I = 1, 1000, 2
A(I) = I
A(I+1) = I + 1
END DO
PROGRAM GOODUNROLL
INTEGER I, X(1000)
REAL A, B, C, TEMP, Y(1000)
!IBM* UNROLL(3)
DO I = 1, 1000
X(I) = X(I) + 1
END DO
!IBM* UNROLL
DO I = 1, 1000
A = -I
B = I + 1
C = I + 2
TEMP = SQRT(B*B - 4*A*C)
Y(I) = (-B + TEMP) / (2*A)
END DO
END PROGRAM GOODUNROLL