-qunroll

Category

Optimization and tuning

@PROCESS

None.

Purpose

Specifies whether unrolling DO loops is allowed in a program. Unrolling is allowed on outer and inner DO loops.

Syntax

Read syntax diagramSkip visual syntax diagram
                       .-auto-.       
                  .-=--+-yes--+-.     
                  |    '-n----' |     
        .-unroll--+-------------+-.   
>>- -q--+-nounroll----------------+----------------------------><

Defaults

-qunroll=auto

Parameters

auto
The compiler performs basic loop unrolling.
yes
The compiler looks for more opportunities to perform loop unrolling than that performed with -qunroll=auto. In general, this suboption has more chances to increase compile time or program size than -qunroll=auto processing, but it may also improve your application's performance.
n
Instructs the compiler to unroll loops by a factor of n. In other words, the body of a loop is replicated to create n copies and the number of iterations is reduced by a factor of 1/n. The value of n must be a positive integer.
Specifying -qunroll=1 disables loop unrolling, and is equivalent to specifying -qnounroll. If n is not specified and if -qhot, -qsmp, -O4, or -O5 is specified, the optimizer determines an appropriate unrolling factor for each nested loop.

If you decide to unroll a loop, specifying one of the above suboptions does not automatically guarantee that the compiler will perform the operation. Based on the performance benefit, the compiler will determine whether unrolling will be beneficial to the program. Experienced compiler users should be able to determine the benefit in advance.

Usage

Specifying -qunroll with no suboptions is equivalent to -qunroll=yes.

The -qnounroll option prohibits unrolling unless you specify the STREAM_UNROLL , UNROLL , or UNROLL_AND_FUSE directive for a particular loop. These directives always override the command line options.

Examples

In the following example, the UNROLL(2) directive is used to tell the compiler that the body of the loop can be replicated so that the work of two iterations is performed in a single iteration. Instead of performing 1000 iterations, if the compiler unrolls the loop, it will only perform 500 iterations.

 !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

Related information

See the appropriate directive on unrolling loops:

See High-order transformation .