Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Pascal/HP-UX Release Notes: HP 9000 Series Systems > Chapter 1 New and Changed Features

Profile-Based Optimization (PBO)

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

Profile-based optimization (PBO) is a set of code-improving transformations that are based on feedback concerning the run-time characteristics of an application. Run-time profile data is collected during program execution. This information is fed back to the optimizer, which performs a variety of optimizations based upon how frequently certain code is executed and how frequently calls are made between different code segments. In general, each higher level of optimization takes increasing advantage of the PBO-generated information.

One of the goals of PBO is to improve the efficiency of memory access by increasing the hit rates for the instruction cache, memory pages, and the Translation Lookaside Buffer (TLB). PBO can also improve the compiler's inlining decisions. One basis for the decision is call frequency, which, without PBO, the compiler can only estimate. With PBO, however, the compiler uses actual frequencies as the basis for its decision.

For complete details on PBO, see HP-UX Linker and Libraries Online User Guide.

NOTE: HP Pascal/HP-UX is limited to procedure repositioning, not basic block repositioning.

Invoking PBO

You must perform the following steps to invoke PBO:

  1. Compile and link with the +I option to produce the instrumented program.

  2. Collect execution profile statistics by running the instrumented program.

  3. Optimize the program with the +P option.

Instrumenting the Program

To instrument the program, use the +I compile-line option when compiling and linking the object files of an application. Instrumenting the program inserts code into the program to collect execution profile statistics. Execution profile statistics include a count of the calls between procedures. Also, note that when you use the +I compile-line option to compile source files, instrumentation can be added within the code for each subroutine in that file.

In the following example, the source file sample.p is compiled, instrumented, and linked into sample.inst:

pc -o sample.inst -O +I sample.p 

Collecting Execution Profile Statistics

To collect execution profile statistics, run your program using reasonably representative data. The profile database file, flow.data, is created the first time the program is run, and is updated for each subsequent execution of the program.

The following example collects execution profile statistics by running the sample.inst program with representative data from two input files:

sample.inst < input.file1
sample.inst < input.file2

This step, by default, logs the profile statistics in a file called flow.data. See “Maintaining Multiple Profile Data Files ” to change this default.

Optimizing the Program

To perform PBO, re-link the program with the +P compile-line option to specify that you wish to use the collected profile data:

pc -o sample.opt -O +P +pgm sample.inst sample.o

The +pgm compile-line option allows you to specify an executable name that is different from the current output file name. In the preceding command line, the +pgm option indicates that the name of the instrumented executable (sample.inst) differs from the name of the optimized executable (sample.opt) that is specified with the -o option.

Source files compiled with the +I option do not need to be recompiled after collecting the profile data. Simply relink the application with the same options that you used in the first step to instrument the program, but replace +I with +P. For more information about how the compiler and linker work together to perform profile based-optimizations, refer to HP-UX Linker and Libraries Online User Guide.

Maintaining Multiple Profile Data Files

By default, PBO logs the profile statistics in a file called flow.data. You can specify another name with the +df compile-line option.

The name of the executable file used during profiling is the name under which the profile data is stored in the database file. If you specify a different executable output file name during the optimization phase, you need to use the +pgm option to specify the program name used during profiling. The following steps and example demonstrate the use of +df and +pgm.

  1. Rename flow.data after performing the data collection step described previously:

    mv flow.data sample.data
  2. Perform PBO on this application by re-linking the program as follows:

    pc -o sample.opt -O +P +pgm sample.inst +df sample.data sample.o

    The default value for the +df compile-line option is flow.data. The +df option is used because the profile data file for the program has been moved from flow.data to sample.data.

    The +pgm option is used because the instrumented program file is sample.inst, and the optimized program file is sample.opt.

    You can also use the FLOW_DATA environment variable to specify a different path name for the profile database file. Note, however, that the +df compile-line option takes precedence over the FLOW_DATA environment variable. For more information about the profile database and the FLOW_DATA environment variable, see HP-UX Linker and Libraries Online User Guide.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1994 Hewlett-Packard Development Company, L.P.