[vtk-developers] floating-point vs. integer performance
Volpe, Christopher R (CRD)
volpecr at crd.ge.com
Fri Jun 15 09:37:43 EDT 2001
|> Some of you might find this interesting:
|>
|> I added some templates to vtkImageReslice so that it can do all
|> transformation & interpolation operations with either fixed-point
|> or floating-point arithmetic, with a method to switch between
|> them at run-time.
|>
|> At first I was overjoyed, because on my PIII machine the fixed-point
|> code ran twice as fast (in some special cases as much as four times
|> as fast) as the original floating-point version.
Have you tried this on a PII as well as a PIII? I've done some experiments with integer arithmetic
vs. floating point arithmetic when I was toying with the idea of representing points and doing
transformations in fixed point. (This was mainly because the results were to be used as indices into
a 3D volume, and in CPU time, the compiler-generated x86 processor state change to trunc mode to do
an integer cast is like watching continental drift. Using inline assembler to hard code a round
instruction speeds this up so that it is merely agonizingly slow, but I digress...) I've found that
floating point beats integer arithmetic by a small margin on a PII. I think my test was something
simple like multiplying two volatile variables and storing results in a tight loop. Not the best of
tests, I'm sure.
|>
|> But then I compiled it on an R10000 IRIX computer, and the
|> fixed-point
|> math was 20% slower than the floating-point math. On an R12000 IRIX,
|> the fixed-point math was 50% slower.
I don't know about Irix, but a while back, on Solaris, an integer multiplication would generate a
FUNCTION CALL (_imul(), I believe) to do the operation, unless you specified some obscure compiler
flag to generate SPARC v8 architecture instructions, or something along those lines.
Chris
============================================
Christopher R. Volpe
Computer Scientist
Visualization and Computer Vision Program
Electronic Systems Laboratory
Bldg KW, Room C215
General Electric Corporate Research & Development
P.O. Box 8, Schenectady, NY 12301
(518) 387-7766, Dial Comm: 8*833-7766, Fax: (518) 387-6981
e-mail: volpecr at crd.ge.com web: http://www.crd.ge.com/~volpecr
More information about the vtk-developers
mailing list