While automatic inlining is the best choice the compiler can make
for you, you can further improve your performance. Use
#pragma inline and
#pragma
noinline to reduce the need to modify your inlining choices when
you change your application. You may want to wait until you have a
stable application before you do the following steps.
- Compile with the OPTIMIZE option and ask for a report from the
inliner by specifying the compiler options INLINE(,REPORT,,) or INLRPT
and OPTIMIZE.
- Look at the report to see if anything was inlined that should
not have been; for example, routines for debugging or handling exceptions.
Add #pragma noinline to your source to
insure that these functions do not get inlined.
- Add the inline keyword (for C++) or the #pragma inline directive (for C) to any frequently
used routines to ensure that it gets inlined.
- Recompile with OPTIMIZE then, regenerate the inline report and
reanalyze for functions that should and should not be inlined.
- You should also vary the limit and threshold values.
- The inline report tells you the abstract code units (ACUs) for
each function. These should help you determine an appropriate threshold to
start from. In general, your initial threshold should be
as small as possible, and your initial limit should be in the 1000
to 2000 range.
- Increase the threshold by an increment small enough to
catch a few more routines each time.
- Change the limit when you wish. Because performance will improve
as a function of both the limit and the threshold values,
it is not recommended that you change both limit and threshold at
the same time.
- Repeat the process until you feel that you have found the best
performance parameters. You should run your application to determine
if the tuning has found the best performance parameters.
- When you are satisfied with the selection of inlined routines,
add the appropriate #pragma inline directives
or inline keywords to the source. That is, when the selected
routines are forced with these directives, you can then compile the
program in selective mode. This way, you do not need to be affected
by changes made to the heuristics used in the automatic inliner.