HP aC++/HP C A.06.25 Programmer's Guide

These steps are involved in performing profile-based optimization:
1. Instrumentation
2. Collecting Data for Profiling
3. Maintaining Profile Data Files
4. Performing Profile-Based Optimization
Instrumentation
To instrument your program, use the +Oprofile=collect option as follows:
aCC +Oprofile=collect -O -c sample.C
aCC +Oprofile=collect -O -o sample.exe sample.o
The first command line uses the +Oprofile=collect option to prepare the code for
instrumentation. The -c option in the first command line suppresses linking and creates
an object file called sample.o.
The second command line uses the -o option to link sample.o into sample.exe.
The +Oprofile=collect option instruments sample.exe with data collection code.
NOTE: Instrumented programs run slower than non-instrumented programs. Only
use instrumented code to collect statistics for profile-based optimization.
Collecting Data for Profiling
To collect execution profile statistics, run your instrumented program with
representative data as follows:
sample.exe < input.file1
sample.exe < input.file2
This step creates and logs the profile statistics to a file, by default called flow.data.
The data collection file is a structured file that may be used to store the statistics from
multiple test runs of different programs that you may have instrumented.
Maintaining Profile Data Files
Profile-based optimization stores execution profile data in a disk file. By default, this
file is called flow.data and is located in your current working directory.
You can override the default name of the profile data file. This is useful when working
on large programs or on projects with many different program files.
The FLOW_DATA environment variable can be used to specify the name of the profile
data file with either the +Oprofile=collect or +Oprofile=use options.
The +Oprofile=use:filename command line option can be used to specify the
name of the profile data file when used with the +Oprofile=use option.
Requesting Optimization 209