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-7-bit X-Google-Thread: f5d71,304c86061dc69dba X-Google-Attributes: gidf5d71,public X-Google-Thread: 109fba,304c86061dc69dba X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,5cb36983754f64da X-Google-Attributes: gid103376,public X-Google-Thread: 1014db,304c86061dc69dba X-Google-Attributes: gid1014db,public X-Google-ArrivalTime: 2004-02-11 06:40:01 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!zeus.visi.com!news-out.visi.com!green.octanews.net!news-out.octanews.net!cox.net!news-xfer.cox.net!news2.telebyte.nl!newsfeed.stueberl.de!newsr1.ipcore.viaginterkom.de!btnet-peer1!btnet-feed5!btnet!carbon.eu.sun.com!new-usenet.uk.sun.com!not-for-mail From: Ole-Hjalmar Kristensen Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.lang.java Subject: Re: No call for Ada (was Re: Announcing new scripting/prototyping language) Date: 11 Feb 2004 15:23:12 +0100 Organization: Sun Microsystems Message-ID: References: <20040206174017.7E84F4C4114@lovelace.ada-france.org> <54759e7e.0402071124.322ea376@posting.google.com> <2460735.u7KiuvdgQP@linux1.krischik.com> <54759e7e.0402081525.50c7adae@posting.google.com> <54759e7e.0402091826.2847e0c@posting.google.com> <54759e7e.0402101819.95cec1d@posting.google.com> <402A29B4.3010807@noplace.com> NNTP-Posting-Host: europa2.norway.sun.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: new-usenet.uk.sun.com 1076509394 1132 129.159.113.162 (11 Feb 2004 14:23:14 GMT) X-Complaints-To: usenet@new-usenet.uk.sun.com NNTP-Posting-Date: 11 Feb 2004 14:23:14 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Xref: archiver1.google.com comp.lang.ada:5434 comp.lang.c:21880 comp.lang.c++:18688 comp.lang.java:2856 Date: 2004-02-11T14:23:14+00:00 List-Id: Marin David Condic writes: > Given that it is 100% legal Ada to build a procedure that contains > nothing but assembly language instructions, I'd be confident that one > could build Ada code that is just as fast as anything produced by any > compiler anywhere. So if one wants to get into high-speed shootouts > between languages, a ground rule has to be that you're comparing > similar code. > > If an Ada example uses a high level abstraction of a matrix and C > can't do that sort of abstraction, then C can't play in that game. If > the C example uses some raw chunk of memory and address arithmetic, > then the Ada example would need to be coded up in that style as well > (and yes, that can be done - but nobody who uses Ada typically *wants* > to. :-) > Only if you have similarly coded examples can you possibly hope to > determine if one compiler is more efficient than another. > > MDC Yes, but there are some caveats. Ada insists on getting floating point arithmetic "right", so it will typically do it differently than C, even though the Ada and C programs superficially look the same. For floating-point intensive programs, this may result in quite a performance hit. I recently ported a small ray-tracing kind of application from C to Ada, keeping largely to the structure of the original program, but using sensible Ada constructs where appropriate. First I verified that it indeed worked the same as the original, then turned off all checks and compiled both versions with -O3 and -funroll-all loops. The Ada version was slower by a factor of 2. Profiling showed that much of the time was spent in sqrt() and other math functions. Next, I imported the necessary functions from the C library and used those instead. This resulted in Ada and C versions which ran at the same speed. Some slight algorithmic optimizations later, the Ada version was approximately 20% faster than the C version. Profiling again, I found that about 10 seconds of a total of 40 seconds runtime was consumed in the truncate function. An inlined assmbler version of this reduced the time spent in truncate to 1-2 seconds, which was more reasonable. Note that neither the C version nor the Ada version are anywhere close to the limit in terms of speed, using the short vector instructions of the processor, I could probably get an overall speedup by a factor of 2-3 for this particular application if coded in assembler. > > Dmitry A. Kazakov wrote: > > There is a problem with that. C does not have arrays. Yet matrices, > > you know, are two-dimensional ones. So any comparison here would be > > suspicious. A program in C, supposed to multiply matrices would lack > > -- > ====================================================================== > Marin David Condic > I work for: http://www.belcan.com/ > My project is: http://www.jsf.mil/NSFrames.htm > > Send Replies To: m o d c @ a m o g > c n i c . r > > "Face it ladies, its not the dress that makes you look fat. > Its the FAT that makes you look fat." > > -- Al Bundy > > ====================================================================== > -- C++: The power, elegance and simplicity of a hand grenade.