User`s guide

Cray XMT Programming Environment Users Guide
7.4 Inlining Functions
Inline expansion, commonly known as inlining, occurs when the compiler replaces a
function reference with the body of the function. The advantages to using inlining
include a reduction in memory usage due to the removal of function calls and returns,
and the possibility of optimizing code near the function call with the function body.
The disadvantages include an increase in the size of the executable and an increase
in the level of complexity required during debugging.
When compiling in separate-module mode, the compiler inlines functions that
are defined in the same file where they are referenced. When compiling in
whole-program mode, the compiler can inline any function in the program or
associated libraries. To view functions that are inlined, use the canal or Apprentice2
performance tools. See Cray XMT Performance Tools User's Guide.
You can use either command-line switches or compiler directives to control how
the compiler inlines functions.
To set inlining from the command line, you can use either the -inline fcn to force
the compiler to inline a specified function or -no_inline fcn to suppress inlining
for the specified function. The option -no_inline_all suppresses inlining for all
functions in a program.
For C++, the function name fcn must use the mangled-name format. Mangled names
are internal compiler names with complete type signatures. To do this, use the
following command format.
-inline mangledfunctionname
To obtain the character string for the mangled name, use the nm -f command.
To set inlining using a directive in your C or C++ program, you can add pragma
statements that require or prohibit inlining of individual functions. To do this, use
one of the following directives.
#pragma mta inline
#pragma mta no inline
You must place one of the previous directives immediately before the function's
definition in your program.
The C++ keyword inline also inlines a function, but it makes the function local
to the file. In this case, if you also add the function's definition to the header file,
multiple inclusions would result in many copies of this function being added to the
program library. Therefore, the use of the pragma directive is usually preferable to
the C++ keyword.
84 S247920