HP Fortran Programmer Guide (766160-001, March 2014)
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.
Compile your program with the +Oprofile=collectoption.
/opt/ansic/bin/cc -Aa +O3 -o program +Oprofile=collect
program.c
Step 1.
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=collectoption, however, the compiler forces
+01optimization to fully measure the program performance.
Run your program to generate the flow-data file.
program[program_arguments]
Step 2.
HP Caliper automatically runs to generate the flow-data information in a file
namedflow.data in the current directory.
You can repeat this step multiple times with different program_arguments to create
aggregated profile information in the flow.datafile to improve your program’s
optimization.
If the flow.datafile already exists in the current directory when you run your
program, then HP Caliper merges the results into the file. If you run your program
multiple times in different directories, then HP Caliper creates a separate flow.data
file in each directory. You can combine the files using the fdm(1)utility program,
which is bundled with the HP C, HP aC++, and Fortran 90 compilers.
When collecting PBO data, the more your program use scenarios resemble the
ways in which your program will actually be used, the more the compiler can
optimize your program specifically for how it is actually used.
When you make changes to your source files, you should delete the flow.data
file before collecting more PBO data on your program.
Use the flow.datafile as input to the compiler when you specify the
+Oprofile=use option on subsequent re-compiles.
/opt/ansic/bin/cc -Aa +O3 -o program +Oprofile=use program.c
Step 3.
The compiler uses the HP Caliper information to help optimize your program.
Note that the benefit of profile-based optimization is application dependent. Some
programs may not improve while others may improve significantly.
Comparing Program Performance
You can use HP Caliper’s other measurement features to explicitly see the results of using PBO.
An example process for comparing performance would be:
1. Compile your program with +Oprofile=collectto generate the executable to optimize.
2. Run your program to generate the profile data file. Use as many use scenarios as possible to
collect representative profile data.
3. Compile your program with +O3to generate the baseline executable to compare against the
fully optimized executable.
4. Run HP Caliper on your +O3executable with a configuration file such as total_cputo measure
performance.
5. Recompile your program with +O3optimization and +Oprofile=useto use the profile data
collected in Step 2 as input.
6. Run HP Caliper on your fully optimized executable from Step 5 with the same configuration
file from Step 4 and compare the report results with the report from Step 4.
88 Performance and optimization