HP Fortran Programmer's Guide (B3908-90031; September 2011)

Performance and optimization
Using profilers
Chapter 6 143
Using profilers
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 HP Caliper performance analysis tool, which is bundled with
HP Fortran as well as the two UNIX profilers, gprof and prof.
NOTE As described in “Stripping debugging information” on page 119, all programs compiled by
HP Fortran 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.
HP Caliper
HP Caliper works with your compiler to perform Profile Based Optimization (PBO).
The compiler option +Oprofile=collect uses HP Caliper in the background to collect profile
information for your entire application. This is equivalent to the +I option on HP PA-RISC systems.
Invoking HP Caliper with the compiler to optimize your program
The simplest way to use HP Caliper is to use the PBO mode to create a flow-data file that the compiler can
use to further optimize your program.
Step 1. Compile your program with the +Oprofile=collect option.
/opt/ansic/bin/cc -Aa +O3 -o program +Oprofile=collect program.c
The loader sets a run-time flag on the program to automatically invoke HP Caliper.
HP Caliper supports programs compiled with any compiler option. When you use the
+Oprofile=collect option, however, the compiler forces +01 optimization to fully measure
the program performance.
Step 2. Run your program to generate the flow-data file.
program [program_arguments]