[vtk-developers] Speeding up raycasting on x86

Lisa Avila lisa.avila at kitware.com
Thu Jul 11 14:30:57 EDT 2002


Hi David,

I had tried something similar to this in another place at one time and did 
not see a significant improvement so I abandoned it. It seems like you have 
found a good place to use it if you've made a 35% performance improvement!

Does this generate compiler warnings? If it doesn't then I see no reason 
not to use it.

Lisa



At 02:15 PM 7/11/2002, David Gobbi wrote:
>Hi Lisa,
>
>I tried a little experiment with vtkVolumeRayCastCompositeFunction
>and managed a speed-up of 35% in VTK's trilinear ray casting.
>
>I replaced all instances of
>
>  <something> = (int)(floatval)
>
>with
>
>  <something> = vtkQuickFloor(floatval)
>
>according to the following definition of vtkQuickFloor:
>
>inline int vtkQuickFloor(double x)
>{
>#if defined i386 || defined _M_IX86
>   unsigned int hilo[2];
>   *((double *)hilo) = x + 103079215104.0;  // (2**(52-16))*1.5
>   return (int)((hilo[1]<<16)|(hilo[0]>>16));
>#else
>   return (int)(x);
>#endif
>}
>
>That big mess with the bitshifts and whatnot is a trick that I found
>on a web page a couple years ago (I could dig up the URL) that works
>many times faster than what most iX86 compilers generate for (int)
>casts.  I've been using it in vtkImageReslice for a while now.
>
>Is this the sort of optimization that Kitware is interested in?
>It is messy and CPU-specific, but it is confined to one single
>inline function.
>
>  - David
>
>_______________________________________________
>vtk-developers mailing list
>vtk-developers at public.kitware.com
>http://public.kitware.com/mailman/listinfo/vtk-developers




More information about the vtk-developers mailing list