Re: user-defined alignment in gfortran



Dr Ivan D. Reid wrote:
On Tue, 29 May 2007 00:22:30 +0000 (UTC), Timo Schneider
<timos@xxxxxxxxxxxxxxxxxx>
wrote in <slrnf5ms51.2q2.timos@xxxxxxxxxxxxxxxx>:

How do I tell gfortran to allign a complex*16 array at 16 byte
boundaries? This is necessary on the Cell BE architecture for being able
to do DMA transfer. In C I can write __attribute__((aligned(16))) and
it works. How can I do that with gfortran?

I wouldn't think you'd have to. I'd expect it to happen
automagically. ...or are you trying to align things up within a derived
type? Usual advice in that case is to assign your type/structure from
the largest elements down to the smallest, with character*? at the end.

For many gfortran targets, this is controlled in part by parameters built into binutils. Typical 32-bit targets didn't even begin to support 16-byte alignment until SSE came along. At one time, various 32-bit gcc targets had maximum alignments supported in binutils of 4 or 8 bytes. Many people claimed that support for more than 4-byte alignment violated the ABI, as long as the hardware provided automatic alignment fix-up.
When you have support for 16-byte alignment built into binutils, the gcc/gfortran option -mpreferred-stack-boundary=4 [this means 2**4] should accomplish what you requested. In current 32- and 64-bit gfortran implementations, this is the default, unless you set -Os, which tries to conserve stack space by setting smaller alignments, and disabling support for vectorization.
.



Relevant Pages

  • Re: reading a text file into a string
    ... If you are buffering lines and want to avoid unintentional cache ... support specified Alignments that are greater than the maximum Alignment ... This applies to subtypes, ...
    (comp.lang.ada)
  • RE: ReadDirectoryChangesW and buffer alignment
    ... There is some documentation in MSDN regarding ... alignment issue. ... We have forwarded this issue to the MSDN ... Microsoft Online Community Support ...
    (microsoft.public.win32.programmer.kernel)
  • Re: reading a text file into a string
    ... > You are probably correct with regards to Windows. ... > compilers that do support such alignments, ... > doing the extra effort required when allocating space on the heap.) ... the alignment of the stack at compile-time. ...
    (comp.lang.ada)
  • Re: reading a text file into a string
    ... > pool (with enough extra memory to support the alignment); ... > that don't need the alignment. ... it is just too much work without compiler support. ... But if I create a cache-aligned storage pool, ...
    (comp.lang.ada)
  • Re: A debugging implementation of malloc
    ... value for alignment in similar situations. ... targets I was using didn't have long double and I don't use them anyway... ... language right? ... Keith Thompson kst-u@xxxxxxx ...
    (comp.lang.c)