Re: Speed penalty for using allocatable arrays?



jomarbueyes@xxxxxxxxxxx wrote:

(snip on slow execution using ALLOCATABLE arrays)

I might expect one or two more instructions to do the calculation
per dimension of the array, but not more. For matrix multiplication,
which does more array access than multiply or add, that could be
a significant part of the time.

You might have a point here. The bottleneck of our algorithms
are fast Fourier transforms (FFTs) which do multiply-add
operations between memory locations that are not close to
each other. However, I'd expect the same limitatation to apply
to programs with static memory allocation.

Usually FFT would be done in a subroutine, and that subroutine
would be the same: allocatable, automatic, or static.

One thing that does happen sometimes is that the compiler copies
a possibly non-contiguous array into contiguous space
before passing to to an assumed size dummy argument. It
is possible that that change would happen in changing to
ALLOCATABLE arrays.

It would be nice if you had a nice small program that showed
this effect. Maybe load data into an array, call FFT, show
the result.

On x86 machines, my favorite way to do timing is with the RDTSC
(read time stamp counter) instruction. It takes a two instruction
assembly program on most 32 bit x86 machines that allow for a 64 bit
INTEGER type.

If you can get a nice small program, though, it should be possible
to look at the generated code and see what is so different.

(snip of other suggestions and answers)

-- glen

.



Relevant Pages

  • Re: Illegal instruction (core dumped)
    ... (snip regarding "Illegal instruction (core dumped)") ... > 1) overwriting the compiled code by writing to an invalid array ... any compile time errors. ...
    (comp.lang.fortran)
  • Re: Question on allocatable arrays in Fortran 90
    ... > Is the allocatable arrays in Fortran 90 always continuous in memory? ... > was somehow copied first to a +continuous array and then the function was ... instead of the raw data. ... a difference that you thought was unimportant, ...
    (comp.lang.fortran)
  • Re: Concatenate integer to string
    ... (snip regarding allocatable arrays and character strings) ... compiler do the "optimization" of leaving the allocation alone if it was ... Reallocation would break any existing pointer ... array with a copy of the old data. ...
    (comp.lang.fortran)
  • Question on allocatable arrays in Fortran 90
    ... Is the allocatable arrays in Fortran 90 always continuous in memory? ... I allocated a 4-dimensional array, say top. ... If I declare a regular variable of the same size, the timing will be much smaller. ... These two codes use almost the same amount of time. ...
    (comp.lang.fortran)
  • Re: fast array assignement
    ... That has not much to do with array notation. ... allocatable arrays and non-pointer dummy arguments and you will get ... > 2) Do loops, wrong order of inner and outer loop ...
    (comp.lang.fortran)