[vtk-developers] vtkMath inline choices...

Sean McBride sean at rogue-research.com
Wed Sep 15 11:42:27 EDT 2010


On Wed, 15 Sep 2010 09:24:14 -0600, Moreland, Kenneth said:

>I can speak to why IsNan is not inlined.  The IsNan (and similar non-
>finite tests) rely on some non-portable functionality.  Depending on
>whether the isnan function is provided, IEEE-754 numbers are used, or if
>operations on NaNs are trapped, different implementations are provided. 
>Over time this can get even more complicated as we encounter computers
>and compilers that treat NaNs differently.  Quite simply, I did not want
>to expose all of this complexity in the header file.

Ken,

Thanks for your informative reply.

There are systems VTK supports that don't use IEEE-754 numbers?  Didn't
know that... Out of curiosity, which?

Similarly, where would VTK_HAS_ISNAN be 0?  I was kinda hoping it was
only with old compilers for which support was recently dropped. :)

>If you plan to go through the trouble of moving that to the header file,
>you should do performance tests to make sure that there is a clear
>advantage to inlining the function.

Certainly.  As I said, I am in the middle of doing many profiling tests.

>I've been surprised in the past to
>find an inline function did not really perform any better than a
>function call.  The fact of the matter is that function calls are cheap
>operations nowadays.

And inlining can make code bigger, and thus bloat caches.  Certainly
there are trade offs.  And making something faster in one usage can make
it slower in another.  Optimisation in the general case is tricky with a
general and portable framework like VTK. :(

OTOH, marking a method inline only makes it eligible for inline, it's
not an obligation.  One hopes that the compiler can make a good decision.

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada





More information about the vtk-developers mailing list