Object level profile-directed feedback

About this task

In addition to optimizing entire executables, profile-directed feedback (PDF) can also be applied to specific objects. This can be an advantage in applications where patches or updates are distributed as object files or libraries rather than as executables. Also, specific areas of functionality in your application can be optimized without you needing to go through the process of relinking the entire application. In large applications, you can save the time and trouble that otherwise need to be spent relinking the application.

The process for using object level PDF is essentially the same as the standard PDF process but with a small change to the -qpdf2 step. For object level PDF, compile your application using -qpdf1, execute the application with representative data, compile the application again with -qpdf2 but now also use the -qnoipa option so that the linking step is skipped.

The steps below outline this process:
  1. Compile your application using -qpdf1. For example:
    xlc -c -O3 -qpdf1 file1.c file2.c file3.c
    In this example, we are using the option -O3 to indicate that we want a moderate level of optimization.
  2. Link the object files to get an instrumented executable.
    xlc -O3 -qpdf1 file1.o file2.o file3.o
    Note: you must use the same optimization options. In this example, the optimization option -O3.
  3. Run the instrumented executable with sample data that is representative of the data you want to optimize for.
    a.out < sample_data
  4. Compile the application again using -qpdf2. Specify the -qnoipa option so that the linking step is skipped and PDF optimization is applied to the object files rather than to the entire executable. Note: you must use the same optimization options as in the previous steps. In this example, the optimization option -O3.
    xlc -c -O3 -qpdf2 -qnoipa file1.c file2.c file3.c
    The resulting output of this step are object files optimized for the sample data processed by the original instrumented executable. In this example, the optimized object files would be file1.o, file2.o, and file3.o. These can be linked using the system loader ld or by omitting the -c option in the -qpdf2 step.
Notes:
  • If you want to specify a file name for the profile that is created, use the pdfname suboption in both the -qpdf1 and -qpdf2 steps. For example:
    xlc -O3 -qpdf1=pdfname=myprofile file1.c file2.c file3.c
    Without the pdfname suboption, by default the file name is ._pdf; the location of the file is the current working directory or whatever directory you have set using the PDFDIR environment variable.
  • Because -qnoipa needs to be specified in the -qpdf2 step so that linking of your object files is skipped, you are not able to use interprocedural analysis (IPA) optimizations and object level PDF at the same time.

For details, see -qpdf1, -qpdf2.