Oracle® Solaris Studio 12.4: Fortran User's Guide

Exit Print View

Updated: March 2015
 
 

3.4.69 –O[n]

Specify optimization level .

n can be 1, 2, 3, 4, or 5. No space is allowed between -O and n.

If -O[n] is not specified, only a very basic level of optimization limited to local common subexpression elimination and dead code analysis is performed. A program’s performance may be significantly improved when compiled with an optimization level than without optimization. Use of -O (which sets -O3) or -fast (which sets -O5) is recommended for most programs.

Each -On level includes the optimizations performed at the levels below it. Generally, the higher the level of optimization a program is compiled with, the better runtime performance obtained. However, higher optimization levels may result in increased compilation time and larger executable files.

Debugging with -g does not suppress -On, but -On limits -g in certain ways; see the dbx documentation.

The -O3 and -O4 options reduce the utility of debugging such that you cannot display variables from dbx, but you can still use the dbx where command to get a symbolic traceback.

If the optimizer runs out of memory, it attempts to proceed over again at a lower level of optimization, resuming compilation of subsequent routines at the original level.

For details on optimization, see the Fortran Programming Guide chapters “Performance Profiling” and “Performance and Optimization.”

–O

This is equivalent to -O3.

–O1

Provides a minimum of statement–level optimizations.

Use if higher levels result in excessive compilation time, or exceed available swap space.

–O2

Enables basic block level optimizations.

This level usually gives the smallest code size. (See also -xspace.)

–O3 is preferred over -O2 unless -O3 results in unreasonably long compilation time, exceeds swap space, or generates excessively large executable files.

–O3

Adds loop unrolling and global optimizations at the function level. Adds -depend automatically.

Usually -O3 generates larger executable files.

–O4

Adds automatic inlining of routines contained in the same file.

Usually -O4 generates larger executable files due to inlining.

The -g option suppresses the -O4 automatic inlining described above.–xcrossfile increases the scope of inlining with -O4.

–O5

Attempt aggressive optimizations.

Suitable only for that small fraction of a program that uses the largest fraction of compute time. -O5’s optimization algorithms take more compilation time, and may also degrade performance when applied to too large a fraction of the source program.

Optimization at this level is more likely to improve performance if done with profile feedback. See -xprofile=p.