[Numpy-discussion] Disabling Extended Precision in NumPy (like -ffloat-store)
Wed Apr 21 10:19:22 CDT 2010
On 21 April 2010 11:03, Pauli Virtanen <email@example.com> wrote:
> ke, 2010-04-21 kello 10:47 -0400, Adrien Guillon kirjoitti:
>> 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).
> Probably the only way to ensure this is to recompile Numpy (and
> possibly, also Python) with the -ffloat-store option turned on.
> When compiling Numpy, you should be able to insert the flag via
> OPT="-ffloat-store" python setup.py build
This will certainly work. But maybe you should be careful even so: you
can't trust floating-point operations to behave identically across
architectures (or even across compilations). Given that, it may be
perfectly sufficient to simply do your calculations normally in numpy,
without recompiling. Even if x86 FPUs store intermediate results in
extended precision, the way numpy structures its computations normally
forces all intermediate results out to main memory: r = a*b + c, when
applied to arrays, carries out all the multiplications, then all the
additions. So extended precision may not be an issue.
More information about the NumPy-Discussion