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 [1], we have a floating point type that is a python object wrapped around an MPFR [2] 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 http://groups.google.com/group/comp.lang.python/browse_thread/thread/ba2b69a8fd8d45f6. The cool thing is that the numpy arrays can use these objects as naturally as other python objects. Thanks, Jason [1] http://www.sagemath.org [2] http://www.mpfr.org _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion