comp.lang.ada
 help / color / mirror / Atom feed
From: Ole-Hjalmar Kristensen <oleh@vlinux.voxelvision.no>
Subject: Re: Is ther any sense in *= and matrices?
Date: Tue, 10 Jun 2003 09:38:57 GMT
Date: 2003-06-10T09:38:57+00:00	[thread overview]
Message-ID: <7visre2rwv.fsf@vlinux.voxelvision.no> (raw)
In-Reply-To: bc15fg$ccu@library2.airnews.net

"John R. Strohm" <strohm@airmail.net> writes:

> "Russ" <18k11tm001@sneakemail.com> wrote in message
> news:bebbba07.0306082024.7cebb5df@posting.google.com...
> > tmoran@acm.org wrote in message news:<AmNEa.67177$d51.133670@sccrnsc01>...
> > > >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.

 <snip>

-- 
Ole-Hj. Kristensen

******************************************************************************
* This page intentionally left blank.
******************************************************************************



  reply	other threads:[~2003-06-10  9:38 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-05 10:45 Is ther any sense in *= and matrices? Preben Randhol
2003-06-05 11:13 ` Vinzent Hoefler
2003-06-05 11:28   ` Preben Randhol
2003-06-05 11:53     ` Vinzent Hoefler
2003-06-05 15:27       ` Preben Randhol
2003-06-05 15:40         ` Vinzent Hoefler
2003-06-05 15:47           ` Preben Randhol
2003-06-05 16:38             ` Vinzent Hoefler
2003-06-05 17:16               ` Preben Randhol
2003-06-05 17:17               ` Preben Randhol
2003-06-05 17:59                 ` Vinzent Hoefler
2003-06-07 19:38             ` Russ
2003-06-08  6:46               ` John R. Strohm
2003-06-08 18:51                 ` Russ
2003-06-08 20:52                   ` tmoran
2003-06-09  4:24                     ` Russ
2003-06-09  5:13                       ` John R. Strohm
2003-06-10  9:38                         ` Ole-Hjalmar Kristensen [this message]
2003-06-10 16:11                           ` Wesley Groleau
2003-06-10 19:24                             ` Ole Kristensen
2003-06-10 18:33                           ` Russ
2003-06-10 23:16                             ` John R. Strohm
2003-06-09  6:58                       ` tmoran
2003-06-08 22:23                   ` John R. Strohm
2003-06-09  6:06                     ` Russ
2003-06-09 10:06                       ` Mango Jones
2003-06-08 22:56                   ` Bobby D. Bryant
2003-06-09  4:27                     ` Russ
2003-06-09  5:17                       ` John R. Strohm
2003-06-09 14:53                       ` Bobby D. Bryant
2003-06-09 17:46                         ` Russ
2003-06-10  9:57                           ` Ole-Hjalmar Kristensen
2003-06-05 12:33     ` John R. Strohm
2003-06-05 19:25   ` Wesley Groleau
2003-06-05 20:17     ` David C. Hoos
2003-06-05 20:52       ` Wesley Groleau
  -- strict thread matches above, loose matches on Subject: below --
2003-06-10 19:00 tmoran
2003-06-10 19:37 ` Ole Kristensen
2003-06-10 19:37 ` Ole Kristensen
2003-06-10 19:48 ` Ole Kristensen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox