diff options
author | John Zwinck <jzwinck@gmail.com> | 2017-09-14 00:16:23 +0800 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-09-13 09:16:23 -0700 |
commit | 03f3789efe4da2c56d2841ed027ef6735ca2f11b (patch) | |
tree | f837acfe5ee4cfd7d6422ee142da995c433c8ff4 /numpy/lib/tests/test_format.py | |
parent | ff8b298084b0e9014a0d8d26d5c90eddce6a5400 (diff) | |
download | numpy-03f3789efe4da2c56d2841ed027ef6735ca2f11b.tar.gz |
ENH: Align data in np.save() at 64 bytes (#9025)
Previously, saving format version 1 would align to 16 bytes,
and saving version 2 would align improperly (bug #8085).
Alignment is now always at least 64 bytes in either version,
which supports memory mapping of the saved files on Linux,
where mmap() offset must be a multiple of the page size.
Why 64 bytes? Simply because we don't know of a case where
more is needed. AVX alignment is 32 bytes; AVX-512 is 64.
Fixes #8085, closes #8598.
Diffstat (limited to 'numpy/lib/tests/test_format.py')
-rw-r--r-- | numpy/lib/tests/test_format.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py index 155732882..2d2b4cea2 100644 --- a/numpy/lib/tests/test_format.py +++ b/numpy/lib/tests/test_format.py @@ -615,6 +615,11 @@ def test_version_2_0(): format.write_array(f, d) assert_(w[0].category is UserWarning) + # check alignment of data portion + f.seek(0) + header = f.readline() + assert_(len(header) % format.ARRAY_ALIGN == 0) + f.seek(0) n = format.read_array(f) assert_array_equal(d, n) @@ -758,6 +763,7 @@ def test_read_array_header_1_0(): s.seek(format.MAGIC_LEN) shape, fortran, dtype = format.read_array_header_1_0(s) + assert_(s.tell() % format.ARRAY_ALIGN == 0) assert_((shape, fortran, dtype) == ((3, 6), False, float)) @@ -770,6 +776,7 @@ def test_read_array_header_2_0(): s.seek(format.MAGIC_LEN) shape, fortran, dtype = format.read_array_header_2_0(s) + assert_(s.tell() % format.ARRAY_ALIGN == 0) assert_((shape, fortran, dtype) == ((3, 6), False, float)) |