Example 1

In the following example, the FLOW_DATA environment variable is used to override the flow.data file name. The profile data is stored instead in /users/profiles/prog.data.

export FLOW_DATA=/users/profiles/prog.data aCC -c +Oprofile=collect sample.C

aCC -o sample.exe +Oprofile=collect sample.o sample.exe < input.file1

aCC -o sample.exe +Oprofile=use +O3 sample.C

Example 2

In this example, the +Oprofile=use:filename option is used to override the flow.data file name with the name /users/profiles/prog.data.

aCC -c +Oprofile=collect +O3 sample.C

aCC -o sample.exe +Oprofile=collect sample.o sample.exe < input.file1

mv flow.data /users/profile/prog.data

aCC -o sample.exe +Oprofile=use:/users/profiles/prog.data +O3 sample.C

Performing Profile-Based Optimization

To optimize the program based on the previously collected runtime profile statistics, recompile the program as follows:

aCC -o sample.exe +Oprofile=use +O3 sample.C

For more information on profile-based optimization, refer to the HP-UX Online Linker and Libraries User’s Guide.

Pragmas That Control Optimization

Compiler options provide a high-level, global approach to optimization. To give you more refinement in optimization, HP aC++ provides pragma OPT_LEVEL.

See “Optimization Pragmas” (page 103) for more information.

160 Optimizing HP aC++ Programs