shunwang / numexpr

Automatically exported from code.google.com/p/numexpr
MIT License
0 stars 0 forks source link

sum big array causes segmentation fault #41

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. python
Python 2.6.5 (r265:79063, Jul 14 2010, 11:36:05) 
[GCC 4.4.4 20100630 (Red Hat 4.4.4-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.version.version
'1.5.1'
>>> a = np.arange(91 * 720 * 361).reshape((91, 720, 361))
>>> import numexpr as ne
>>> ne.__version__
'1.4.1'
>>> nesum = ne.evaluate("sum(a, axis=0)")
Segmentation fault

2.
3.

What is the expected output? What do you see instead?
I expect to get the sum of *a* along the first axis.

What version of the product are you using? On what operating system?
numexpr 1.4.1
numpy 1.5.1
python 2.6.5
RHEL6

Please provide any additional information below.

Original issue reported on code.google.com by jakob.malm on 14 Jan 2011 at 7:58

GoogleCodeExporter commented 9 years ago
Yes, I can reproduce that (it takes a while, but I see the segfault).

Now that there is preliminary support for the proposed new iterator in NumPy, I 
was wandering if this would crash too, but we have some problem here:

>>> nesum = ne.evaluate("sum(a, axis=0)")
ValueError: The 'op_axes' provided to the iterator constructor for operand 1 
contained duplicate value 0
>>> ne.print_versions()
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Numexpr version:   2.0.dev
NumPy version:     2.0.0.dev-c44820a
Python version:    2.6.1 (r261:67515, Feb  3 2009, 17:34:37) 
[GCC 4.3.2 [gcc-4_3-branch revision 141291]]
Platform:          linux2-x86_64
AMD/Intel CPU?     True
VML available?     False
Detected cores:    2
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Mark, what do you think?

Original comment by fal...@gmail.com on 14 Jan 2011 at 2:06

GoogleCodeExporter commented 9 years ago
The numpy mailing list has some discussion of a problem that sounds related:

numexpr.evaluate gives randomized results on arrays larger than 2047 elements. 
The following program demonstrates this: 

from numpy import * 
from numexpr import evaluate

x = zeros(2048)+.01

print evaluate("sum(x, axis = 0)")
print evaluate("sum(x, axis = 0)")

For me this prints different results each time, for example:
11.67
14.84

If we set the size to 2047 I get consistent results.
20.47
20.47

Interestingly, if I do not add .01 to x, it consistently sums to 0.

using numpy 1.5.1 and numexpr 1.4.1

Original comment by jsalvat...@gmail.com on 24 Jan 2011 at 7:16

GoogleCodeExporter commented 9 years ago
I should also mention that this was duplicated with prod and at least one other 
person experienced this with a different array size 8192 (2**13) instead of 
2048 (2**11).

Original comment by jsalvat...@gmail.com on 24 Jan 2011 at 7:29

GoogleCodeExporter commented 9 years ago
Okay.  This is a problem with the threading code.  Now, forced the use of a 
single thread on reduction operations.  Fixed in r269.

Original comment by fal...@gmail.com on 25 Jan 2011 at 10:16

GoogleCodeExporter commented 9 years ago
What would be the best way to get the threading code back for sum and prod, 
while fixing this bug?

Original comment by nicolas....@gmail.com on 4 Mar 2012 at 7:27