prof

The profprofiler can also be used for profiling. Unlike the gprofprofiler, prof does not generate the call graph profile. To use prof, do the following:

1.Compile the program with the +prof option. For example: $ f90 -o prog +prof prog.f90

2.Run the program. This creates a file named mon.out in the current directory. For example: $ prog$ ls mon.outmon.out

3.Run prof, giving the name of the program as an argument, as follows: $ prof prog

profproduces a listing on standard output showing the time spent in each routine.

For more information about prof, see the prof((1))man page.

Using options to control optimization

HPFortranincludes a rich set of command-line options for controlling optimization. For most applications, we recommend optimizing with -O, which enables the default level of optimization. (For information about the default level of optimization, refer to Table on page 149; look up +O2 in the first column.) You can raise or lower the level of optimization with the +Oopt-leveloption, and you can use the +Ooptimizationoption to control the kinds of optimizations that are available at each level.

The following sections describe how to use the +Oopt-leveland +Ooptimizationoptions. For detailed descriptions of the optimization options, see the HPFortranProgrammer’s Reference.

Using +O to set optimization levels

HP Fortran provides four levels of optimization. Each higher level is a superset of the lower levels; level 4 is the highest level and can result in a significant increase in program performance. Level 2 is the default level of optimization.

You invoke optimization by compiling with the +Oopt-leveloption, where opt-levelis an integer in the range 0 - 4. The following command line invokes the optimizer at the highest level:

$ f90 +O4 file.f90

You can invoke level 2 (the default level) by specifying the -Ooption.

Table6-1 summarizes each level, giving the option that invokes that level, the advantages, disadvantages, and recommended usages. For technical information about the specific optimizations at each level, see the HP PA-RISC Compiler Optimization Technology White Paper. A PostScript version of this document is available online in /opt/langtools/newconfig/white_papers/ optimize.ps.

NOTE: You can debug programs optimized up to level 2. To prepare an optimized program for debugging, use the command line:

$ f90 -g +Oopt-level prog.f90

Table 27 Optimization levels

 

Optimizations

 

 

 

Option

performed

Advantages

Disadvantages

Recommended use

 

 

 

 

 

+O0default

Constant folding and

Compiles fastest;

Does very little

During program development.

 

partial evaluation of

compatible with the

optimization.

 

 

test conditions.

debugger option -g.

 

 

 

 

 

 

 

+O1

Level 0

Produces faster

Compiles slower

During program development.

 

optimizations, plus

programs than level 0;

than level 0.

 

 

 

 

 

 

90 Performance and optimization