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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

-qpdf Option<br />

Syntax<br />

-qpdf{1|2}<br />

Tunes optimizations through profile-directed feedback (PDF), where results from<br />

sample program execution are used to improve optimization near conditional<br />

branches and in frequently executed code sections.<br />

To use PDF, follow these steps:<br />

1. Compile some or all of the source files in a program with the -qpdf1 option.<br />

You need to specify the -O2 option, or preferably the -O3, -O4, or -O5 option,<br />

<strong>for</strong> optimization. Pay special attention to the compiler options that you use to<br />

compile the files, because you will need to use the same options later.<br />

In a large application, concentrate on those areas of the code that can benefit<br />

most from optimization. You do not need to compile all of the application’s<br />

code with the -qpdf1 option.<br />

2. Run the program all the way through using a typical data set. The program<br />

records profiling in<strong>for</strong>mation when it finishes. You can run the program<br />

multiple times with different data sets, and the profiling in<strong>for</strong>mation is<br />

accumulated to provide an accurate count of how often branches are taken and<br />

blocks of code are executed.<br />

Important: Use data that is representative of the data that will be used during<br />

a normal run of your finished program.<br />

3. Relink your program using the same compiler options as be<strong>for</strong>e, but change<br />

-qpdf1 to -qpdf2. Remember that -L, -l, and some others are linker options, and<br />

you can change them at this point. In this second compilation, the accumulated<br />

profiling in<strong>for</strong>mation is used to fine-tune the optimizations. The resulting<br />

program contains no profiling overhead and runs at full speed.<br />

For best per<strong>for</strong>mance, use the -O3, -O4, or -O5 option with all compilations when<br />

you use PDF (as in the example above). If your application contains C or C++ code<br />

compiled with <strong>IBM</strong> <strong>XL</strong> C/C+ compilers, you can achieve additional PDF<br />

optimization by specifying the -qpdf1 and -qpdf2 options available on those<br />

compilers. Combining -qpdf1/-qpdf2 and -qipa or -O5 options (that is, link with<br />

IPA) on all <strong>Fortran</strong> and C/C++ code will lead to maximum PDF in<strong>for</strong>mation being<br />

available <strong>for</strong> optimization.<br />

Rules<br />

The profile is placed in the current working directory or in the directory that the<br />

PDFDIR environment variable names, if that variable is set.<br />

To avoid wasting compilation and execution time, make sure that the PDFDIR<br />

environment variable is set to an absolute path. Otherwise, you might run the<br />

application from the wrong directory, and it will not be able to locate the profile<br />

data files. When that happens, the program may not be optimized correctly or may<br />

be stopped by a segmentation fault. A segmentation fault might also happen if you<br />

change the value of the PDFDIR variable and execute the application be<strong>for</strong>e<br />

finishing the PDF process.<br />

Background In<strong>for</strong>mation<br />

Because this option requires compiling the entire application twice, it is intended<br />

to be used after other debugging and tuning is finished, as one of the last steps<br />

be<strong>for</strong>e putting the application into production.<br />

210 <strong>XL</strong> <strong>Fortran</strong> <strong>Enterprise</strong> <strong>Edition</strong> <strong>for</strong> <strong>AIX</strong> : User’s <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!