PR 19925 and expansion of array constructors
Paul Brook
paul@codesourcery.com
Thu Jun 30 20:12:00 GMT 2005
On Thursday 30 June 2005 19:37, Erik Edelmann wrote:
> My question is: where is the correct place to expand the
> constructor? And why not expand all constructors, small as well as
> large, in gfc_expand_constructor? Since they'll have to be
> eaxpanded anyway at some point, why not do it from the beginning?
Expanding everything takes insane amounts of memory and produces unreasonably
large executables. An example from real code:
program killme
integer, parameter :: N = 200000000
integer :: i
integer :: a(N) = (/(0, i = 1, N)/)
call foo(a)
end program
For really big variables (Where anything > GFC_MAX_AC_EXPAND counts as big) we
want to expand these at runtime. ie. the above code becomes:
program killme
integer, parameter :: N = 200000000
integer :: i
integer, save :: a(N)
logical :: _initialized_a = .false.
if (.not. _initialized_a) then
do _i = 1, N
a(_i) = 0
end do
end if
call foo(a)
end program
It's probably worth special casing initialization-to-zero, but we still want
other cases to work.
Note there are obviously other places than need to check GFC_MAX_AC_EXPAND as
the above case already takes an unreasonable amount of time to compile
(before it fails).
Paul
More information about the Fortran
mailing list