[Beowulf] Re: Stroustrup regarding multicore

Perry E. Metzger perry at piermont.com
Tue Aug 26 15:52:35 PDT 2008

"David Mathog" <mathog at caltech.edu> writes:
> Alan Louis Scheinine <alscheinine at tuffmail.us> wrote:
>> I forgot to mention, function calls in Fortran, C or C++ seem to kill
> efficiency,
> That's pretty much true for any language when those calls are inside
> inner loops.  There are exceptions though - inlined functions in C with
> a "good" compiler will not have the call overhead because the compiler
> will just replicate the code in place and compile it there.  It is not a
> good thing to depend on though, since some other compiler may not be
> able to pull off the same trick.

If you're going to think that way, you can't guarantee that any two
Fortran compilers will optimize the same way, either.

Generally, inline gets respected by modern compilers because people
very much expect that inline means what it says and are expecting the
same sort of performance you would get from a macro. I haven't heard
of a compiler that doesn't do it correctly, though of course one may

> So in general it is usually best, if your goal is to have the code
> run fast everywhere, to locate such compute intensive loops (with
> valgrind, or whatever) and squeeze the function overhead out of
> them.

gprof or a similar profiling tool is actually the right thing here.

Generally, though, when I find a hot spot in code, my first
inclination is to check my algorithm first, microoptimize second...

Perry E. Metzger		perry at piermont.com

More information about the Beowulf mailing list