Optimization Levels: the /optimize Option

Visual Fortran performs many optimizations by default. You do not have to recode your program to use them. However, understanding how optimizations work helps you remove any inhibitors to their successful function.

If an operation can be performed, eliminated, or simplified at compile time, Visual Fortran does so, rather than have it done at run time. The time required to compile the program usually increases as more optimizations occur.

The program will likely execute faster when compiled at /optimize:4, but will require more compilation time than if you compile the program at a lower level of optimization.

The size of object files varies with the optimizations requested. Factors that can increase object file size include an increase of loop unrolling or procedure inlining.

The following table lists the levels of Visual Fortran optimization with different /optimize:num options (for example, /optimize:0 specifies no selectable optimizations); some optimizations always occur. All levels of optimizations available on the architecture can be specified using /optimize:5. On ia32 systems, /optimize:5 includes loop transformations; on ia64 systems, /optimize:5 includes loop transformations and software pipelining.

Levels of Optimization with Different /optimize:num Options

Optimization Type /optimize:0 /optimize:1 /optimize:2 /optimize:3 /optimize:4 /optimize:5
Software pipelining           x (ia64 only)
Loop transformation           x
Automatic inlining         x x
Additional global optimizations       x x x
Global optimizations     x x x x
Local (minimal) optimizations   x x x x x

The default for the command line and in the visual development environment for a release configuration is /optimize:4. In the visual development environment for a debug configuration, the default is /optimize:0. However, when /debug is specified, the default is /optimize:0 (no optimizations).

In the table, the following terms are used to describe the levels of optimization (described in detail in the following sections:

The following sections discuss I/O performance considerations in more detail: