Single precision floating point calcs?

Ross Ridge rridge at caffeine.csclub.uwaterloo.ca
Thu May 10 08:29:52 EDT 2007


Grant Edwards  <grante at visi.com> wrote:
>In the C implementations, the algorithms will be done
>implemented in single precision, so doing my Python prototyping
>in as close to single precision as possible would be "a good
>thing".

Something like numpy might give you reproducable IEEE 32-bit floating
point arithmetic, but you may find it difficult to get that out of a
IA-32 C compiler.  IA-32 compilers either set the x87 FPU's precision to
either 64-bits or 80-bits and only round results down to 32-bits when
storing values in memory.  If you can target CPUs that support SSE,
then compiler can use SSE math to do most single precision operations
in single precision, although the compiler may not set the required SSE
flags for full IEEE complaince.

In other words, since you're probably going to have to allow for some
small differences in results anyways, it may not be worth the trouble
of trying to get Python to use 32-bit floats.

(You might also want to consider whether you want to using single
precision in your C code to begin with, on IA-32 CPUs it seldom makes
a difference in performance.)

					Ross Ridge

-- 
 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge at csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //	  



More information about the Python-list mailing list