[Numpy-discussion] floating point exception weirdness

Todd Miller jmiller at stsci.edu
Wed Aug 11 03:50:24 EDT 2004

Hi Andrew,

So far you mentioned debian, linux-2.6.7, Python-2.3.4, and the Intel
IPP library.   What compiler are you using?

More comments below.

On Wed, 2004-08-11 at 02:26, Andrew Straw wrote:
> Hi All,
> I've isolated numarray.ieeespecial as the cause of a strange error which 
> I posted on c.l.py:
> http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&threadm=41198B29.7090600%40NOSPAM-DELETE-THIS.astraw.com&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26group%3Dcomp.lang.python
> My non-expert guess as to an explanation: some statements early in 
> numarray.ieeespecial (e.g. _na.array(1.0)/_na.array(0.0)) result in a 
> floating point exception being set which lies dormant until I call 
> certain functions in the Intel IPP library (e.g. 
> ippiAddWeighted_8u32f_C1IR), at which point the latent exception bit my 
> Python program is killed while the console says "Floating point exception".

It sounds to me like the IPP library is aborting as a result of
previously irrelevant floating point error state.  My guess is that the
problem is not confined to ieeespecial,  but rather to floating point
exception handling in general in combination with the IPP library and/or
whatever compiler you're using.  

The key numarray code for clearing the floating point error state is
NA_checkFPErrors() in numarray/Src/newarray.ch.

Some things that occur to me are:

1. Verify that any array divide by zero results in the same failure.  
>>> x = arange(10,20)/zeros((10,)) 
>>> call_your_ipp_code()

2. Look in the IPP library for routines related to clearing floating
point exceptions.  Look in your compiler runtime library for routines
related to clearing floating point exceptions.  Modify NA_checkFPErrors
accordingly and re-build numarray with 

% python setup.py install --genapi

4. Walk through the Pyrex generated wrapper code and make sure there's
nothing going on there.  I'm doubtful that this has anything to do with
the problem.

More ideas will come as you let us know what your compiler is and verify
item 1.


More information about the NumPy-Discussion mailing list