From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,13280cdb905844e4 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!x22g2000yqx.googlegroups.com!not-for-mail From: jonathan Newsgroups: comp.lang.ada 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) Organization: http://groups.google.com Message-ID: References: <993d3a57-ba45-4b5a-b61e-e6c2c8ad4283@d37g2000yqa.googlegroups.com> NNTP-Posting-Host: 143.117.23.62 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1266278976 8051 127.0.0.1 (16 Feb 2010 00:09:36 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 16 Feb 2010 00:09:36 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: x22g2000yqx.googlegroups.com; posting-host=143.117.23.62; posting-account=Jzt5lQoAAAB4PhTgRLOPGuTLd_K1LY-C User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.16) Gecko/2009121609 Iceweasel/3.0.6 (Debian-3.0.6-3),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:9259 Date: 2010-02-15T16:09:36-08:00 List-Id: 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. =A0When 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 :=3D 0.5; begin for i in 1 .. 10_000_000 loop x :=3D 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