[vtk-developers] vtkMath inline choices...

Moreland, Kenneth kmorel at sandia.gov
Wed Sep 15 12:04:10 EDT 2010


I don't know of any systems we are currently running on that don't use IEEE-754 numbers, but it's a bad idea to assume that they are.  There is nothing in any compiler standard specifying the bit layout of floating point numbers.

I can't remember what dashboards didn't have the isnan function, but there definitely were some at the time I write the vtkMath functions (which was not that long ago).  The isnan function was relatively recently added to the C standard (C99), so I would expect to run into non-conforming compilers for some time.

-Ken


On 9/15/10 9:42 AM, "Sean McBride" <sean at rogue-research.com> wrote:

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






   ****      Kenneth Moreland
    ***      Sandia National Laboratories
***********
*** *** ***  email: kmorel at sandia.gov
**  ***  **  phone: (505) 844-8919
    ***      web:   http://www.cs.unm.edu/~kmorel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100915/f02116ed/attachment.html>


More information about the vtk-developers mailing list