comp.lang.ada
 help / color / mirror / Atom feed
From: cjames@stout.entertain.com (Colin James III)
Subject: Re: GNAT function calling overhead
Date: 1995/04/06
Date: 1995-04-06T00:00:00+00:00	[thread overview]
Message-ID: <3m0psq$fl2@stout.entertain.com> (raw)
In-Reply-To: 3m0nv1$pv2@nef.ens.fr

In article <3m0nv1$pv2@nef.ens.fr>, Duncan Sands <sands@clipper.ens.fr> wrote:
>system: DOS 486 (with math coprocessor), gcc 2.6.3, GNAT 2.03
>
>Essentially the question is: why so much function calling overhead
>in GNAT?
>
>I'm writing a set of matrix factorization routines (Schur etc) so
>of course I need routines for multiplying matrices etc.
>For me a matrix is
>   type Matrix is array(Positive range <>, Positive range <>) of Float;
>
>I overloaded "*" for matrix multiplication:
>   function  "*"(Left : in Matrix; Right : in Matrix) return Matrix;
>
>Multiplying two 15 by 15 matrices 10_000 times using this function
>takes about 55 seconds on my machine.  The algorithm is the obvious
>one: loop over rows and columns, add up the appropriate products and
>assign them.
>
>I then "inlined" this function: rather than using "*", I put the code
>for "*" directly into my 10_000 times loop, of course renaming Left
>and Right to the names of my matrices, and assigning directly to the
>matrix which is to hold the answer.  In this way I eliminated the
>function calling overhead.  Using this method, multiplying two 15 by
>15 matrices 10_000 times takes about 44 seconds.
>
>All this was done with optimisation (-O3) and -gnatp (i.e. no range
>checking etc).
>
>In summary: 55 seconds with function calling overhead.
>            44 seconds without function calling overhead.
>
>Now, a 15 by 15 matrix means 225 entries.  225 entries at,
>say, 8 bytes an entry makes a bit less than 2k.  So, depending on
>whether GNAT takes function parameters by reference or by copy,
>this makes anything between 2k and, say, 10k bytes to be copied
>on each function call.
>
>Does this explain the time difference?  It shouldn't!  The amount
>of time spent copying memory should be completely overwhelmed by
>the amount of time taken to do the floating point operations!
>That is, for each of the 225 entries there are 15 floating point
>multiplications to be performed.  The amount of time taken to
>copy the 225 entries, even if you need to copy them several times,
>should be MUCH smaller than the amount of time spent in the
>calculation.  But the timings above indicate that function
>calling overhead makes up something like 25% of the time taken!
>
>So, the question is: why so much function calling overhead in GNAT?
>
>Can anyone please enlighten me?
>
>Thanks a lot,
>
>Duncan Sands.
>
>PS: The corresponding C code takes about 6 seconds.  This surprises
>me too.

At the most abstract level, it's because GNAT is a failed government 
project which was never finished and was mismanaged from the start by a 
bunch of flaky educators posing as "capable professionals".

At the most detailed level, it's because GNAT emits poorly optimized, and 
hence very evil, C code.

And what makes anyone think that ACT will change anything with regard to 
GNAT support, documentation or enhancements.  The ACT principals have 
already demonstrated that they failed with GNAT, by even starting ACT.
In other words, if GNAT were such a smashing success and quality product, 
then there would be no need for ACT.  

Good grief, what moral and intellectual dishonesty !




  parent reply	other threads:[~1995-04-06  0:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-04-06  0:00 GNAT function calling overhead Duncan Sands
1995-04-06  0:00 ` Norman H. Cohen
1995-04-06  0:00 ` Colin James III [this message]
1995-04-06  0:00   ` Samuel Tardieu
1995-04-06  0:00   ` Robb Nebbe
1995-04-07  0:00     ` Duncan Sands
1995-04-07  0:00     ` Robert Dewar
1995-04-07  0:00   ` Philip Brashear
1995-04-07  0:00   ` Robert Dewar
1995-04-07  0:00   ` Tom Griest
1995-04-07  0:00     ` Robert Dewar
1995-04-07  0:00 ` Robert Dewar
1995-04-07  0:00 ` Theodore Dennison
1995-04-07  0:00   ` Robert Dewar
1995-04-07  0:00 ` Kenneth Almquist
1995-04-07  0:00   ` Larry Kilgallen
1995-04-07  0:00     ` Robert Dewar
1995-04-07  0:00   ` Colin James III
1995-04-07  0:00     ` Robert Dewar
1995-04-07  0:00   ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox