Search code examples
c++gccinlineicc

Intel compiler inline size


I have been compiling my code for some time with g++ and then moved to Intel's icpc compiler. With icpc I kept getting the following warnings:

remark #11074: Inlining inhibited by limit max-size 
remark #11074: Inlining inhibited by limit max-total-size 

I never had this problem with g++. After some research, I understood that I can compile with -no-inline-max-total-size and -no-inline-total-size to avoid limits on inlining size. My question is whether it is always a good practice to remove sizes on inlining and inline as much as possible? My code is computation heavy and performance is key, therefore my common sense dictates that I should allow as much inlining as possible for the compiler. Is that true? Are there situations at all where imposing an inlining limit is useful?


Solution

  • My question is whether it is always a good practice to remove sizes on inlining and inline as much as possible?

    No, it is not always a good pratice to remove size limits on inlining nor to inline as much as possible.

    Ideally, inlining should be done only when it improves performance.

    Are there situations at all where imposing an inlining limit is useful?

    If a function is very large, and it is called from many contexts, then inlining such function to all of those contexts will bloat the executable. If the executable itself is let's say several gigabytes because of inlining, then loading the program from the disk may become the bottleneck.

    In less pathological cases, the trade-offs are more subtle. The way to find out optimal limits is measurement. Profile guided optimisation can give the optimiser more useful heuristics than simple hard limits.