[vtk-developers] vtkMath inline choices...

Moreland, Kenneth kmorel at sandia.gov
Mon Jan 31 13:17:35 EST 2011


Since we are talking about inlining vtkMath::IsNaN anyway, why not just provide overloaded inlined functions for integer types that always return false?  That way the compiler removes the check for you without having to write any type-dependent case code.

-Ken


On 1/30/11 11:24 AM, "David Gobbi" <david.gobbi at gmail.com> wrote:

Hi Ken,

The main issue with performance and IsNan() is more about how it is used than about whether it is inlined.  My guess is that Sean saw a performance hit because IsNan() was used inside vtkLookupTable, which has some of the hottest loops in all of VTK.  The IsNan() check was applied to all datatypes, even though it is not relevant for integer data.

I've patched vtkLookupTable so that it overloads vtkLinearLookup() and the IsNan check is only done on float and double.  The new code gives me a 40% speedup in color mapping a 16-bit image to RGBA.  The patch can be seen here: http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=1c348fcb.  I merged it directly into master.

There is also a function in vtkScalarsToColorsPainter that applies IsNan() regardless of scalar type.  It could benefit from a similar patch.

 - David



   ****      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/20110131/5f83cb7b/attachment.html>


More information about the vtk-developers mailing list