From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <6672a3b3a2d30eebadbbc2f13ed1f25a.axp-list@archive.invalid> X-Archive-Original-Message-ID: <9701282002.AA15294@moene.indiv.nluug.nl> Date: Tue, 28 Jan 97 21:02:09 +0100 From: Toon Moene Subject: Re: compiler efficency Claus Denk wrote: > Here you go: ( I was just posting the loop, as this is > where almost all the time is spent) [ ... Deleted ... ] To implement Richard Henderson's suggestion (which sounds reasonable to me), change the program as follows: PROGRAM EULER DOUBLE PRECISION GAM, FAC GAM = 1.0d0 FAC = 1.0d0 NMAX=100000000 DO I=2,NMAX FAC=FAC+1.0d0 GAM=GAM+1.0d0/FAC ENDDO GAM = GAM - DLOG(dble(NMAX)) WRITE(*,*) GAM WRITE(*,*) 'Exact: 0,57721566490153286060' END This is indeed a transformation that's not done by g77 or gcc (nor by f2c in the translation from Fortran to C). I seem to remember that SGI's Fortran compiler has an explicit option to _prohibit_ such an optimisation. I belief, though, that in most ordinary Fortran code few conversions from INTEGER to REAL occur. > Tests were done with -O3 on both gcc and f77. I got on > a 433 Mhz 21164/Linux This is actually not fair with respect to f77; its highest optimisation level is -O5; on the other hand, gcc -O3 -funroll-loops might result in a better figure for the gcc timing. > If anyone tries the program, please send me your results > (Compiler/Options Machine/OS), so I can add it to my > list. Hmmm, can't resist (this is on a 25 Mhz Motorola 68040 based NeXTStation - but my other computer is a 47 CPU Fujitsu :-) g77 -O2: 278.5 s g77 -O2: 251.7 s (with 'FAC') f2c + gcc -O2: 278.4 s f2c + gcc -O2: 260.1 s (with 'FAC') Cheers, Toon. -- 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