From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <199701290010.RAA09121@ellpspace.math.ualberta.ca> Date: Tue, 28 Jan 1997 17:10:28 -0700 (MST) From: Michal Jaegermann Subject: Re: compiler efficency In-Reply-To: <9701282002.AA15294@moene.indiv.nluug.nl> Toon Moene wrote: > > 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 I tried this loop on the following machine (275 MHz Cabriolet): cpu model : EV4 cpu variation : 0 cpu revision : 0 cpu serial number : Linux_is_Great! system type : Cabriolet system variation : 0 system revision : 0 system serial number : MILO-0000 cycle frequency [Hz] : 274951883 timer frequency [Hz] : 1024.00 page size [bytes] : 8192 phys. address bits : 34 max. addr. space # : 63 BogoMIPS : 271.58 kernel unaligned acc : 0 (pc=0,va=0) user unaligned acc : 0 (pc=0,va=0) cpu : Alpha A compiler is gcc version 2.7.2, as distributed with RH 4.0, and programs were compiled with 'fort77 -O6' (but a peek into a generated assembler code does not reveal any differences with -O3). Times were like this: For an original version 20.94user 0.00system 0:20.95elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (84major+25minor)pagefaults 0swaps For rewrite by Toon Moene 18.00user 0.00system 0:18.00elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (84major+25minor)pagefaults 0swaps And this one 15.78user 0.00system 0:15.80elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (84major+25minor)pagefaults 0swaps for the following variant: PROGRAM EULER DOUBLE PRECISION GAM, I, NMAX GAM = 1.0d0 NMAX=100000000. DO I=NMAX,2.,-1 GAM=GAM+1.0d0/I ENDDO GAM = GAM - DLOG(dble(NMAX)) WRITE(*,*) GAM WRITE(*,*) 'Exact: 0,57721566490153286060' END Yes, I realize that using a floating point loop control is, in general, a Very Bad Idea (TM). But in this particular case we can get away with it. :-) Unfortunately I cannot compare with results of Fortran compiler from DU. :-( Michal -- 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