[Numpy-discussion] Disabling Extended Precision in NumPy (like -ffloat-store)
Fri Apr 23 13:53:13 CDT 2010
On 04/21/2010 09:47 AM, Adrien Guillon wrote:
> Hello all,
> I've recently started to use NumPy to prototype some numerical
> algorithms, which will eventually find their way to a GPU (where I
> want to limit myself to single-precision operations for performance
> reasons). I have recently switched to the use of the "single" type in
> NumPy to ensure I use single-precision floating point operations.
> My understanding, however, is that Intel processors may use extended
> precision for some operations anyways unless this is explicitly
> disabled, which is done with gcc via the -ffloat-store operation.
> Since I am prototyping algorithms for a different processor
> architecture, where the extended precision registers simply do not
> exist, I would really like to force NumPy to limit itself to using
> single-precision operations throughout the calculation (no extended
> precision in registers).
> How can I do this?
If you want to avoid any assumptions the hardware might make that you
aren't aware of, you might look at software libraries which emulate
single precision numbers. For example, in Sage , we have a floating
point type that is a python object wrapped around an MPFR  number
(look at the RealField class or email sage-support for details). You
might also look at minifloat libraries or related libraries. For
example, a google search turns up
The cool thing is that the numpy arrays can use these objects as
naturally as other python objects.
More information about the NumPy-Discussion