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!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!uns-out.usenetserver.com!news.usenetserver.com!pc03.usenetserver.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail Newsgroups: comp.lang.ada Subject: Re: GNAT compiler switches and optimization References: <1161341264.471057.252750@h48g2000cwc.googlegroups.com> From: Stephen Leake Date: Sat, 21 Oct 2006 06:45:37 -0400 Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (windows-nt) Cancel-Lock: sha1:jdabQjrjOzq1nlokIWf02bvFw8I= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 9fc394539fa55759e00d415574 Xref: g2news2.google.com comp.lang.ada:7110 Date: 2006-10-21T06:45:37-04:00 List-Id: Duncan Sands writes: > On Friday 20 October 2006 12:47, 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. > > GNAT GPL 2006 is based on gcc 3.4.6. For fortran you are using > gcc 4.2.0. Try using comparable compiler versions, eg: an Ada > aware gcc 4.2.0 (several linux distributions provide this) or > a gcc 3.4.6 version of fortran (i.e. some version of g77). I have a pre-release of GNAT 5.05, which is based on gcc 4.2. I tried tst_array with both -O2 and -O3; -O2 was faster. AdaCore says -O3 has "dangerous experimental optimizations; don't use it". Here's a comparison: GNAT 5.04, -O2 -gnatp: ./tst_array.exe 800 Init Time: 0.557314686 Mult Time: 20.139092538 1.99202E+02 1.96854E+02 1.88844E+02 1.84498E+02 GNAT 5.05, -O2 -gnatp: ./tst_array.exe 800 Init Time: 0.575690486 Mult Time: 12.160329316 1.99202E+02 1.96854E+02 1.88844E+02 1.84498E+02 Note that I timed the initialize with random separate from the matrix multiply; it could easily be that the random number generators are different. But that's a small effect. I don't have gfortran installed. -- -- Stephe