
dynamic memory allocated fortran code takes more time to execute
Quote:
>> I am running a fortran code on an SGI INDY/INDIGO. I spent a lot of effort
>> changing the code lines so it allocates memory dynamically to arrays. The
>> most time consuming subroutine (which contains nested do loops) now takes
>> 60% more time to execute compared to when the memory was allocated statically.
>> A simple loop counter placed inside the innermost loop indicates it is the
>> same in both situations. However profiling with pixie option indicates it
>> is spending correspondingly more no. of cycles in the code which does dynamic
>> memory allocation (there are no memory allocation code lines inside any do
>> loop). I am clueless; has anyone experienced this kind of behaviour?
>> thanks
>> SS
>I guess it is some kind of optimization problem.
>Have you tried to test it with different degrees of optimization ?
>How did you allocate the memory, just a pointer and malloc or ?
>arne
Aren't dynamically-allocated arrays always slower than static arrays?
I mean, isn't there more overhead at every array reference, because of
bounds-checking?
Maybe you can overcome your problem (to a certain extent) by assigning
array elements to temporary variables, ex.:
do i=1,100
t1 = a(i)
do 20 j=100
c(i,j) = t1+b(j)
enddo
enddo
instead of:
do i=1,100
do 20 j=100
c(i,j) = a(i)+b(j)
enddo
enddo
Of course this kind of practice works only when an array element is
referenced more than once in a do loop.
Athanasios Nenes