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!15g2000yqa.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 13:17:25 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <993d3a57-ba45-4b5a-b61e-e6c2c8ad4283@d37g2000yqa.googlegroups.com> NNTP-Posting-Host: 143.117.23.232 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1266268645 21286 127.0.0.1 (15 Feb 2010 21:17:25 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 15 Feb 2010 21:17:25 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 15g2000yqa.googlegroups.com; posting-host=143.117.23.232; 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:9255 Date: 2010-02-15T13:17:25-08:00 List-Id: On Feb 15, 8:00=A0pm, sjw wrote: > On Feb 15, 6:26=A0pm, "(see below)" wrote: > > Is that 1 millisecond for 1e6 calls? This implies 1ns per call in C++. > > I find it incredible that a log function could be so fast. > > I think the loop body must be evaluated at compile-time in C++. > > I think it's a mixture of your point & Jonathan's; the loop body, with > the 500 calls to log10(), is executed once, then the compiler smartly > realizes that each iteration produces the same increment. Right ... there was never any mystery here ... that's why I thought a translation of the original bench wasn't necessary. 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. Jonathan