Optimizing XL Fortran Programs

Partial Table-of-Contents

  • The Philosophy of XL Fortran Optimizations
  • Summary of Compiler Options for Optimization
  • Choosing an Optimization Level
  • Optimization Level -O2
  • Optimization Level -O3
  • Getting the Most out of -O2 and -O3
  • The -O4 and -O5 Options
  • Optimizing for a Target Machine or Class of Machines
  • Getting the Most out of Target Machine Options
  • Optimizing Floating-Point Calculations
  • High-order Transformations (-qhot)
  • Getting the Most out of -qhot
  • Optimizing Loops and Array Language
  • Cost Model for Loop Transformations
  • Unrolling Loops
  • Describing the Hardware Configuration
  • Efficiency of Different Array Forms
  • Reducing Use of Temporary Arrays
  • Array Padding
  • Profile-directed Feedback (PDF)
  • Using Profile-directed Feedback (PDF)
  • Optimizing Conditional Branching
  • Interprocedural Analysis (-qipa)
  • Getting the Most from -qipa
  • Optimizing Subprogram Calls
  • Finding the Right Level of Inlining
  • Shared-memory Parallelism (-qsmp)
  • Getting the Most out of -qsmp
  • Other Program Behavior Options
  • Other Performance Options
  • Debugging Optimized Code
  • Different Results in Optimized Programs
  • Compiler-friendly Programming
  • This section provides background information on optimization, guidance on using XL Fortran's optimization features, and details of some XL Fortran optimization techniques.

    Simple compilation is the translation or transformation of the source code into an executable or shared object. An optimizing transformation is one that gives your application better overall performance at run time. XL Fortran provides a portfolio of optimizing transformations tailored to the IBM hardware. These transformations can:

    Significant performance improvements are possible with relatively little development effort because the compiler is capable of widely applicable and sophisticated program analysis and transformation. Moreover, the compilers enable programming models such as OpenMP, which allow you to write high-performance code.

    Optimizations are intended for later phases of application development cycles, such as product release builds. If possible, you should test and debug your code without optimization before attempting to optimize it.

    Optimization is controlled by compiler options and directives. However, compiler-friendly programming idioms can be as useful to performance as any of the options or directives. It is no longer necessary nor is it recommended to excessively hand-optimize your code (for example, manually unrolling loops). Unusual constructs can confuse the compiler (and other programmers), and make your application difficult to optimize for new machines. The section Compiler-Friendly Programming contains some suggested idioms and programming tips for writing good optimizable code.

    It should be noted that not all optimizations are beneficial for all applications. A trade-off usually has to be made between an increase in compile time accompanied by reduced debugging capability and the degree of optimization done by the compiler. IBM Copyright 2003