From: tmoran@acm.org
Subject: Re: Is ther any sense in *= and matrices?
Date: Mon, 09 Jun 2003 06:58:10 GMT
Date: 2003-06-09T06:58:10+00:00 [thread overview]
Message-ID: <6eWEa.73297$d51.141789@sccrnsc01> (raw)
In-Reply-To: bebbba07.0306082024.7cebb5df@posting.google.com
> > >about 19 seconds, and the "+" version took about 55 seconds. That's
> > took 4.38 and 3.28 seconds, a factor of 1.33, and using Gnat 3.15p
> I'm using gcc 2.95.2 on a Sunblade 2000. I can't post the code,
Here's my code. Please try it on the Sunblade 2000 with gcc 2.95.2
and let us know the results.
#include <stdio.h>
#include <time.h>
#define N 3
// 4.386/3.275= 1.33 10M N=3
struct matrices{int x[N][N];};
struct matrices f(struct matrices left, struct matrices right){
struct matrices result;
int i,j;
for(i=0;i<N;i++)
for(j=0;j<N;j++)
result.x[i][j]=left.x[i][j]+right.x[i][j];
return result;
}
void add_to(struct matrices left, struct matrices right){
int i,j;
for(i=0;i<N;i++)
for(j=0;j<N;j++)
left.x[i][j]+=right.x[i][j];
}
void set(struct matrices m, int v){
int i,j;
for(i=0;i<N;i++)
for(j=0;j<N;j++)
m.x[i][j]=v;
}
void main() {
int i;
clock_t t0,t1,t2;
matrices a;
matrices b;
printf("Go ");
set(a,0);
set(b,0);
add_to(a,b);
a = f(a,b);
t0 = clock();
for(i=0;i<10000000;i++)
add_to(a,b);
t1 = clock();
for(i=0;i<10000000;i++)
a = f(a,b);
t2=clock();
printf("%i %i %i",(int)CLOCKS_PER_SEC,(int)(t1-t0),(int)(t2-t1));
}
next prev parent reply other threads:[~2003-06-09 6:58 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
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 [this message]
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