[Numpy-discussion] Numpy 1.9.1, zeros and alignement

Pauli Virtanen pav at iki.fi
Tue Nov 18 17:10:39 EST 2014

18.11.2014, 21:44, David Cournapeau kirjoitti:
> On Tue, Nov 18, 2014 at 7:05 PM, Julian Taylor <
> jtaylor.debian at googlemail.com> wrote:
>> 32 bit windows should not provide 16 byte alignment, at least it doesn't
>> for me. That is typically a property of 64 bit OS.
>> But that does not explain why normal double is not aligned for you, that
>> only needs 4 bytes on i386 which even 32 bit OS should provide.
> Sorry for the confusion, doubles are aligned, only complex128 are not. But
> I see that on linux 32 bits, this is the same as on windows (zeros output
> not always aligned on "D" dtype), and yet I don't see the issues with f2py
> not being able to

The scipy ticket is here, btw:

The second question is whether F2py actually *needs* to check the
dtype-size alignment, or is just something like sizeof(double) enough
for Fortran compilers. Fortran compilers however apparently do generate
code that crashes and burns if there's no alignment also on x86:
https://github.com/scipy/scipy/pull/2698  All this is probably
unspecified, as it's just F77 up out there.

Apparently, everything has worked OK with the old Numpy behavior, or at
least, nobody managed to pinpoint a crash on Win32 because of this? Can
the F2py alignment checks be relaxed? Maybe it is enough to assume the
Fortran compiler is happy with whatever alignment the system malloc()

If not, the second option is a bit nasty, since I'd believe many people
have f2py code out there with complex inout arrays, and I think no-one
uses special aligned allocators...

Pauli Virtanen

More information about the NumPy-Discussion mailing list