From owner-sc22wg5@dkuug.dk  Thu Oct  9 22:55:18 2003
Received: (from majordom@localhost)
	by dkuug.dk (8.12.10/8.9.2) id h99KtIgk027887
	for sc22wg5-domo; Thu, 9 Oct 2003 22:55:18 +0200 (CEST)
	(envelope-from owner-sc22wg5@dkuug.dk)
X-Authentication-Warning: ptah.dkuug.dk: majordom set sender to owner-sc22wg5@dkuug.dk using -f
Received: from math.jpl.nasa.gov (math.jpl.nasa.gov [137.79.7.57])
	by dkuug.dk (8.12.10/8.9.2) with ESMTP id h99KtCEt027882
	for <sc22wg5@dkuug.dk>; Thu, 9 Oct 2003 22:55:14 +0200 (CEST)
	(envelope-from vsnyder@mls.jpl.nasa.gov)
Received: from math.jpl.nasa.gov (localhost.localdomain [127.0.0.1])
	by math.jpl.nasa.gov (8.12.8/8.12.8) with ESMTP id h99KtWAQ009717
	for <sc22wg5@dkuug.dk>; Thu, 9 Oct 2003 13:55:32 -0700
Received: from math.jpl.nasa.gov (vsnyder@localhost)
	by math.jpl.nasa.gov (8.12.8/8.12.8/Submit) with ESMTP id h99KtWpq009713
	for <sc22wg5@dkuug.dk>; Thu, 9 Oct 2003 13:55:32 -0700
Message-Id: <200310092055.h99KtWpq009713@math.jpl.nasa.gov>
X-Mailer: exmh version 2.5 01/15/2001 with nmh-1.0.4
To: sc22wg5@dkuug.dk
Reply-to: Van.Snyder@jpl.nasa.gov
Subject: Re: (SC22WG5.3023) Wishes for future revisions of Fortran 
In-Reply-To: Your message of "Thu, 09 Oct 2003 13:36:43."
             <3f85c6dbb494c3.42373721@firstinter.net> 
From: Van.Snyder@jpl.nasa.gov
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Date: Thu, 09 Oct 2003 13:55:32 -0700
X-Spam-Score: 0.339 () NO_REAL_NAME
Sender: owner-sc22wg5@dkuug.dk
Precedence: bulk


I wrote:

> > I've just spent 40 hours tracking down a bug that turned out to have
> > resulted from a typo introduced during manual inlining of a procedure
> > with four executable statements (other than the END statement).  The
> > procedure is referenced in dozens of places in a code of 140,000 or so
> > lines.  Inlining it makes a difference of a factor of eight in the run
> > time, which was 14 hours on each of 386 3 GHz Pentium Xeon processors
> > before the inlining.  The bug arose in a case where one of the arguments
> > is a product of three arrays, each of which has a vector subscript, each
> > subscript of which has a vector subscript, each of which is a section.
> > Something like A(A1(A2(I:J)))*B(B1(B2(I:J)))*C(C1(C2(I:J))).  Naturally,
> > this reference is the one that makes the most difference in the run time.
> > The reference is within an inner loop.  I DID try creating an array temp
> > outside the loop to reduce the stress on the memory allocator.  This
> > provided an improvement, but not nearly as dramatic an improvement as
> > inlining did.
> > 
> > Can we PLEASE PLEASE PLEASE have an INLINE attribute for subprograms in a
> > future revision of the Fortran standard -- preferably the next one after
> > 2003?

and andyv@firstinter.net replied:

>   The only place inlining is practical for a compiler to do is within the
> same source file as the procedure being inlined.  Otherwise, the compiler's
> intermediate representation must be stored on disk along with the .o files. 
> If an inline directive did exist, you'd have to replicate the procedure
> in each of the source files that uses it.
> 
>   If it is only four lines to be inlined, you might try solutions based on
> 'include' or the C preprocessor.

We just installed another terabyte of disk storage.  I'm not worried about
storing the compiler's internal representation, whether that's in the .o
or .mod files.  Presumably, it would only be stored for subprograms that
have the INLINE attribute.

Since we don't have "very local" variables, that is, construct scope variables,
I need to declare all of the variables from the inlined procedure at the point
of inlining.  This isn't normally a problem, until I come to an inlining in a
scope that has a variable of the same name, and forget to change one or the
other of them.

Neither 'include' nor the the C preprocessor offer any help with this
problem, which is the source of the bug I spent 40 hours tracking down.

'include' doesn't know how to substitute actual arguments for dummy arguments,
so it's a non-starter.

-- 
Van Snyder                    |  What fraction of Americans believe 
Van.Snyder@jpl.nasa.gov       |  Wrestling is real and NASA is fake?
Any alleged opinions are my own and have not been approved or disapproved
by JPL, CalTech, NASA, Sean O'Keefe, George Bush, the Pope, or anybody else.


