8000 BUG: tighten alignment for complex types. by cournape · Pull Request #5365 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: tighten alignment for complex types. #5365

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

Closed
wants to merge 1 commit into from

Conversation

cournape
Copy link
Member

Complex types memory representations in C for a given type are guaranteed to be equivalent to type[2]. As such, the alignment of complex<type> should be the same as type.

I tested scipy 0.14.x (at scipy/scipy@d6c3206, containing the f2py workaround) in the following setups:

numpy 1.9.1, w/ this patch
  • one genuine error (all platforms). Unlikely to be related to numpy.
[192.168.33.13] out: ======================================================================
[192.168.33.13] out: ERROR: test_antiderivative_of_constant (test_interpolate.TestPPoly)
[192.168.33.13] out: ----------------------------------------------------------------------
[192.168.33.13] out: Traceback (most recent call last):
[192.168.33.13] out:   File "/home/vagrant/src/master-env/lib/python2.7/site-packages/scipy/interpolate/tests/test_interpolate.py", line 659, in test_antiderivative_of_constant
[192.168.33.13] out:     assert_equal(p.antiderivative().c, PPoly([[1], [0]], [0, 1]).c)
[192.168.33.13] out:   File "/home/vagrant/src/master-env/lib/python2.7/site-packages/scipy/interpolate/interpolate.py", line 821, in antiderivative
[192.168.33.13] out:     self.x, nu)
[192.168.33.13] out:   File "_ppoly.pyx", line 142, in scipy.interpolate._ppoly.fix_continuity (scipy/interpolate/_ppoly.c:5462)
[192.168.33.13] out: ValueError: order too large
  • a few minor precision issues that have been here for a while otherwise.
numpy 1.9.1, w/o this patch
  • Same results as above for rh5 and osx and windows 64 bits, but a dozen new errors for windows 32 bits:
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_x_and_y_stride (test_fblas.TestZaxpy)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\lib\blas\tests\test_fblas.py", line 85, in test_x_and_y_stride
[172.17.5.102] err:     assert_array_almost_equal(real_y,y[::2])
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 842, in assert_array_almost_equal
[172.17.5.102] err:     precision=decimal)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not almost equal to 6 decimals
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([  0.+0.j,  12.+0.j,  24.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_x_stride (test_fblas.TestZaxpy)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\lib\blas\tests\test_fblas.py", line 71, in test_x_stride
[172.17.5.102] err:     assert_array_almost_equal(real_y,y)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 842, in assert_array_almost_equal
[172.17.5.102] err:     precision=decimal)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not almost equal to 6 decimals
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([  0.+0.j,   7.+0.j,  14.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  1.+0.j,  2.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_y_stride (test_fblas.TestZaxpy)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\lib\blas\tests\test_fblas.py", line 78, in test_y_stride
[172.17.5.102] err:     assert_array_almost_equal(real_y,y[::2])
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 842, in assert_array_almost_equal
[172.17.5.102] err:     precision=decimal)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not almost equal to 6 decimals
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  3.+0.j,  6.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_x_and_y_stride (test_fblas.TestZcopy)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\lib\blas\tests\test_fblas.py", line 219, in test_x_and_y_stride
[172.17.5.102] err:     assert_array_almost_equal(x[::4],y[::2])
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 842, in assert_array_almost_equal
[172.17.5.102] err:     precision=decimal)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not almost equal to 6 decimals
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  4.+0.j,  8.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_y_stride (test_fblas.TestZcopy)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\lib\blas\tests\test_fblas.py", line 213, in test_y_stride
[172.17.5.102] err:     assert_array_almost_equal(x,y[::2])
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 842, in assert_array_almost_equal
[172.17.5.102] err:     precision=decimal)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not almost equal to 6 decimals
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  1.+0.j,  2.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_simple (test_fblas.TestZscal)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\lib\blas\tests\test_fblas.py", line 145, in test_simple
[172.17.5.102] err:     assert_array_almost_equal(real_x,x)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 842, in assert_array_almost_equal
[172.17.5.102] err:     precision=decimal)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not almost equal to 6 decimals
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  3.+0.j,  6.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  1.+0.j,  2.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_simple (test_fblas.TestZswap)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\lib\blas\tests\test_fblas.py", line 288, in test_simple
[172.17.5.102] err:     assert_array_almost_equal(desired_x,x)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 842, in assert_array_almost_equal
[172.17.5.102] err:     precision=decimal)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not almost equal to 6 decimals
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  1.+0.j,  2.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_x_and_y_stride (test_fblas.TestZswap)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\lib\blas\tests\test_fblas.py", line 315, in test_x_and_y_stride
[172.17.5.102] err:     assert_array_almost_equal(desired_x,x[::4])
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 842, in assert_array_almost_equal
[172.17.5.102] err:     precision=decimal)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not almost equal to 6 decimals
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  4.+0.j,  8.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_x_stride (test_fblas.TestZswap)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\lib\blas\tests\test_fblas.py", line 297, in test_x_stride
[172.17.5.102] err:     assert_array_almost_equal(desired_x,x[::2])
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 842, in assert_array_almost_equal
[172.17.5.102] err:     precision=decimal)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not almost equal to 6 decimals
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  2.+0.j,  4.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_y_stride (test_fblas.TestZswap)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\lib\blas\tests\test_fblas.py", line 307, in test_y_stride
[172.17.5.102] err:     assert_array_almost_equal(desired_y,y[::2])
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 842, in assert_array_almost_equal
[172.17.5.102] err:     precision=decimal)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not almost equal to 6 decimals
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  1.+0.j,  2.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_x_and_y_stride (test_fblas.TestZaxpy)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\linalg\tests\test_fblas.py", line 87, in test_x_and_y_stride
[172.17.5.102] err:     assert_array_equal(real_y,y[::2])
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 739, in assert_array_equal
[172.17.5.102] err:     verbose=verbose, header='Arrays are not equal')
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not equal
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([  0.+0.j,  12.+0.j,  24.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_y_stride (test_fblas.TestZaxpy)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\linalg\tests\test_fblas.py", line 80, in test_y_stride
[172.17.5.102] err:     assert_array_equal(real_y,y[::2])
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 739, in assert_array_equal
[172.17.5.102] err:     verbose=verbose, header='Arrays are not equal')
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:  
8000
   raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not equal
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  3.+0.j,  6.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_x_and_y_stride (test_fblas.TestZcopy)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\linalg\tests\test_fblas.py", line 219, in test_x_and_y_stride
[172.17.5.102] err:     assert_array_equal(x[::4],y[::2])
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 739, in assert_array_equal
[172.17.5.102] err:     verbose=verbose, header='Arrays are not equal')
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not equal
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  4.+0.j,  8.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_y_stride (test_fblas.TestZcopy)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\linalg\tests\test_fblas.py", line 213, in test_y_stride
[172.17.5.102] err:     assert_array_equal(x,y[::2])
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 739, in assert_array_equal
[172.17.5.102] err:     verbose=verbose, header='Arrays are not equal')
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not equal
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  1.+0.j,  2.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_simple (test_fblas.TestZscal)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\linalg\tests\test_fblas.py", line 146, in test_simple
[172.17.5.102] err:     assert_array_equal(real_x,x)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 739, in assert_array_equal
[172.17.5.102] err:     verbose=verbose, header='Arrays are not equal')
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not equal
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  3.+0.j,  6.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  1.+0.j,  2.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_simple (test_fblas.TestZswap)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\linalg\tests\test_fblas.py", line 287, in test_simple
[172.17.5.102] err:     assert_array_equal(desired_x,x)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 739, in assert_array_equal
[172.17.5.102] err:     verbose=verbose, header='Arrays are not equal')
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not equal
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  1.+0.j,  2.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_x_and_y_stride (test_fblas.TestZswap)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\linalg\tests\test_fblas.py", line 314, in test_x_and_y_stride
[172.17.5.102] err:     assert_array_equal(desired_x,x[::4])
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 739, in assert_array_equal
[172.17.5.102] err:     verbose=verbose, header='Arrays are not equal')
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not equal
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  4.+0.j,  8.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_x_stride (test_fblas.TestZswap)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\linalg\tests\test_fblas.py", line 297, in test_x_stride
[172.17.5.102] err:     assert_array_equal(desired_y,y)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 739, in assert_array_equal
[172.17.5.102] err:     verbose=verbose, header='Arrays are not equal')
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not equal
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  2.+0.j,  4.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err: 
[172.17.5.102] err: ======================================================================
[172.17.5.102] err: FAIL: test_y_stride (test_fblas.TestZswap)
[172.17.5.102] err: ----------------------------------------------------------------------
[172.17.5.102] err: Traceback (most recent call last):
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\scipy\linalg\tests\test_fblas.py", line 305, in test_y_stride
[172.17.5.102] err:     assert_array_equal(desired_x,x)
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 739, in assert_array_equal
[172.17.5.102] err:     verbose=verbose, header='Arrays are not equal')
[172.17.5.102] err:   File "C:\Users\vagrant\src\master-env\lib\site-packages\numpy\testing\utils.py", line 665, in assert_array_compare
[172.17.5.102] err:     raise AssertionError(msg)
[172.17.5.102] err: AssertionError:
[172.17.5.102] err: Arrays are not equal
[172.17.5.102] err: 
[172.17.5.102] err: (mismatch 66.6666666667%)
[172.17.5.102] err:  x: array([ 0.+0.j,  0.+0.j,  0.+0.j])
[172.17.5.102] err:  y: array([ 0.+0.j,  1.+0.j,  2.+0.j])
[172.17.5.102] err: 

Complex types memory representations in C are guaranteed to be equivalent to
type[2]. As such, the alignment of complex<type> should be the same as type.
@juliantaylor
Copy link
Contributor

test failure is real, should be the same you see on sparc

@juliantaylor
Copy link
Contributor

confirmed the bus error on sparc with this patch,, see I told you I tried this :)
that said that this crashes even though the alignment should be sufficient is an issue in numpy, a fix for that would be great.

@pv
Copy link
Member
pv commented Dec 11, 2014

The real problem apparently is that the logic in the loop selection in
lowlevel_strided_loops.c.src:PyArray_GetStridedCopyFn is correct only
if the alignment is the same as for the integer type of the same itemsize.
.
In particular, complex64 on gcc/linux/x86_64 has alignment 4 and
itemsize 8. The loop selector sees the array is aligned and selects
itemsize-8 loop. However, the itemsize-8 loop itself assumes the data
is aligned according to uint64 -> boom. (On x86 this doesn't matter,
apart from the asserts.)

@juliantaylor
Copy link
Contributor

yes thats why I introduced the copy alignment variable to account for this, one could also add special complex code or only use copy alignment for copy operations.

@pv
Copy link
Member
pv commented Dec 11, 2014

Yes, the problem is that PyArray_ISALIGNED has nothing to do with the alignment that the copy loops want to know about. Nevertheless, PyArray_ISALIGNED is used to in ndarray_constr.c to decide this. I'll try to see if this it's easy to come up with a patch...

@pv
Copy link
Member
pv commented Dec 11, 2014

I won't finish it today (or tomorrow), but the suggested fix would be to restore descr->alignment to be the alignment given by the C compiler --- this is a public API in numpy, and this is how it used to be. Then, add an internal function PyArray_DescrGetCopyAlignment(desrc) that returns the appropriate alignment for the copy loops, and use that in all code paths that end up choosing copy loop 8000 s. There are a number of them, and various variants of alignment checks are littered here and there, so there's some cleanup to do. (There are also some FIXMEs there along these lines :)

@juliantaylor
Copy link
Contributor

do we really care that a complex float32 from 8 byte unaligned memory is not flagged as 4 byte aligned?
if not my other pr is somewhat simpler

@charris
Copy link
Member
charris commented Dec 11, 2014

I haven't worked on this so my opinion might be totally irrelevant, but if I understand correctly, it makes sense to distinguish the types of alignment if one is specific to the needs of copying.

@njsmith
Copy link
Member
njsmith commented Dec 11, 2014

"do we really care that a complex float32 from unaligned memory is not
flagged as aligned?" -- maybe I'm just not the audience for this question,
but FWIW I have no idea what you're asking :-)

Do I have it right that basically what the strided copy loop code should be
doing is, if (ptr % itemsize) == (stride % itemsize) == 0 then we use the
aligned loop, and otherwise we use the unaligned one?
On 11 Dec 2014 21:22, "Julian Taylor" notifications@github.com wrote:

do we really care that a complex float32 from unaligned memory is not
flagged as aligned?
if not my other pr is somewhat simpler


Reply to this email directly or view it on GitHub
#5365 (comment).

@pv
Copy link
Member
pv commented Dec 11, 2014

The strided copy loop should be doing if (ptr % _ALIGN(@copytype@)) == 0 && (stride % _ALIGN(@copytype@)) == 0) where @copytype@ is uint8, uint16, uint32, uint64 and is chosen based on itemsize. Currently, it assumes this check is equivalent to checking the dtype alignment.

@pv
Copy link
Member
pv commented Dec 11, 2014

@cournape: did you also test with Numpy 1.8.x? What I don't understand right now is that the complex alignment was doubled already in Numpy 1.8 (c9bf9b0), so one would expect to see f2py issues also there?

@juliantaylor
Copy link
Contributor

1.8 didn't actually check the alignment, everything was aligned

@pv
Copy link
Member
pv commented Dec 11, 2014

@juliantaylor: do you mean flags.aligned == True on all newly allocated arrays? Or just the thing of adding alignment checks to the transfer loops?

@juliantaylor
Copy link
Contributor

the former, but also for arrays which where created by passing the constructor a pointer

@cournape
Copy link
Member Author

@pv for numpy 1.8.1 on win-32, I had np.dtype("D").alignment == 8 true.

@rgommers
Copy link
Member

@cournape test failure for Bento build

@charris
Copy link
Member
charris commented Jan 19, 2015

Closing this. For 1.9.2 will backport #5316, and for 1.10.0 another fix is pending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0