The optimize
directive sets the optimization
level, ranging from 0 for minimum optimization to 5 for maximum
optimization. You can set the optimization level globally by using
the optimize=<integer>
command qualifier. The following
shows the meaning of each of the different optimization levels:
Value | Disables |
---|---|
0 | KAP does not perform loop optimizations. |
1
| KAP performs only simple analysis and loop optimizations. |
2 |
DO loop interchanging techniques are applied. Lifetime analysis is performed to determine when last-value assignment of scalars is necessary. More powerful data dependence tests are used. |
3 | KAP distributes loops to optimize only a part of a loop. Special techniques are used to break data dependence cycles that otherwise prevent optimization. More loop interchanging is attempted, such as interchanging of triangular loops. Special-case data dependence tests are used. Special index sets, called wraparound variables, are recognized to uncover more opportunities for optimization. |
4 | Two versions of a loop are generated, if necessary, to break a data dependence arc. Loop interchanging around reductions is attempted. More exact data dependence tests are allowed. |
5 | Array expansion and loop fusion are enabled. |
A higher optimization level results in more optimization, along with increased compilation time. Many programs that are written to be easily optimized do not need advanced transformations; with these programs, a lower optimization level will suffice.