Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

UNROLL and NOUNROLL General Directives

General Compiler Directive: Tells the compiler's optimizer how many times to unroll a DO loop or disables the unrolling of a DO loop. These directives can only be applied to iterative DO loops.

!DIR$ UNROLL [(n)] -or- !DIR$ UNROLL [=n]

!DIR$ NOUNROLL

n

Is an integer constant. The range of n is 0 through 255.

If n is specified, the optimizer unrolls the loop n times. If n is omitted, or if it is outside the allowed range, the optimizer picks the number of times to unroll the loop.

The UNROLL directive overrides any setting of loop unrolling from the command line.

To use these directives, compiler option O2 or O3 must be set.

Example

!DIR$ UNROLL
  do i =1, m
    b(i) = a(i) + 1
    d(i) = c(i) + 1
  enddo

The following shows another example:

!DIR$ UNROLL= 4
  do i =1, m
    b(i) = a(c(i)) + 1
  enddo