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: finit-local-zero and default initialization


Asher Langton wrote:
On 6/5/07, Steve Kargl <sgk@troutmask.apl.washington.edu> wrote:
On Tue, Jun 05, 2007 at 04:50:43PM -0700, Asher Langton wrote:
> I'm planning to add support for -finit-local-zero (PR20441), as well
> as for arbitrary default initializations specified at compile-time.
> One request from within LLNL has been for a way to control the default
> initialization values at runtime, via some simple library routines
> (set_default_integer, get_default_integer, etc.).  This would be very
> useful for debugging large codes without recompiling an entire
> project.  Any comments, suggestions, or objections?
>

I think the compile time options would be quite useful.
Can you describe the runtime method?  Would

   program test
   integer i
   print *, i
   end progrma test

compile to (pseudocode of course)

  if (getenv(RUNTIME_INITIALIZE))
    i = set_default_integer()

  print i
  end

The default initializations would be done only if specified at compile time. The runtime option would just change the values used for default initialization. So if default initialization was specified at compile time, the compiled code would be something like:

i = get_default_integer()
print i
end

By default, get_default_integer() would evaluate to 0, but a different
value could be specified at compile time (via a compiler flag) or at
runtime by calling set_default_integer.  Then a user could write a
driver program to do something like:

set_default_integer (-2147483648)
call massive_program
set_default_integer (2147483647)
call massive_program

This would help to reveal problems arising from incorrectly initialized values.

I like this approach, no runtime penalty if default initialization flag not given at compile time.

Jerry


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