comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: GNAT function calling overhead
Date: 1995/04/07
Date: 1995-04-07T00:00:00+00:00	[thread overview]
Message-ID: <dewar.797259175@gnat> (raw)
In-Reply-To: 3m0nv1$pv2@nef.ens.fr

Two issues here:

first, in your example, you return unconstrained arrays. This always
involves a fair amount of overhead. Some compilers will use the heap
for this (GNAT used to, and I think Alsys still does in some of their
compilers), and do two copies.

Some other compilers will do two copies, using a secondary stack (that's
what GNAT does now).

Some compilers will use specialized calling sequences, and manage to do
only one copy in some cases, but still two copies in many cases.

Anyway, there will be at least one extra copy, so that probably accounts
for the overhead of the call that you see. If you are concerned with
maximum efficiency, try to avoid returning uncosntrained arrays (note
that this facility does not exist at all in Fortran, C or C++).

Second, the comparisons between GNAT and C are odd. Normally when you
write equivalent code in Ada and C and compile both with GCC you will
get identical object code.

In almost all cases that we have examined, it turns out that such
discrepancies are caused by using high level features in Ada that
have no analog in C, thus rendering it an apples-vs-oranges comparison.

Anyway, I can't comment further without details. Send me the sources
at dewar@cs.nyu.edu, and I will analyze what is going on,a nd post a
followup when I figure it out.






  parent reply	other threads:[~1995-04-07  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
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   ` Robert Dewar
1995-04-07  0:00   ` Philip Brashear
1995-04-07  0:00   ` Tom Griest
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   ` Robert Dewar
1995-04-07  0:00   ` Colin James III
1995-04-07  0:00     ` Robert Dewar
1995-04-07  0:00 ` Robert Dewar [this message]
1995-04-07  0:00 ` Theodore Dennison
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