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,8c8550b9f2cf7d40 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-10 02:39:30 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!nycmny1-snf1.gtei.net!news.gtei.net!colt.net!news.tele.dk!news.tele.dk!small.news.tele.dk!uninett.no!news.powertech.no!dax.net!juliett.dax.net!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Is ther any sense in *= and matrices? References: From: Ole-Hjalmar Kristensen Message-ID: <7visre2rwv.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: Tue, 10 Jun 2003 09:38:57 GMT NNTP-Posting-Host: 193.216.12.150 X-Complaints-To: abuse@tele2.no X-Trace: juliett.dax.net 1055237937 193.216.12.150 (Tue, 10 Jun 2003 11:38:57 MET DST) NNTP-Posting-Date: Tue, 10 Jun 2003 11:38:57 MET DST Organization: Tele2 Norway AS Public Access Xref: archiver1.google.com comp.lang.ada:38890 Date: 2003-06-10T09:38:57+00:00 List-Id: "John R. Strohm" writes: > "Russ" <18k11tm001@sneakemail.com> wrote in message > news:bebbba07.0306082024.7cebb5df@posting.google.com... > > tmoran@acm.org wrote in message news:... > > > >Oh, really? I just did a test in C++ with 3x3 matrices. I added them > > > >together 10,000,000 times using "+", then "+=". The "+=" version took > > > >about 19 seconds, and the "+" version took about 55 seconds. That's > > > Would you be so kind as to post your code, and what C++ compiler > > > and what hardware you used? Your results seem quite different from > > > other people's. My old 900MHz Windows 2K machine using MSVC++ 5.0 > > > took 4.38 and 3.28 seconds, a factor of 1.33, and using Gnat 3.15p > > > on the same machine took 1.38 and 0.85 seconds, a ratio of 1.6 > > > Clearly, there's something substantially different between our > > > compilers/hardware/code. > > > > I'm using gcc 2.95.2 on a Sunblade 2000. I can't post the code, but it > > is a pretty standard vector/matrix implementation in C++. Actually, it > > is designed for very efficient indexing, perhaps at the expense of > > slightly less efficient construction (it has a pointer for each row of > > the matrix). That might explain part of the difference you are seeing, > > but certainly not all. Perhaps your choice of C++ compiler is a factor > > too. > > I think the point that Tom is trying to make is that your results are so far > out of line with expected reality that he suspects that your optimizations > for indexing may in fact be pessimizations. > Yes, on modern hardware, having a pointer for each row of the matrix usually leads to slower code. The reason is that the indexing operation by multilply/add is actually faster than fetching a pointer from an array and then adding, thereby incurring an extra memory fetch and cache pollution. The above holds for large matrices, I haven't investigated the effects on small matrices. > Without seeing your code, we aren't going to be able to tell very much. > > There is also this. You're on a Sunblade. I'm guessing that is a PowerPC. It's a SPARC. -- Ole-Hj. Kristensen ****************************************************************************** * This page intentionally left blank. ******************************************************************************