[YLUG] Why is this so much faster on an Opteron?
Roger Leigh
rleigh at whinlatter.ukfsn.org
Wed Sep 26 21:26:09 BST 2007
"Robert Hulme" <rob at robhulme.com> writes:
> I have this code:
>
> #include <stdio.h>
>
> int main(char **argv,int argc) {
> double f=0;
> int i=0;
> int j=0;
> int c=1;
> for(i=0;i<10000;i++)
> for(j=0;j<10000;j++,c++)
> f=f+0.505/(j+i/(1.0+j+i));
> return (int)f%10;
> }
What's the point of c?
> If I compile it with -O2 it takes about 40 seconds to run on my
> Pentium D (dual core pentium 4) desktop, but only about 2 seconds
> (when using time) to run on a 2.2Ghz Opteron.
>
> How long does it take to run on peoples machines?
% gcc-4.2 -O2 -o test test.c
% time ./test
./test 8.18s user 0.00s system 94% cpu 8.675 total
% cat /proc/cpuinfo
processor : 0
cpu : 7447A, altivec supported
clock : 1416.666661MHz
revision : 0.2 (pvr 8003 0102)
bogomips : 83.20
timebase : 41620997
platform : PowerMac
machine : PowerMac10,1
motherboard : PowerMac10,1 MacRISC3 Power Macintosh
detected as : 287 (Mac mini)
pmac flags : 00000010
L2 cache : 512K unified
pmac-generation : NewWorld
Regards,
Roger
--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/
`- GPG Public Key: 0x25BFB848 Please GPG sign your mail.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
Url : http://mailman.lug.org.uk/pipermail/york/attachments/20070926/91553d31/attachment.bin
More information about the York
mailing list