New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is wrong if np.zeros(2) == 0
returns array([False, True], dtype=bool)
?
#6251
Comments
In a fresh environment with the same Python 3.4.3, I installed NumPy without ATLAS etc, still giving the same error. |
That's certainly very strange behavior.
.
Can you try to localize the issue a bit more, e.g. by checking the
output from
.
import numpy as np
for i in range(42):
print(i)
x = np.zeros(i)
print(x)
y = x == 0.0
print(result)
z = np.invert(y)
print(z)
print(np.nonzero(z)[0])
.
Which of the operations zeros/invert/nonzero is giving the incorrect
results?
.
Was the Numpy for Python 2.7.9 compiled using the same compiler?
|
Hey, thanks. So the comparison operation is giving the incorrect results, for example here is the output for
|
Here is the Python 2.7.9
And here Python 3.4.3
|
One source for the strange periodicity in the results could be the SSE2
vectorization of the comparison. Something is still strange, since the
code is widely used on other x86_64 machines without problems. The
somewhat old gcc version might possibly also be related.
.
To check this, you can check if Numpy version 1.7.2 also has the same
problem. Alternatively, on top of numpy/core/src/umath/simd.inc.src change
.
#ifdef NPY_HAVE_SSE2_INTRINSICS
.
to
.
#undef NPY_HAVE_SSE2_INTRINSICS
#ifdef NPY_HAVE_SSE2_INTRINSICS
.
and reinstall from a clean build ("rm -rf build dist; pip install .").
.
@juliantaylor: ping
|
Thanks, I'll check that. BTW I just compiled NumPy 1.9.2 under the GCC-4.3-compiled Python 3.4.3 above, but used GCC 4.7.2, and the bug disappears. |
If changing gcc version fixes the issue, there are some grounds to
suspect a compiler bug.
|
Wow, even across different Python versions with the same compiler. |
Ok, NumPy 1.7.2 under GCC 4.3.4 compiled Python 3.4.3 works |
OK confirmed that under GCC 4.3.4 compiled Python 3.4.3, NumPy 1.9.2 compiled with GCC 4.3.4 |
So, to summarize, the bug seems to occur in my setting if all the following conditions are
|
A compiler that miscompiles vectorized code on a HPC cluster is a pretty clear cut case to convince admins to upgrade the version. The cluster is likely just producing wrong results for every program. though I'd like to check that out, are there any custom patches on the gcc? |
I assume numpy.test() fails too? |
numpy.test() fails with a lot of AssertionError: Arrays are not equal |
Ran 5484 tests in 23.528s FAILED (KNOWNFAIL=6, SKIP=14, errors=104, failures=1046) |
Here is the objdump of umath.so | grep sse |
How do I find out custom patches on the GCC? |
Thanks for your help! |
Note that the grep makes the output not useful, the idea is to look at
the generated assembler code and determine what's wrong with it.
|
as it works with python2 I assume its an aliasing issue in the ordered compare part. A bit strange I didn't think there would be anything for the compiler to screw up. Out of curiosity what kind of hardware is the cluster using that it is using gcc 4.3? itanium? 4.3 shouldn't support anything much newer than that. |
@pv Ah I see , obviously. Is there a standard way to upload that 3.9 M ? |
Ok here is the full output of $ objdump -d numpy-test/lib/python3.4/site-packages/numpy/core/umath.cpython-34m.so https://gist.github.com/andsor/4ad5460f8bc641124233#file-umath-objdump |
Re hardware: "Linux-2.6.32.59-0.7-default-x86_64-with-SuSE-11-x86_64"
|
xz compressed it should go down to a few kilobyte, you can send that per email e.g. to jtaylor.debian@googlemail.com |
Here is the objdump for the Python 2.7.9 version: |
is the python 3 build a debug build? its did not even inline npy_is_aligned which is like three instructions. the python2 build did |
oh wait both didn't... so don't expect good performance with that build |
Well I am not that familiar with building Python, but the admins say they configured and installed it with
However, I am not sure whether it was a clean install or whether they used it for the desktops before. Just guessing here, sorry. |
can you put a numpy build log into the gist |
Here is a build log (clean build): |
Didn't think the violation could cause issues but apparently some compilers do mess it up. Also the old code is overly complicated, don't know what I was thinking ... Closes numpygh-6251
hm ok looks like a normal build, still a bit strange assembly. |
Magnificient. That fixes it. |
(Of course still better to have a newer compiler, though) |
good thanks for testing. |
For the record: np.test() Running unit tests for numpy OK (KNOWNFAIL=6, SKIP=14) |
Thanks for all your help guys. That's it for me tonight! |
Didn't think the violation could cause issues but apparently some compilers do mess it up. Also the old code is overly complicated, don't know what I was thinking ... Closes numpygh-6251
Didn't think the violation could cause issues but apparently some compilers do mess it up. Also the old code is overly complicated, don't know what I was thinking ... Closes numpygh-6251
Hi, my first issue here in this great package so please bear with me :-)
As I encounter the above and this strange behaviour in a HPC environment.
prints
NumPy compilation with
By the way, under Python 2.7.9 on the same system with the same setup, this bug does not occur.
The text was updated successfully, but these errors were encountered: