[comp.lang.fortran] Looking for source-level inliner

ngse18@castle.ed.ac.uk (J R Evans) (05/08/91)

Discussion on comp.compilers notwithstanding :-), I'm looking for a basic 
Fortran to Fortran function inliner.  The application is not demanding, 
and the relevant code is yet to be written, so I am not seeking an 
all-singing, all-dancing tool.  Any suggestions welcome.

Some background for the curious:  I'm rewriting some ancient code for 
modelling seismic wave propagation in stratified media, and I'd like to
be able to run the code on our Convex system as well as my workstation.
Good program design and my intention to develop certain aspects of the
program suggest that I should code the main algorithm - a series of
manipulations of small matrices - as a collection of subroutine calls.
The algorithm is certainly vectorizable, but the Convex compiler is 
apparently incapable of vectorizing a loop which contains such calls.  
An inliner would allow me to write and test the code in a legible, 
maintainable fashion on my workstation, and to transform it into 
vectorizable form for subsequent 'production' use on the Convex.  
I concede that I could perhaps produce readable code by careful use of 
a macro pre-processor, but I would prefer to construct modular code in
standard Fortran.

Thanks for your attention

Russ Evans
British Geological Survey, Edinburgh           
Principal mailbox : e_gs18@va.nmh.ac.uk

ngse18@castle.ed.ac.uk (J R Evans) (05/09/91)

In the referenced article, I asked for suggestions regarding a Fortran
to Fortran function inliner, to assist in generating vectorizable code.
It seems I was wrong in thinking that the Convex Fortran compiler offers
no facilities for vectorizing code containing function calls; although
their 'Advanced Optimisation Course' has a lot to say about manually
inlining at source code level, it completely fails to mention that the
compiler has a facility for inlining at the intermediate code level. 
Thus it appears that Convex does provide the facilities I need - they
are just poorly documented! 

Thanks to Jim Davies (jrbd@craycos.com !!) for information on Convex's
'Application Compiler' which offers high levels of interprocedural
optimisation as an (expensive) add-on extra to the standard compilers.

Russ Evans
British Geological Survey, Edinburgh           
Principal mailbox : e_gs18@va.nmh.ac.uk

psmith@convex.com (Presley Smith) (05/10/91)

In article <10161@castle.ed.ac.uk> ngse18@castle.ed.ac.uk (J R Evans) writes:
>In the referenced article, I asked for suggestions regarding a Fortran
>to Fortran function inliner, to assist in generating vectorizable code.
>It seems I was wrong in thinking that the Convex Fortran compiler offers
>no facilities for vectorizing code containing function calls; although
>their 'Advanced Optimisation Course' has a lot to say about manually
>inlining at source code level, it completely fails to mention that the
>compiler has a facility for inlining at the intermediate code level. 
>Thus it appears that Convex does provide the facilities I need - they
>are just poorly documented! 

Basically, inlining in the procedure FORTRAN compiler (fc) on the CONVEX
is accomplished by the user doing a compile on the routine(s) that he wishes 
to inline with a switch on the command line that tells the compiler to 
produce an intermediate result that can then be inlined.   Multiple routines
can be precompiled for inlining and these routines are placed in a 
directory that is used during the main compilation process.

When you compile the main routines, you specify the directory that has
the precompiled routines that are to be inlined.  The compiler inserts
code from the precompiled routine INLINE with the main routine during the
compilation and that code participates fully in optimization that is done
by the compiler.  

I'm not sure what documentation you have, but inlining has been available
since November, 1987 in the CONVEX FORTRAN compiler.

>
>Thanks to Jim Davies (jrbd@craycos.com !!) for information on Convex's
>'Application Compiler' which offers high levels of interprocedural
>optimisation as an (expensive) add-on extra to the standard compilers.
>

The Application Compiler works in a different manner.  The Application 
Compiler compiles the entire application, not just one routine at a time.
Interprocedural Analysis in the Application Compiler gives the compiler
the ability to look at the called routine and to determine if that called
routine is profitable to inline.   This is done AUTOMATICALLY.  The user
can still specify routines to inline if desired, but the Application 
Compiler is capable of determining automatically what routines to inline. 
In many cases performance is increased without the user having to specify
which routines to inline.

The Application Compiler works with both FORTRAN and C code and provides 
many other optimizations that cannot be done by conventional compilers. 
We have had performance increases from 0% on highly optimized code to 
over 100% in cases where code was not well written.   The average 
performance increase using the Application Compiler on FORTRAN is in the
10% to 20% range. 

In addition, the Application Compiler finds many errors and potential 
errors.  Since this compiler has visitibility of ALL the routines in 
the application and all the interfaces between those routines, it can 
find errors like mismatched argument types, invalid subscripts, aliasing
violations, unitialized variables, and others.

The Application Compiler contains the next generation of optimization 
technology.  It contains all of the code in the the FORTRAN and C compilers
plus 85,000 lines of new Interprocedural Optimization code.  It took 10 man
years of effort to produce this product. 

As to the "expense"... the price for the Application Compiler is the SAME as
for the CONVEX FORTRAN or CONVEX C compiler on CONVEX products.  It is a
separate product from the standard FORTRAN and C compilers.    

If you'd like to know more about the CONVEX Application Compiler, contact
your nearest CONVEX office.  There is a 15 minute video tape that describes
the product and it's capabilities. 

FYI
Presley Smith 
Manager: Development Software
CONVEX Computer Corporation              Reply to: psmith@convex.com
3000 Waterview Parkway,                  Phone:    214-497-4000
P.O. Box 833851                          FAX:      214-497-4500
Richardson,   TX  75083-3851