From: Jim Nance <jlnance@avanticorp.com>
Subject: more cc and gcc
Date: Mon, 24 Mar 1997 14:04:22 -0500 (EST) [thread overview]
Message-ID: <9703241904.AA13267@halfpint.rtp.avanticorp.com> (raw)
Hello all,
I am sorry it has taken me so long to respond to the feedback I received in
response to my last post where I compared the code produced by cc and gcc on
the alpha. My father passed away the morning after I posted it, and I spent
the rest of the week in Wilmington, NC with my mother.
Since my last message I have learned several important things from postings
to axp-list, which I would like to comment on here. If you dont remember
my original message, take a look at:
http://www.acs.uncwil.edu/~jlnance/mmul/index.html
1) gcc does not do loop unrolling without the -funroll-loops flag
When I learned this I assumed that this was at the root of my problems,
especially after someone else reported that the 4x4 case ran 4 times
faster with the -funroll-loops flag on a PPro processor. Unfortunately,
while the -funroll-loops flag helps, it does not help a lot, certainly
not enough to make it competitive with cc. Given that it helps so much
on the PPro, it seems like an alpha specific problem. Does the PPro do
out of order instruction execution?
2) The 4x4 case runs much faster if the sum is accumulated into a temporary
variable.
For a more complete description of this see:
http://www.redhat.com/support/mailing-lists/archives/axp-list/1997-March/0588.html
To me this seems like another optimizer problem. When I wrote the code I
put the temporary 4x4 matrices on the stack so that the compiler would know
that it could optimize them w/o having to worry about any aliasing problems
or things like that. If accumulating the sum into a temporary variable will
speed things up, I would expect the compiler to figure this out and do it.
3) It seems that my method of timing things was non-portable.
I have rewritten my program to use gettimeofday(), which is hopefully more
portable. Someone also requested run times for smaller matrices that would
fit inside a 1M cache. Here are the new results. These were run under
Digital Unix on an AlphaStation 500/500 (8M cache) running Digital Unix 4.0.
The binaries are statically linked, so they should run under any version
of Linux/Alpha that has a.out support. The binaries were compiled as:
cc -non_shared -newc -std1 -fast simple.c -o mmul.cc
gcc -static -funroll-loops -O3 simple.c -o mmul.gccO3
Time to square 1000x1000 matrix 2 times:
cc 136.883789 44.124023 50.171875
gcc 185.990235 52.113281 104.900391
Time to square 400x400 matrix 3 times:
cc 8.157226 2.879883 4.245118
gcc 11.041015 3.520508 9.496093
Time to square 200x200 matrix 24 times:
cc 5.155273 2.146484 3.970704
gcc 7.411132 2.407227 9.121094
Again, I am supplying this data not because I want to complain about gcc,
which I have in general found to be an excellent program, but because this
test program is simple enough that it may be useful for people interested
in optimizing gcc. If you are interested in getting the new source or
precompiled binaries, take a look at
http://www.acs.uncwil.edu/~jlnance/mmul/update/index.html
--
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
reply other threads:[~1997-03-24 19:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox