Download PGI Compiler User`s Guide

Transcript
Chapter 4.
USING FUNCTION INLINING
Function inlining replaces a call to a function or a subroutine with the body of the function
or subroutine. This can speed up execution by eliminating parameter passing and function/
subroutine call and return overhead. It also allows the compiler to optimize the function with the
rest of the code. Note that using function inlining indiscriminately can result in much larger code
size and no increase in execution speed.
The PGI compilers provide two categories of inlining:
‣
‣
Automatic inlining - During the compilation process, a hidden pass precedes the
compilation pass. This hidden pass extracts functions that are candidates for inlining. The
inlining of functions occurs as the source files are compiled.
Inline libraries - You create inline libraries, for example using the pgfortran compiler driver
and the –o and –Mextract options. There is no hidden extract pass but you must ensure
that any files that depend on the inline library use the latest version of the inline library.
There are important restrictions on inlining. Inlining only applies to certain types of functions.
Refer to Restrictions on Inlining for more details on function inlining limitations.
This section describes how to use the following options related to function inlining:
–Mextract
–Minline
–Mrecursive
4.1. Invoking Function Inlining
To invoke the function inliner, use the -Minline option. If you do not specify an inline library,
the compiler performs a special prepass on all source files named on the compiler command
line before it compiles any of them. This pass extracts functions that meet the requirements for
inlining and puts them in a temporary inline library for use by the compilation pass.
Several -Minline suboptions let you determine the selection criteria for functions to be inlined.
These suboptions include:
PGI Compiler User's Guide
51