HP aC++/HP C A.06.20 Programmer's Guide
aCC +Oprofile=use -O sample.C -o sample.exe
// Recompile with optimization.
• Numerical applications which perform the same calculations independent of the
input data will only see a small performance boost.
• Profile-based optimization has the greatest impact on application performance
when used with level 2 or greater optimizations.
• Profile-based optimization benefits most applications, especially large applications
with multiple compilation units, such as compilers, editors, database managers,
and user interface managers.
• Profile-based optimization should be enabled during the final stages of application
development. To obtain the best performance, reprofile and reoptimize your
application after making source code changes.
There are three steps involved in performing profile-based optimization:
1. Instrumentation
2. Collecting Data for Profiling
3. 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 -O option to perform level 2 optimization and the
+Oprofile=collect option to prepare the code for instrumentation.
(+Oprofile=collect generates intermediate code.) The -c option in the first
command line suppresses linking and creates an intermediate object file called
sample.o. The .o file can be used later in the optimization phase, avoiding a second
compile.
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.
Instrumenting Code at Level 4 Optimization
When optimizing at level 4, (where code generation is delayed until link time), use the
+Oprofile=collect option as follows:
aCC +Oprofile=collect +O4 -c x.C y.C
aCC +Oprofile=collect +O4 x.o y.o
Requesting Optimization 205