np.divide.accumulate gives incorrect results for float64 on Numpy 1.15.0 using Intel compiler
See original GitHub issueI have a unit test failing on np.divide.accumulate
with numpy 1.15.0 compiled with the Intel compiler. The same code is fine with a local build of GCC.
Perhaps this is related to ENH: umath: don’t make temporary copies for in-place accumulation (https://github.com/numpy/numpy/pull/10665) where @juliantaylor fixed numpy/core/src/umath/loops.c.src
for GCC’s ivdep
pragma. That was reviewed by @eric-wieser .
Reproducing code example
Source code was 1.15.0 compiled with the Intel compiler 2018.1.163. where np.divide.accumulate fails in the numpy unit tests.
I can reproduce with this Python 2.7 test case for float64
dtype. It runs correctly for float32
and float128
on the Intel compiler. It also runs correctly for float64
using GCC instead of Intel.
$ python -c "import numpy as np; acc = np.divide.accumulate;
a = np.ones(8, dtype=np.float64);
print acc(a, out=2*np.ones_like(a)); print acc(a); print acc(a); print acc(a);
print acc(a, out=2*np.ones_like(a))"
[1. 1. 2. 2. 2. 2. 2. 2.]
[1. 1. 1. 1. 2. 2. 2. 2.]
[1. 1. 1. 1. 1. 1. 2. 2.]
[1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 2. 2. 2. 2. 2. 2.]
Notice how only the next two elements are set each time np.divide.accumulate
runs. That suggests the float64
s are being processed in pairs. Then in the final line, specifying the output array again returns to the first line’s incorrect behavior.
Numpy/Python version information:
numpy 1.15.0 build with ICC 2018.1.163.
python 2.7.11 built with GCC 4.9.3.
Issue Analytics
- State:
- Created 5 years ago
- Comments:26 (19 by maintainers)
Thanks @svenevs just in case, one thing that would be nice is to ensure that our test suits finds these errors (if possible). Probably that is already the case, but if not it would be good to add them. After that anyone using these compilers will know that something is off.
@svenevs you should probably start with doing modifications here:
https://github.com/numpy/numpy/blob/1dfb0ab7358b0cae068b41b3d07452713594ef6b/numpy/core/src/umath/loops.c.src#L1820
which are the loops that get executed for the typical floating point types. Note that “kind” in that code bunch can be
divide