Option Type | Default Value | #pragma options | C | C++ |
-qoption | nopdf1 nopdf2 |
- | x | x |
Syntax
-qpdf1 | -qpdf2 | -qnopdf1 | -qnopdf2
Purpose
Tunes optimizations through Profile-Directed Feedback (PDF),
where results from one or more sample program executions are used
to improve optimization near conditional branches and in
frequently executed code sections.
Notes
To use PDF:
Important: Use data that is representative of the data that will be used during a normal run of your finished program.
For optimum performance, use the -O3 option with all compilations when you use PDF (as in the example above). With -O2 optimization, one of the most important PDF optimizations (moving code before branches to fill delay slots) is not done.
The profile is placed in the current working directory, or the directory named by the PDFDIR environment variable if that variable is set.
To avoid wasting compilation and execution time, make sure the PDFDIR environment variable is set to an absolute path; otherwise, you might run the application from the wrong directory so that it cannot locate the profile data files. If that happens, the program may not be optimized correctly or may be stopped by a segmentation fault. A segmentation fault might also happen if you change the value of the PDFDIR variable and execute the application before finishing the PDF process.
Because this option requires compiling the entire application twice, it is intended to be used after other debugging and tuning is finished, as one of the last steps before putting the application into production.
Restrictions
The following commands are available for managing the PDFDIR directory:
resetpdf [pathname] | Zeros out all profiling information (but
does not remove the data files) from the pathname
directory; or if pathname is not specified, from the PDFDIR
directory; or if PDFDIR is not set, from
the current directory. When you make changes to the application and recompile some files, the profiling information for those files is automatically reset, because the changes may alter the program flow. Run resetpdf to reset the profiling information for the entire application, after making significant changes that may affect execution counts for parts of the program that were not recompiled. |
cleanpdf [pathname] | Removes all profiling information from
the pathname directory; or if pathname is not specified,
from the PDFDIR directory; or if PDFDIR
is not set, from the current directory. Removing the profiling information reduces the runtime overhead if you change the program and then go through the PDF process again. Run this program after compiling with -qpdf2, or after finishing with the PDF process for a particular application. If you continue using PDF with an application after running cleanpdf, you must recompile all the files with -qpdf1. |
Example 1
Here are the steps for a simple example:
The program should now run faster than without PDF, if the sample used data was typical of actual program data.
Note: When using -qpdf1, specify the search location for its libraries with the -L compiler option, as shown in step 2 above.
Example 2
Here are the steps for a more elaborate example.
List of Compiler Options and Their
Defaults
Options that Define the Compiler Object
Code Produced