* Re: Interesting gcc to cc comparison
[not found] <Pine.LNX.3.95L01at.970318142302.18255A-100000@wopr.campus.luth.se>
@ 1997-03-18 13:33 ` Andreas Johansson
0 siblings, 0 replies; 5+ messages in thread
From: Andreas Johansson @ 1997-03-18 13:33 UTC (permalink / raw)
On Tue, 18 Mar 1997, Andreas Johansson wrote:
> So, with gcc 2.7.2.1 on Linux I don't see the phenomenon you are
> describing.
>
> This is my system for reference:
> Noname axppci 266MHz 15ns, 256k cache.
Oh, just a note, my processor can't execute that much in parallel, this is
probably why I don't see your problem. But you should probably try
compiling with -funroll-loops.
--
<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=->
: E-mail: ajo@wopr.campus.luth.se :
: S-mail: Andreas Johansson, Karhusvagen 5 6:618, 977 54 Lulea, SWEDEN :
: Have you had your dose of 261.62 BogoMIPS today? - Run Alpha! :
<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=->
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Interesting gcc to cc comparison
@ 1997-03-20 20:30 Claus Denk
0 siblings, 0 replies; 5+ messages in thread
From: Claus Denk @ 1997-03-20 20:30 UTC (permalink / raw)
Claus Denk wrote:
(replying to my own post):
of course it's
double sum = cc[ii][jj];
for(kk=0; kk<4; kk++) {
sum += aa[ii][kk] * bb[kk][jj];
}
cc[ii][jj] = sum;
sorry ...
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Interesting gcc to cc comparison
@ 1997-03-20 20:19 Claus Denk
0 siblings, 0 replies; 5+ messages in thread
From: Claus Denk @ 1997-03-20 20:19 UTC (permalink / raw)
Jim Nance wrote:
>
> Hello All,
> I have a program here that I thought you all might be interested in.
> Its a little benchmark that I wrote that multiplies 2 matrices. The nice
> things about it are that it is quite short and it does a good job of
> exposing weaknesses in gcc. Hopefully it will be of interest to people
> working on improving gcc.
> snip ...
> Here are the results for multiplying
> two 400x400 matrices 3 times:
>
> Simple 2x2 4x4
> cc 8.016346 2.849886 4.199832
> gcc -O2 12.232844 3.833180 10.182926
> gcc -O3 12.032852 3.383198 10.116262
>
Note: that was AlphaStation 500/500 384M, DU 4.0
Hi Jim and all,
I got your
source code and made some tests. We have a PC164/500 Mhz 1 Mb Cache
over here, and I would be interested in some of your timings for
smaller matrices, so that they fit into 1 Mb Cache. (I think your
machine has 8 Mb, right ?). Could you send me some ?
My results with your original program are:
(gcc -static -O3 -funroll-all-loops )
1 2 3
a.out 400 3 : 17.77 5.31 11.21
a.out 100 500 : 12.22 4.56 23.19
a.out 40 10000 : 11.28 4.29 28.74
(where i commented out the printf(".") + fflush(stdout) statements)
You can speed up mat_mul_3 quite a bit (for gcc) using a temporary
variable sum for the innermost loop, like you do in mat_mul_1:
double sum = 0;
for(kk=0; kk<4; kk++) {
sum += aa[ii][kk] * bb[kk][jj];
}
cc[ii][jj] = sum;
3
a2.out 400 3 : 7.71
a2.out 100 500 : 15.65
a2.out 40 1000 : 19.10
So that looks like as if gcc definitely could do something better
here (Or is the programmer supposed to do that ?).
I would be really interested in your results (with cc & gcc)
for the smaller matrices, so if you find the time...
I think I can not run the DU 4.0 binaries, due to my 2.0.23 kernel.
regards,
Claus Denk
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread[parent not found: <9703181310.AA03085@halfpint.rtp.avanticorp.com>]
* Re: Interesting gcc to cc comparison
[not found] <9703181310.AA03085@halfpint.rtp.avanticorp.com>
@ 1997-03-18 13:30 ` Andreas Johansson
0 siblings, 0 replies; 5+ messages in thread
From: Andreas Johansson @ 1997-03-18 13:30 UTC (permalink / raw)
On Tue, 18 Mar 1997, Jim Nance wrote:
> Hello All,
> I have a program here that I thought you all might be interested in.
> [...]
> two 400x400 matrices 3 times:
>
> Simple 2x2 4x4
> cc 8.016346 2.849886 4.199832
> gcc -O2 12.232844 3.833180 10.182926
> gcc -O3 12.032852 3.383198 10.116262
>
> The most interesting result is probably for the 4x4 matrices. Gcc really
> does poorly here, and I think I might know why. For the 4x4 case there
> are some for loops of the form for(ii=0; ii<4; ii++) which I am counting
> on the compiler to unroll so the math inside the loops can be done in
> parallel. It suspect that this is not happening.
This is not supposed to happend unless you specify -funroll-loops, I
believe.
Anyway, I tried it on Linux with gcc 2.7.2.1. The timing is screwed up
(about 1000 times wrong :), but you can still see the relative speed:
(256x256 matrix)
gcc -O2 0.038493 0.011104 0.011817
gcc -O3 0.036401 0.010734 0.011687
gcc -O2 -funroll-loops 0.037359 0.010688 0.010967
gcc -O3 -funroll-loops 0.035515 0.010243 0.010812
So, with gcc 2.7.2.1 on Linux I don't see the phenomenon you are
describing.
This is my system for reference:
Noname axppci 266MHz 15ns, 256k cache.
--
<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=->
: E-mail: ajo@wopr.campus.luth.se :
: S-mail: Andreas Johansson, Karhusvagen 5 6:618, 977 54 Lulea, SWEDEN :
: Have you had your dose of 261.62 BogoMIPS today? - Run Alpha! :
<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=->
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Interesting gcc to cc comparison
@ 1997-03-18 13:10 Jim Nance
0 siblings, 0 replies; 5+ messages in thread
From: Jim Nance @ 1997-03-18 13:10 UTC (permalink / raw)
Hello All,
I have a program here that I thought you all might be interested in.
Its a little benchmark that I wrote that multiplies 2 matrices. The nice
things about it are that it is quite short and it does a good job of
exposing weaknesses in gcc. Hopefully it will be of interest to people
working on improving gcc. I ran these tests under Digital Unix because
Linux does not run well on my current AlphaStation, but I would be
quite surprised if the results under Linux are any different.
The machine is an AlphaStation 500/500 with 384M of ram running Digital
Unix 4.0 Rev 464. The gcc compiler is 2.7.2.2, and the cc compiler
identifies itself as DEC C X5.6-054. I tested 3 different executables,
which were compiled using the flags:
gcc -static -O2
gcc -static -O3
cc -non_shared -newc -std1 -fast
The test program uses 3 different matrix multiplication methods. The first
is the simple across-a-row-down-a-column method that everyone learns in
school. The second is a modification of the first method using a 2x2
submatrix instead of a single element, and the third uses a 4x4 submatrix.
The use of submatrices is supposed to improve both locality and the ability
to execute operations in parallel. Here are the results for multiplying
two 400x400 matrices 3 times:
Simple 2x2 4x4
cc 8.016346 2.849886 4.199832
gcc -O2 12.232844 3.833180 10.182926
gcc -O3 12.032852 3.383198 10.116262
And here are the results for multiplying two 1000x1000 matrices 2 times:
Simple 2x2 4x4
cc 131.861392 43.131608 49.664680
gcc -O2 178.309534 52.414570 111.778862
gcc -O3 176.009626 51.997920 111.645534
The most interesting result is probably for the 4x4 matrices. Gcc really
does poorly here, and I think I might know why. For the 4x4 case there
are some for loops of the form for(ii=0; ii<4; ii++) which I am counting
on the compiler to unroll so the math inside the loops can be done in
parallel. It suspect that this is not happening.
The source code, Digital Unix assembler output, and statically linked
Digital Unix binaries are available from the URL:
http://www.acs.uncwil.edu/~jlnance/mmul/index.html
Hope this is interesting,
Jim
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1997-03-20 20:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <Pine.LNX.3.95L01at.970318142302.18255A-100000@wopr.campus.luth.se>
1997-03-18 13:33 ` Interesting gcc to cc comparison Andreas Johansson
1997-03-20 20:30 Claus Denk
-- strict thread matches above, loose matches on Subject: below --
1997-03-20 20:19 Claus Denk
[not found] <9703181310.AA03085@halfpint.rtp.avanticorp.com>
1997-03-18 13:30 ` Andreas Johansson
1997-03-18 13:10 Jim Nance
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox