Possible Code Performance Disparity using "parameter"
Steve Kargl
sgk@troutmask.apl.washington.edu
Mon Mar 12 22:18:00 GMT 2012
On Mon, Mar 12, 2012 at 06:03:11PM -0400, John L. Males wrote:
>
> Any thoughts or comments with regards to this discovery?
>
Without seeing the code, one can say very little.
You do realize that the PARAMETER attribute in a type
declaration statement makes an entity a named constant
and not a variable. When it is a named constant, gfortran
will replace the entity by the actual value, which may
permit constant-folding and other optimizations (such
as hositing a (sub)expression out of a loop). Depending
on how complicated the code is and how you use the
entity when it is a variable, the generated code may
actually be read its value from memory on each iteration.
--
Steve
More information about the Fortran
mailing list