extra memory used for intermediate calculations

Hi,
I’m using pgi fortran 90 on a linux machine and would like to know how to determine if the compiler is using extra memory for intermediate calculations.

For example, if a and b are arrays then

a=a+b

does not use an extra array to store a+b before copying it to a. but if a,b,c,d,e are arrays then

e=matmul(a,b)+matmul(c,d)

would require extra memory for the two intermediate arrays. How would I check to see if this happens for less obvious cases (and to what extent)?

Thanks,

Xi Lin

Hi Xi Lin,

If you are familiar with the assembly, you can look at the generated code. Not sure what you are trying to get. You can also use top command to use at memory use and compare to the size of your binary.

What is your experience with other compilers?

Hongyon

thanks for the quick reply.

I have very little experience with compilers, much less assembly.

I have a fixed cluster with a fixed amount of memory and would like to be able to solve as large as problems as possible. In order words, it is easy to keep track of the memory i statically and dynamically allocate, but I wish to know what other memory fortran uses for intermediate calculations.

because if i calculate

a=a+b

and I stay safe, then I would have to declare a third variable:

c=a+b
a=c

Thus increasing the amount of memory used by 50%.

I am not sure what you mean by top command and size of binary?

Thanks!

top command is a unix top command.

Type: top

You will see that what is total memory, how much it is used, and other information. You can do that before you run a binary and then once you run a binary you can see how much memory is used for your program based on the information printing by top. You will need to consider the size of your binary when looking at memory used that it is not an extra memory.

Hope this helps.
Hongyon

OK i see. That helps me see the total memory occupied, but does not give me any details on a specific line of the code. There is no other way than looking at the assembly??

Hi,

Sorry, as far as I know there is no easy way to do.

Hongyon