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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,1d575f572a099528 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-07 09:03:34 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed1.uni2.dk!news.net.uni-c.dk!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: What is faster Ada or C? Date: Fri, 07 Dec 2001 18:03:33 +0100 Organization: Centre for Chaos and Turbulence Studies, Niels Bohr Institute Message-ID: <3C10F665.FF7D0E4A@nbi.dk> References: <3c08314d$0$158$9b622d9e@news.freenet.de> <3C0BA624.7A12BFA1@boeing.com> <3C10C26B.AA451459@nbi.dk> NNTP-Posting-Host: alf.nbi.dk Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.net.uni-c.dk 1007744613 16970 130.225.212.55 (7 Dec 2001 17:03:33 GMT) X-Complaints-To: usenet@news.net.uni-c.dk NNTP-Posting-Date: Fri, 7 Dec 2001 17:03:33 +0000 (UTC) X-Mailer: Mozilla 4.78 [en] (X11; U; OSF1 V4.0 alpha) X-Accept-Language: fo,da,no,sv,is,de,fr,en Xref: archiver1.google.com comp.lang.ada:17585 Date: 2001-12-07T18:03:33+01:00 List-Id: Preben Randhol wrote: > On 07 Dec 2001 17:16:18 +0200, Aaro Koskinen wrote: > > Jacob Sparre Andersen writes: > >> * Why are the two programs below not equivalent? > >> * How can I get the Ada program to run as fast as the C++ program? > > [..] > >> Compilation...: gnatmake sqrt_timer -O3 -gnatn > > [..] > >> for i in 1 .. 10_000_000 loop > >> X := Sqrt (1.0 + X); > >> end loop; > > > > Did you try with -gnatp? I have tried both "-gnatp", "-funroll-loops" and other flags without any significant change in the timing results. > I tried to add the -gnatp switch. I compiled the Ada programs twice with > the -O3 and -S switches. Whether I add the -gnatp switch or not I get > the exact same assambler source. Is this correct? That's very likely. There is no need for range checks on the counter, and I seem to remember that the floating point operations (in x86 processors) can check for exceptions without extra code. > I think the difference between the Ada and C++ program is the Sqrt > function. Certainly. (On ix86 processors) GNU C++ inlines the sqrt operation built into the processor, while GNU Ada makes calls to a Sqrt function. > I simplified the two programs by removing sqrt (and using Float in Ada) > and then both programs run at the same speed, 66ms. Of course. Then there is no function call to inline. Jacob -- SSLUG's julekalender - fra den 1. til den 24. december p�: http://www.sslug.dk/julekalender/