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-Thread: 103376,7767a311e01e1cd X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 20 Oct 2006 18:54:10 -0500 Date: Fri, 20 Oct 2006 19:52:54 -0400 From: Jeffrey Creem User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: GNAT compiler switches and optimization References: <1161341264.471057.252750@h48g2000cwc.googlegroups.com> <9Qb_g.111857$aJ.65708@attbi_s21> In-Reply-To: <9Qb_g.111857$aJ.65708@attbi_s21> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <434o04-7g7.ln1@newserver.thecreems.com> NNTP-Posting-Host: 24.147.74.171 X-Trace: sv3-6JCCxfzpzwcFmveaCSBUUbqR7/+TXUfbKiqTFFGUtb1tYJZ0yMlrx0U7j+Y4GJRIvLB9ZDGDFtD5M/j!bNXm6qZp7fZxyUap7C4XUbi3ofacrnVF4NB7Olwvk02xygLqhCwbZsQ1PpU/UWQxfp9+uUQhAZ5s!d0s= 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.3.32 Xref: g2news2.google.com comp.lang.ada:7102 Date: 2006-10-20T19:52:54-04:00 List-Id: Jeffrey R. Carter wrote: > tkrauss wrote: > >> I'm a bit stuck trying to figure out how to coax more performance >> out of some Ada code. I suspect there is something simple (like >> compiler switches) but I'm missing it. As an example I'm using >> a simple matrix multiply and comparing it to similar code in >> Fortran. Unfortunately the Ada code takes 3-4 times as long. > > > 1st, make sure you're timing the same thing. How does Ada matrix > multiplication compare to FORTRAN? You don't know, because you're also > timing the random number generators and I/O. Ada.Text_IO, especially, is > quite heavy-weight compared to other languages. > > Here's my version of your program: > Note, I am the first one to jump to the defense of "Ada" in general but in this case, GNAT just plain sucks compared to GNU FORTRAN as it does a poor job on (at least) the inner loop (verified by looking at the output assembly) Jeff's (the other jeff :) modified version looks a little cleaner and actually runs faster (than even old "fixed version" that did not time the IO and made sure to just time the matrix multiply in both versions) but it does not time the zeroing of the elements of C which would be required if this were a real matrix multiply routine and not some test driver. However, even having said that, this not really equivilent version runs about 2x slower than the FORTRAN (with the same version of GCC) I don't see any meaningful excuse for why GNAT should be slower in this case but it clearly is. I tried looking at the tree dump generated by the front ends prior to going to the optimizer step (not something I have a lot of experience at) . One thing is clear is the trees generated by GNAT is quite a bit uglier and more verbose so it is not surprising that the optimizer is unable to fully clean things up resulting in the explosion of instructions at the assembly level.