[vtk-developers] vtkImageReslice performance questions/improvemnts

Sean McBride sean at rogue-research.com
Tue Sep 14 12:33:52 EDT 2010


Hi David,

Thanks for your speedy reply!


On Tue, 14 Sep 2010 09:08:01 -0600, David Gobbi said:

>Casting to int does round-towards-zero, while floor() does
>round-towards-neg-infinity. The latter rounding mode is needed for
>vtkImageReslice.

Ah!  Does vtkImageReslice care about other edge cases, like inf, nan, or
doubles outside the range of the 'int' type?

>Also, even casting to int can be notoriously slow on
>the x86 CPU.  A summary is provided here:
>http://www.stereopsis.com/FPU.html

Interesting.  Well, there have been so many x86 CPUs... :)  For me, the
compiler seems to use cvttsd2si, which seems pretty fast.  But is
doesn't round as desired.

>The general implementation "static_cast<int>(floor())" is the simplest
>correct implementation, even if it is inefficient, so I'd like to
>leave it as the general case.

I agree it's good to have a simple correct baseline to compare against.

>But we could easily add an #ifdef to
>add whichever float-to-int conversion is most efficient for your
>platform.

The two platforms I deploy to, ppc64 and x86_64, both fall into the
general floor() case. :( I don't see anything like cvttsd2si that does
round-towards-neg-infinity.  But this must be a solved problem...

-- 
____________________________________________________________
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