From: "Jeff Creem" <jeff@thecreems.com>
Subject: Re: What is faster Ada or C?
Date: Mon, 10 Dec 2001 17:33:16 GMT
Date: 2001-12-10T17:33:16+00:00 [thread overview]
Message-ID: <wl6R7.10969$5W5.4382989@typhoon.ne.mediaone.net> (raw)
In-Reply-To: 3C14E817.8A2E798E@nbi.dk
Note that if you are really interested in the performance difference of
the two discussed square roots you may want to look for a few minutes
at the instruction set of your computer and your problem domain since
there is sometimes an instruction that calculates the 1/sqrt(x) which can
then be used in places where you had code like Y := B / SQRT(X) which
can now be Y := B * my_sqrt_recip(X). If your processor has and
instruction like
this it can save a few cycles. I use this as an example but there may be
other cases where
things like this can be found.
A small package machine_code coded special purpose math library can
sometimes really
help in tight loops. (And of course it can be a fun waste of time in not so
tight loops :)
"Jacob Sparre Andersen" <sparre@nbi.dk> wrote in message
news:3C14E817.8A2E798E@nbi.dk...
> Robert Dewar wrote:
>
> > Jacob Sparre Andersen <sparre@nbi.dk> wrote in message
news:<3C10F77E.6BDD9A3B@nbi.dk>...
> > > When I look at the corresponding assembler code (gnatgcc
> > > -S/g++ -S) I can see that GNU C++ inlines the square root
> > > function, while GNU Ada doesn't.
> >
> > You seem to be assuming that the function called square root in C++
> > and the function called square root in Ada
> > are the same function,
>
> Correct.
>
> > presumably because their names
> > are similar, and both are usable in your context, but they
> > are not at all the same routine. The Ada routine has additional
> > semantics not present in the C++ routine (e.g.
> > the handling of -0.0 which is required to return -0.0).
>
> I had forgotten (or had not noticed) this.
>
> > Those extra tests take significant time. Now one can sit
> > back and say "Ada is a junk language, it insists on testing
> > for errors at runtime, and in giving accurate IEEE results,
> > and I don't need either",
>
> I happen to need accurate results, and I appreciate being
> able to specify things like the number of significant digits
> in my floating point types. But I am (as a physicist) not
> used to -0.0 being different from +0.0, nor to being unable
> to calculate the square root of -0.0, as your explanations
> seem to indicate that IEEE floating point processors are.
>
> > but that's not a very reasonable
> > position given that if you like you can easily call the
> > C routine directly, since Ada, unlike other languages,
> > carefully defines the syntax and semantics of calling routines written
> > in other languages :-)
>
> Since I - in the example program - know that the values will
> never get close to zero, I suppose that I can use the C
> function "sqrt".
>
> Jacob
> --
> I teorien lyver folk ikke i retten.
next prev parent reply other threads:[~2001-12-10 17:33 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-01 1:22 What is faster Ada or C? Heiko Hamann
2001-12-01 1:43 ` Aaro Koskinen
2001-12-03 8:49 ` John McCabe
2001-12-04 23:00 ` Florian Weimer
2001-12-05 15:53 ` Ted Dennison
2001-12-06 0:17 ` Jeffrey Carter
2001-12-10 15:18 ` Dale Pontius
2001-12-10 17:44 ` Pascal Obry
2001-12-01 3:44 ` Nick Roberts
2001-12-01 20:09 ` Heiko Hamann
2001-12-02 4:49 ` Jeffrey Carter
2001-12-02 10:44 ` Pascal Obry
2001-12-04 11:43 ` john mann
2001-12-04 14:25 ` Ted Dennison
2001-12-05 9:46 ` John McCabe
2001-12-02 10:07 ` Mark Lundquist
2001-12-03 14:43 ` Ted Dennison
2001-12-09 12:31 ` Robert Dewar
2001-12-01 9:26 ` Gisle Sælensminde
2001-12-01 10:13 ` Pascal Obry
2001-12-02 17:49 ` Bertrand Augereau
2001-12-03 14:39 ` Ted Dennison
2001-12-03 16:19 ` Jeffrey Carter
2001-12-03 19:04 ` Ted Dennison
2001-12-03 20:56 ` Georg Bauhaus
2001-12-03 21:17 ` Preben Randhol
2001-12-03 21:20 ` Preben Randhol
2001-12-04 23:02 ` Florian Weimer
2001-12-05 16:05 ` Georg Bauhaus
2001-12-06 23:33 ` Florian Weimer
2001-12-04 2:35 ` Jeffrey Carter
2001-12-04 6:54 ` Steven Deller
2001-12-04 22:05 ` Bertrand Augereau
2001-12-06 4:25 ` Richard Riehle
2001-12-07 20:02 ` Hyman Rosen
2001-12-09 19:32 ` Richard Riehle
2001-12-11 16:14 ` Hyman Rosen
2001-12-14 0:36 ` Will
2001-12-19 22:23 ` Hyman Rosen
2001-12-17 17:37 ` Richard Riehle
2001-12-20 23:02 ` Hyman Rosen
2001-12-23 4:12 ` Will
2001-12-23 6:41 ` James Rogers
2001-12-04 22:37 ` Pascal Obry
2001-12-05 15:57 ` Georg Bauhaus
2001-12-05 17:12 ` Larry Kilgallen
2001-12-07 13:21 ` Jacob Sparre Andersen
2001-12-07 15:16 ` Aaro Koskinen
2001-12-07 16:50 ` Preben Randhol
2001-12-07 17:03 ` Jacob Sparre Andersen
2001-12-07 17:26 ` Aaro Koskinen
2001-12-07 18:32 ` Preben Randhol
2001-12-07 20:23 ` Wes Groleau
2001-12-07 17:11 ` Ted Dennison
2001-12-07 18:47 ` Preben Randhol
2001-12-07 16:16 ` Preben Randhol
2001-12-07 17:04 ` Jacob Sparre Andersen
2001-12-07 16:26 ` Ted Dennison
2001-12-07 17:08 ` Jacob Sparre Andersen
2001-12-09 12:27 ` Robert Dewar
2001-12-10 16:51 ` Jacob Sparre Andersen
2001-12-10 17:33 ` Jeff Creem [this message]
2001-12-07 16:45 ` Georg Bauhaus
2001-12-07 17:02 ` Preben Randhol
2001-12-07 17:10 ` Jacob Sparre Andersen
2001-12-07 18:12 ` Pascal Obry
2001-12-07 18:50 ` Preben Randhol
2001-12-07 18:54 ` Pascal Obry
2001-12-07 20:40 ` Preben Randhol
2001-12-07 22:01 ` Pascal Obry
2001-12-07 18:19 ` Jeffrey Carter
2001-12-10 9:59 ` Ole-Hjalmar Kristensen
-- strict thread matches above, loose matches on Subject: below --
2001-12-02 19:37 Gautier Write-only-address
2001-12-23 10:33 Gautier Write-only-address
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox