This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Switch to disable initialization of local structures in subprogram.


On 09/28/2011 05:34 PM, Paul van Delst wrote:
These structures are defined like so:

   TYPE :: CSVar_type
     TYPE(CSinterp_type) :: csi(MAX_N_LAYERS, MAX_N_CLOUDS)

How fancy is the type CSinterp_type?


Otherwise, I do not see why gfortran should do anything fancy. As variable with compile-time known size, it should be created on either the stack on in static memory, depending on the size of -fmax-stack-var-size= and whether -frecursive/-fopenmp/RECURSIVE is used.

Especially, if the data is in static memory, there should be no performance penalty, but also stack-allocated memory is fast.

As a test, you could try to use the "SAVE" attribute on the variables and check whether it makes a difference.

Note that by commenting code, you also change the function size - and thus possibly allowing to inline code which was before kept as a separate code.

You could use, e.g., -finline-limit=<n> (n could be for instance 600) for that file to see whether it makes a difference.*

You could also try to create a smaller example and use "-fdump-tree-original" which creates a file which contains the generated code with a C-like syntax. That should allow you to see what GCC/gfortran does internally. (Note: The dump does not contain all information.)

Tobias

* In GCC 4.7, the inliner has seen some modifications which should help Fortran. Additionally, there is the flag -fstack-arrays, which generates automatic arrays on the stack rather than allocating it on the heap, which significantly improves the performance of some programs (and requires a lot of stack memory).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]