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: 103376,38fc011071df5a27 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-04 07:51:24 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!uio.no!193.216.69.35.MISMATCH!dax.net!juliett.dax.net!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Ideas for Ada 200X References: <7vu1b640gf.fsf@vlinux.voxelvision.no> From: Ole-Hjalmar Kristensen Message-ID: <7vhe75522e.fsf@vlinux.voxelvision.no> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 04 Jun 2003 14:50:50 GMT NNTP-Posting-Host: 193.216.12.150 X-Complaints-To: abuse@tele2.no X-Trace: juliett.dax.net 1054738250 193.216.12.150 (Wed, 04 Jun 2003 16:50:50 MET DST) NNTP-Posting-Date: Wed, 04 Jun 2003 16:50:50 MET DST Organization: Tele2 Norway AS Public Access Xref: archiver1.google.com comp.lang.ada:38605 Date: 2003-06-04T14:50:50+00:00 List-Id: Bill Findlay writes: > On 4/6/03 11:10, in article 7vu1b640gf.fsf@vlinux.voxelvision.no, > "Ole-Hjalmar Kristensen" wrote: > > > I think the difference between C++ and Ada is the compiler. I run both > > through gcc, and got identical results. The function "+" is about > > three times slower on my system, as you can see. This is a bit > > disappointing, I'll run it through gcc 3.2 later and see if it does > > any better. > ... > > procedure Matrix_fun is > > subtype M_Index is Integer range 1..100; > > type Matrices is array(M_Index,M_Index) of Integer; > > > > function "+"(M1,M2: Matrices) return Matrices is > > Tmp : Matrices := M1; > Why the redundant copy? ^ > > > begin > > for I in M1'Range(2) loop > > for J in M1'Range(1) loop > > Tmp(I,J) := M1(I,J) + M2(I,J); > N.B. Not Tmp............^ Just shows that even Ada cannot protect you completely from brain farts. However, even if I remove the assignment, I get essentially the same results. Keeping the tmp := M1 assignment and substituting Tmp(I,J) := Tmp(I,J) + M2(I,J); actually reduces the average time to .600 seconds. Optimizers are strange animals. > > > end loop; > > end loop; > > return Tmp; > > end "+"; > > pragma Inline("+"); > I managed to get it to run in .393 seconds (clock time) by the following hack: Tmp : matrices; for Tmp'Address use M1'address; ...... Now we are down to only 100% increase in time. -- Ole-Hj. Kristensen ****************************************************************************** * You cannot consistently believe this sentence. ******************************************************************************