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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5cb36983754f64da X-Google-Attributes: gid103376,public X-Google-Thread: 1014db,304c86061dc69dba X-Google-Attributes: gid1014db,public X-Google-Thread: 109fba,304c86061dc69dba X-Google-Attributes: gid109fba,public X-Google-Thread: f5d71,304c86061dc69dba X-Google-Attributes: gidf5d71,public X-Google-ArrivalTime: 2004-02-11 14:58:34 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!newsfeed1.easynews.com!easynews.com!easynews!border1.nntp.sjc.giganews.com!nntp.giganews.com!local1.nntp.sjc.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 11 Feb 2004 16:58:32 -0600 Date: Wed, 11 Feb 2004 17:58:32 -0500 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 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) 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> In-Reply-To: <54759e7e.0402101819.95cec1d@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.77.160 X-Trace: sv3-eVwTuxkZ1dsMyVTmmnuHBfNtS/+S2ImsiNUSikdJwMGN2wzhhFqz8rZLSxZp30MgbVD6R+VY72LlB6i!W+klLXaZLeLvb2bdFoo7q6TtChJ2Oke9c8FixKrwQEvteC2d2skJDXIOB/BTYQ== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.lang.ada:5460 comp.lang.c:21981 comp.lang.c++:18773 comp.lang.java:2865 Date: 2004-02-11T17:58:32-05:00 List-Id: MSG wrote: > Can you write (*) a matrix multiplication routine in Ada, compile it > with GNAT and measure the number CPU cycles per FLOP, compare to a > similar routine in C? > The shootout seems to put GNAT closer to Perl and Java than to C/C++. As a matter of fact I am writing a fairly complex linear algebra package in Ada that is designed for high-performance in supercomputer type applications. I probably could write it in C and stay out of the asylum, but it would be a close call. Why? It does things like A := A*B; in place, with only a row sized temporary, and using Strassen's algorithm with almost no copying. For efficiency the code works not with an array type, but with a view that may share data with another view. That way I can, for example, divide an existing matrix into four smaller matrices in O(1) time and space. Eventually I will also have code present to support both transposed views of matrices, in fact I just finished the fast transpose code. That way I can transpose the right argument, and avoid doing it more than once. But if I did write the same code in C, I would not expect performance to be better. (There are a few cases where the parameter passing overhead in C would be higher, so performance would be technically worse, but only by a few instructions.) > (*) Only if you think the one on the shootout page is inadequate. Which shootout page, this one? http://dada.perl.it/shootout/matrix.html If so the only questions I would have is why are there no default initial values for the matrices to insure consistancy. (It would be possible for any implementation to fail unless overflow checking is turned off, and in Ada that can cause code to run slower.) Incidently on this page, on this test gcc takes ten milliseconds, GNAT takes 20 ms. Hardly in the same class as perl, 34.31 seconds, or even java, 73 milliseconds. Also I just submitted a new version of the strcat routine to fix a minor problem that resulted in the test being reported as failed. (The length was printed with leading spaces, and the test harness didn't expect that.) While I was at it I rewrote basically the whole thing: with Ada.Command_Line; use Ada.Command_Line; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Strings.Fixed; use Ada.Strings; with Ada.Text_Io; use Ada.Text_Io; procedure Strcat is N: Integer; Hello : String := "hello" & Ascii.Lf; begin if Argument_Count < 1 then N := 10_000; else N := Integer'Value(Argument(1)); end if; declare Buffer : Unbounded_String := N*Hello; begin Put_Line(Ada.Strings.Fixed.Trim (Integer'Image(Length(Buffer)),Left)); end; end Strcat; This results in about a 100x speed up. Is this the right way to write it and the code they had wrong? In one sense, that probably is true. But if I use Bounded_String, the version on the website is slightly faster, and both versions fall midway between the fast and slow Unbounded versions. (A version that just uses String is actually faster than the Unbounded String version. However, I think that version is a bit of a cheat. ;-) -- Robert I. Eachus "The war on terror is a different kind of war, waged capture by capture, cell by cell, and victory by victory. Our security is assured by our perseverance and by our sure belief in the success of liberty." -- George W. Bush