-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: Bad SIMD integer //
on windows in numpy 1.21.2
#20025
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
Comments
Thanks for the report! I am not aware that divmod ( @Macky1979 it would be very helpful if you can simplify the code a bit (e.g. |
Looks to be windows only. Simplest reproducer I found is import numpy as np
factor = 160995261420
a = np.array([160995261399, 160995261399, 160995261399, 160995261399])
a // factor
Funny enough import numpy as np
factor = 160995261420
a = np.array([160995261399, 160995261399])
a // factor
|
Thanks @bashtage, I think that is all the information needed to start digging efficiently. If the size matters, this is quite certainly SIMD related. |
Yep maybe SIMD, in first case we use this loop, which could be faulty: numpy/numpy/core/src/umath/loops_arithmetic.dispatch.c.src Lines 78 to 87 in 7dabf22
it works in second case as we use loop below that uses normal C Yeah it has to be that loop: >>> a = np.array([160995261399, 160995261399, 160995261399, 160995261399, 160995261399])
>>> a // factor
array([1, 1, 1, 1, 0], dtype=int64) |
//
on windows in numpy 1.21.2
My bad, this bug is caused by the SIMD implementation of fast integer division(#18178) when the divisor is a scalar and the dividend length >= 2 or 4 or 8 depending on the enabled SIMD extension on runtime. as @bashtage mentioned the bug occurs at windows only, to be more precise on msvc <= 2017 builds. #20153 should fixes this issue. also during my investigation, I discovered another bug but this time related to the unsigned 8-bit division which has been reported within #20168. |
Describe the issue:
I would like to report different behavior of % and // operands under numpy 1.20.3 and 1.21.2 running on Windows 10. The below code produces
[0 0 0 0 0 0 0 0]
for numpy 1.20.3 and[1 1 1 1 1 1 1 1]
for numpy 1.21.2.After upgrading numpy, I have noticed that pandas function groupby() is returning error of type
IndexError: index 2 is out of bounds for axis 0 with size 2
. The root of the cause is in function decons_group_index(), which is present in pandas file sorting.py. The issue is that groupby() determines unique values in individual columns and function decons_group_index() creates corresponding vector of indices. In my particular case I have two distinct values (e.g. 'a' and 'b') but three indices ([0, 1, 2]) when using numpy 1.21.2. Thus the error. In numpy 1.20.3 everything works fine. I suspect the following performance improvement being responsible for the issue.Reproduce the code example:
Error message:
No response
NumPy/Python version information:
1.21.2 3.9.6 (default, Aug 18 2021, 15:44:49) [MSC v.1916 64 bit (AMD64)]
The text was updated successfully, but these errors were encountered: