Re: user-defined alignment in gfortran



Louis Krupp <lkrupp@xxxxxxxxxxxxxxxxxxxxxxx> schrieb:
Timo Schneider wrote:
Richard Maine <nospam@xxxxxxxxxxxxx> schrieb:
glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx> wrote:

No hardware that I know of has instruction that operate on
complex data. There is no complex add or complex multiply
instruction. Operations are done on separate real and imaginary
parts using ordinary floating point instructions.
Reread the original post. He was not talking about Fortran operations on
the complex data. He specifically cited DMA transfer as the reason for
the request and he said it was a specific array. Doesn't sound to me as
though it directly had anything to do with it being complex, but just
that this particular array was the one involved withthe DMA transfer.

Yes! I dont care about the type of the array, I just want the array to
be 16-byte aligned.

I can tell you how I would do it in C; you could probably do something
similar in Fortran, although you might give up some portability.

I think I actually gaining "portability" by the aproach described below,
because in that way I don't have to impose restrictions on the caller.
(The code I write which reads the array is a library written in C but
called by (mainly) Fortran).

Start with the assumption that dynamic allocation will give you an
address that is eight-byte aligned, so figure out how many real*8
elements you need, and add one. Do the allocation. Pass the returned
address to a C routine that will tell you if it's on a 16-byte boundary.
If it's on a 16-byte boundary, use that address. If it's not, check
to make sure that it *is* on an 8-byte boundary, and use the address of
the next element, which *will* be on a 16-byte boundary.

Yeah, this is exactly what I do right now as a "workaround". The only
problem with this aproach I see right now is that if I want to get the
first element of an arry which is 8 but not 16 bytes aligned I have to
read 8 bytes of "junk" before the start of the array.
Now it could (theoreticaly) happen that the memory of these 8 bytes
"junk" do not belong to my application an we get a segfault.

Maybe you can think of a workaround for this or can prove me that the
case discribed obove can't hapen? I *believe* that it can't happen if
the pagesize is a multiple of 16, but I didn't look into this long
enough to be sure about it or to be able to determine the pagesize
(shoukd be somewhere inside the specs or kernel code).

Regards,
Timo
.



Relevant Pages

  • Re: user-defined alignment in gfortran
    ... instruction. ... the complex data. ... that this particular array was the one involved withthe DMA transfer. ... Start with the assumption that dynamic allocation will give you an address that is eight-byte aligned, so figure out how many real*8 elements you need, and add one. ...
    (comp.lang.fortran)
  • Re: user-defined alignment in gfortran
    ... instruction. ... the complex data. ... that this particular array was the one involved withthe DMA transfer. ...
    (comp.lang.fortran)
  • Re: user-defined alignment in gfortran
    ... instruction. ... the complex data. ... that this particular array was the one involved withthe DMA transfer. ...
    (comp.lang.fortran)
  • Re: Who uses clapack?
    ... > functions like SUM and MAXVAL and the ability to use array sections ... > drastically change the meaning of a Fortran code. ... >>Have you ever seen those bills for a Fortran compiler for an ... engineering applications in the C and C++ languages. ...
    (comp.lang.fortran)
  • Re: Who uses clapack?
    ... > functions like SUM and MAXVAL and the ability to use array sections ... > drastically change the meaning of a Fortran code. ... >>Have you ever seen those bills for a Fortran compiler for an ... engineering applications in the C and C++ languages. ...
    (sci.math.num-analysis)