(j3.2006) Chaining type-bound procedure references

Tobias Burnus burnus
Fri May 2 15:35:49 EDT 2014


Rafik Zurob wrote:
>> Does C++ require inlining in these scenarios? Many of the examples 
>> I've seen using iterators, would have bar() be a rather involved 
>> function that would be very awkward to inline. 
> Sorry, I wasn't clear.  I don't want to inline bar().  I would like to
> inline foo().  It's not a language requirement, but it's allowed and is
> often done for small functions.  My point is that C++ makes it easy to
> inline foo (if it makes sense to inline it).  Fortran does not.

Depends how one compiles the code. Using link-time optimization (LTO, 
also known as whole-program inter-procedure optimization), that's surely 
possible with Fortran.

And some compilers (I know of at least one commercial one) automatically 
do it when using modules - even without a special flag. (Well, in that 
case, it helps that the module information is stored directly in the .o 
files with that compiler, allowing a one-to-one correspondence between 
module information and binary.)

Otherwise, I concur that without LTO and without a compiler which does 
such an optimization, small function's placed in different files won't 
be inlined in Fortran. As LTO hasn't really caught on with the users, 
that's surely a problem. (And if one does many edit-compile cycles, LTO 
can slow down the compilation quite a bit.)

Tobias



More information about the J3 mailing list