<HTML>
<HEAD>
<TITLE>Re: [vtk-developers] vtkMath inline choices...</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>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.<BR>
<BR>
-Ken<BR>
<BR>
<BR>
On 1/30/11 11:24 AM, "David Gobbi" <<a href="david.gobbi@gmail.com">david.gobbi@gmail.com</a>> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Hi Ken,<BR>
<BR>
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.<BR>
<BR>
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: <a href="http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=1c348fcb">http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=1c348fcb</a>.  I merged it directly into master.<BR>
<BR>
There is also a function in vtkScalarsToColorsPainter that applies IsNan() regardless of scalar type.  It could benefit from a similar patch.<BR>
<BR>
 - David<BR>
<BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT><FONT SIZE="2"><FONT FACE="Consolas, Courier New, Courier"><SPAN STYLE='font-size:10pt'><BR>
   ****      Kenneth Moreland<BR>
    ***      Sandia National Laboratories<BR>
***********  <BR>
*** *** ***  email: <a href="kmorel@sandia.gov">kmorel@sandia.gov</a><BR>
**  ***  **  phone: (505) 844-8919<BR>
    ***      web:   <a href="http://www.cs.unm.edu/~kmorel">http://www.cs.unm.edu/~kmorel</a><BR>
</SPAN></FONT></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT>
</BODY>
</HTML>