Kenwood HP 9000 Personal Computer User Manual


 
Chapter 8 285
Ways to Improve Performance
Profile-Based Optimization
Specifying a Different Program Name (+pgm)
When retrieving a program's profile data from the flow.data file, the
linker uses the program's basename as a lookup key. For instance, if a
program were compiled as follows, the linker would look for the profile
data under the name foobar:
$ cc -v -o foobar +P foo.o bar.o
/usr/ccs/bin/ld /usr/ccs/lib/crt0.o -u main -o foobar \
foo.o bar.o -P -lc
This works fine as long as the name of the program is the same during
the instrumentation and optimization phases. But what if the name of
the instrumented program is not the same as name of the final optimized
program? For example, what if you want the name of the instrumented
application to be different from the optimized application, so you use the
following compiler commands?
$ cc -O +I -o prog.inst prog.c Instrument prog.inst.
$ prog.inst < input_file1 Profile it, storing the data
under the name prog.inst.
$ prog.inst < input_file2
$ cc +P -o prog.opt prog.c Optimize it, but name it prog.opt.
The linker would be unable to find the program name prog.opt in the
flow.data file and would issue the error message:
No profile data found for the program prog.opt in flow.data
To get around this problem, the compilers and linker provide the +pgm
name option, which allows you to specify a program name to look for in
the flow.data file. For instance, to make the above example work
properly, you would include +pgm prog.inst on the final compile line:
$ cc +P -o prog.opt +pgm prog.inst prog.c
Like the +df option, the +pgm option is passed directly to the linker.
Selecting an Optimization Level with PBO
When -P is specified, the code generator and linker perform profile-based
optimizations on any I-SOM or regular object files found on the linker
command line. In addition, optimizations will be performed according to
the optimization level you specified with a compiler option when you
instrumented the application. Briefly, the compiler optimization options
are:
+O0 Minimal optimization. This is the default.
+O1 Basic block level optimization.