Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Fortran 90 Compiler for HP-UX: Fortran 90 Programmer's Guide > Chapter 6 Performance and optimization

Using profilers

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

A profiler is a tool for sampling a program during execution so that you can determine where your program spends most of its time. After examining the data provided by a profiler, you can decide whether to redesign parts of the program to improve their performance or to re-compile the program with optimization options. For example, if your program contains a loop with an embedded call and profiling reveals that the program spends much of its time in the loop, you may decide to inline the embedded call.

The following sections describe the CXperf performance analysis tool, which is bundled with HP Fortran 90, as well as the two UNIX profilers, gprof and prof.

NOTE: As described in “Stripping debugging information”, all programs compiled by HP Fortran 90 include symbol table information in the executable file, unless you compile with the +strip option or have removed the symbol table with the strip utility. This information must be present in the executable in order to use the profiling tools.

CXperf

When working on HP V-Class systems, you can use the CXperf profiler to get loop-level and routine-level information on HP Fortran 90 programs. For CXperf support, compile using the +pa option (for routine-level data) or the +pal option (for loop-level and routine-level data). For example:

% f90 +pal foo.f

The +pa and +pal options cause HP Fortran 90 to run cxoi (the CXperf object instrumentor) as part of the compilation process to create an executable program that supports CXperf's methods of collecting statistics.

To collect profile statistics for a program that was compiled with +pa or +pal, run CXperf and specify the executable program you want to profile. For example:

% /opt/cxperf/bin/cxperf a.out

CXperf creates a profile of a program by collecting information on the wall clock time and CPU time spent per routine (and, if requested, per loop). It also can gather statistics on cache hits and misses and other aspects of the program's execution, such as the sequence in which routines are called (viewable as a graphical "call graph").

More information about CXperf is available from its Help menu.

gprof

The gprof profiler enables you to determine which subprograms are called the most and how much time is spent in each subprogram.To use gprof, do the following:

  1. Compile the program with the +gprof option. For example:

    $ f90 -o prog +gprof prog.f90
  2. Run the program. This creates the file gmon.out in the current directory. For example:

    $ prog
    $ ls gmon.out
    gmon.out
  3. Run gprof, specifying the name of the program as an argument. It will display two tables to standard output: a flat profile and a call graph profile. Since these tables can be quite large, you may want to redirect the output from gprof, as follows:

    $ gprof prog >gprof.out

    The flat profile lists the number of times each subprogram was called and the percentage of the total execution time for each of the subprogram times. The call graph profile includes such information as the index of the function in the call graph listing, the percentage of total time of the program accounted for by a routine and its descendents, and the number of seconds spent in the routine itself.

  4. Once gprof is finished, you can view the output tables using an ASCII editor.

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

prof

The prof profiler can also be used for profiling. Unlike the gprof profiler, 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.out
    mon.out
  3. Run prof, giving the name of the program as an argument, as follows:

    $ prof prog

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

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

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.