Alignment of gfortran allocated arrays
John Travers
jtravs@gmail.com
Fri Aug 17 18:34:00 GMT 2007
On 17/08/07, Tim Prince <tprince@computer.org> wrote:
> John Travers wrote:
> >
> > Yes, my two primary systems (including the one I posted from) are 64
> > bit. I thought it was clear what I was talking about as we were
> > discussing getting 16-byte alignment.
> >
> 16-byte alignments are needed for SSE support on both 32- and 64-bit
> OS. Various compilers for 32-bit linux handle it in incompatible ways.
> You could get into trouble calling a vectorized gcc or gfortran
> function from ifort, for example. malloc() gives 4-byte alignment on
> 32-bit Windows (even scalar double precision performance may suffer),
> and 8-byte on linux.
> Windows and linux 64-bit both adopted 16-byte alignment as a default.
> If malloc() doesn't give a 16-byte aligned pointer, that's a bug. The
> URLs you referenced indicate that gfortran already has resolved the
> ALLOCATABLE problem as far as 64-bit linux is concerned. Solaris is the
> only 64-bit OS I know of which has trouble here.
>
I think we keep miss-interpreting each other :). My 64-bit systems do
not have any problem at all, so no bugs in malloc. I was simply
explaining that I was aware of 64 bit systems being common, but my
desire to sort out the 16 byte alignment (with respect to the default
8 byte mentioned in the posts I linked to), implied I was talking
about 32 bit systems. I should have been clearer on that, I'm sorry.
Anyway, somebody contacted me off list to suggest I use the shiny new
iso_c_bindings to call fftw_malloc. I knew of the bindings, but didn't
realise I could coerce a fortran array pointer to take data allocated
in c. I'm now enlightened and it works perfectly!
So I regard this issue (of mine) now solved, and think the c bindings
technique is better than fiddling with gfortran internals, so I won't
try and make any patches to wrap gfortran's malloc.
Sorry for creating so much noise on this list and thanks for all the
helpful replies!
Best regards,
John
More information about the Fortran
mailing list