24.05.2014 Views

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Profile-directed Feedback (PDF)<br />

Profile-directed feedback is a two-stage compilation process that lets you provide<br />

the compiler with data characteristic of typical program behavior. An instrumented<br />

executable is run in a number of different scenarios <strong>for</strong> an arbitrary amount of<br />

time, producing as a side effect a profile data file. A second compilation using the<br />

profile data produces an optimized executable.<br />

PDF should be used mainly on code that has rarely executed conditional error<br />

handling or instrumentation. The technique has a neutral effect in the absence of<br />

firm profile in<strong>for</strong>mation, but is not recommended if insufficient or uncharacteristic<br />

data is all that is available.<br />

The following diagram illustrates the PDF process.<br />

Source<br />

code<br />

Compile with<br />

-qpdf1<br />

Instrumented<br />

executable<br />

Compile with<br />

-qpdf2<br />

Sample runs<br />

Profile data<br />

Optimized<br />

executable<br />

The two stages of the process are controlled by the compiler options -qpdf1 and<br />

-qpdf2. Stage 1 is a regular compilation using an arbitrary set of optimization<br />

options and -qpdf1, that produces an executable or shared object that can be run in<br />

a number of different scenarios <strong>for</strong> an arbitrary amount of time. Stage 2 is a<br />

recompilation using the same options, except -qpdf2 is used instead of -qpdf1,<br />

during which the compiler consumes previously collected data <strong>for</strong> the purpose of<br />

path-biased optimization.<br />

Using Profile-directed Feedback (PDF)<br />

You can optimize an application based on an analysis of how often it executes<br />

different sections of code, as follows:<br />

1. Compile the application with -qpdf1.<br />

2. Run the application using a typical data set or several typical data sets. When<br />

the application exits, it writes profiling in<strong>for</strong>mation in the PDF file.<br />

3. Compile the application with -qpdf2.<br />

If you want to see which functions are used the most often, do the following:<br />

1. Compile the application with -qpdf1 -qshowpdf.<br />

2. Run the application using a typical data set or several typical data sets. The<br />

application writes more detailed profiling in<strong>for</strong>mation in the PDF file.<br />

3. Use the showpdf utility to view the in<strong>for</strong>mation in the PDF file.<br />

You can take more control of the PDF file generation, as follows:<br />

1. Compile the application with -qpdf1.<br />

Optimizing <strong>XL</strong> <strong>Fortran</strong> Programs 315

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!