Alignment of gfortran allocated arrays
John Travers
jtravs@gmail.com
Fri Aug 17 11:14:00 GMT 2007
On 17/08/07, Tim Prince <tprince@computer.org> wrote:
> malloc() hardly qualifies as a gfortran internal.
I never meant to imply that it was.
> It has been around
> since long before gfortran or SSE. The 32-bit glibc malloc(), if that's
> what you're discussing, is likely to continue as it has been for over 10
> years, supporting double precision but not SSE objects. Note that
> gfortran runs on a lot of systems besides those which depend on 32-bit
> glibc, so if that is your world, you might clarify your posts by so
> stating. As there aren't any more CPUs manufactured which don't support
> 64-bit OS, you might take into account that many of us use 64-bit. Not
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.
> so many years ago, people scoffed at the idea that g77 could support
> even 8-byte alignments on certain 32-bit platforms. Extensions such as
> _mm_malloc() (not at all portable) and aligned_malloc() arose as a
> result, and probably have to be taken into account by people who build
> fftw for the associated targets. It might be valuable to include
> malloc wrappers for 32-bit gfortran to make the allocations 16-byte
> aligned, but I am only guessing that might be what you are getting at.
Good guess.
> We continue to have trouble in 32-bit applications which use mixed
> Fortran and C, being unable to sort out where the less-than-16-byte
> alignments arise.
>
Well, for fftw at least, people will use fftw_malloc in the c world to
get the alignment. Else, if they cared about alignment, they could
use any of the standard aligned malloc calls, such as the
posix_memalign. With fortran we don't have that luxury, so having some
method to obtain aligned allocations would be nice. I have a
preliminary hack to gfortran to get aligned malloc calls which I might
eventually get to the standard required for submission.
I did also think, that instead of an option to compile with aligned
arrays we could add an extension, i.e. an allocate_aligned subroutine.
But I defer to others such decisions, or whether to add anything at
all.
Thanks,
John
More information about the Fortran
mailing list