comp.lang.ada
 help / color / mirror / Atom feed
From: jonathan <johnscpg@googlemail.com>
Subject: Re: Is there an Ada compiler whose Ada.Numerics.Generic_Elementary_Functions.Log(Base=>10, X=>variable) is efficient?
Date: Mon, 15 Feb 2010 16:09:36 -0800 (PST)
Date: 2010-02-15T16:09:36-08:00	[thread overview]
Message-ID: <f5bac059-9297-47a5-91b1-fb1fd0004345@x22g2000yqx.googlegroups.com> (raw)
In-Reply-To: e2677a02-0af1-47d3-9232-b0030e6a7452@15g2000yqa.googlegroups.com

I said:

>The remaining puzzle
> is the smallish difference between the gnat Log and the gcc Log. I
> will (also) leave this to the experts.  When I looked at this in
> the past it has always been because gnat did the calculation to 18
> significant figures (even if you use type
> Real is digits 15), gcc to 15.

Well, I can't resist .. its easy to demonstrate (on Intel cpu's).
Let's do a benchmark of 10_000_000 base e Log's with 15 digits
and then 18 digits.  Must compile without -gnatn or -gnatN
so that it doesn't optimize away the constant in the inner loop.
I just used -O3. (Couldn't find anything faster.)

with ada.numerics.generic_elementary_functions;
with text_io; use text_io;

procedure log_bench_2 is

  type Real is digits 15;
--type Real is digits 18;

  package Math is
     new ada.numerics.generic_elementary_functions(Real);
  use Math;
  x, y : Real := 0.5;

begin

  for i in 1 .. 10_000_000 loop
    x := Log (y);
  end loop;
  Put (Real'Image (x));

end log_bench_2;

Using 15 digits I get:

-6.93147180559945E-01
real    0m0.209s
user    0m0.208s
sys     0m0.000s

Using 18 digits I get:

-6.93147180559945309E-01
real    0m0.208s
user    0m0.208s
sys     0m0.000s

So 18 digits are calculated just as fast as 15.

Jonathan



  reply	other threads:[~2010-02-16  0:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-15 10:58 Is there an Ada compiler whose Ada.Numerics.Generic_Elementary_Functions.Log(Base=>10, X=>variable) is efficient? Colin Paul Gloster
2010-02-15 13:02 ` John B. Matthews
2010-02-15 14:17   ` Colin Paul Gloster
2010-02-15 17:19     ` John B. Matthews
2010-02-15 14:54 ` jonathan
2010-02-15 15:04   ` jonathan
2010-02-15 19:50     ` sjw
2010-02-16 16:50       ` Colin Paul Gloster
2010-02-15 18:26 ` (see below)
2010-02-15 18:51   ` jonathan
2010-02-15 20:00   ` sjw
2010-02-15 21:17     ` jonathan
2010-02-16  0:09       ` jonathan [this message]
2010-02-16 17:33   ` Colin Paul Gloster
2010-02-24 10:07     ` Colin Paul Gloster
2010-02-15 23:04 ` Jeffrey R. Carter
2010-02-16 14:54   ` Colin Paul Gloster
2010-02-16 15:24     ` Colin Paul Gloster
2010-02-16 19:01     ` Jeffrey R. Carter
2010-02-17 10:25       ` Colin Paul Gloster
2010-02-15 23:20 ` Randy Brukardt
replies disabled

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