Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Toon Moene <toon@moene.indiv.nluug.nl>
Subject: Re: compiler efficency
Date: Tue, 28 Jan 97 21:02:09 +0100	[thread overview]
Message-ID: <6672a3b3a2d30eebadbbc2f13ed1f25a.axp-list@archive.invalid> (raw)

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

             reply	other threads:[~1997-01-28 20:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-28 20:02 Toon Moene [this message]
     [not found] <9701282002.AA15294@moene.indiv.nluug.nl>
1997-01-29  0:10 ` compiler efficency Michal Jaegermann
  -- strict thread matches above, loose matches on Subject: below --
1997-01-28 23:23 Huw Davies
1997-01-28 11:22 Claus Denk
1997-01-27 22:41 Craig Burley
1997-01-27 22:15 Przemek Klosowski
1997-01-27 21:48 Toon Moene
1997-01-27 20:51 Robert Williams
1997-01-27 20:37 Claus Denk
1997-01-27 20:35 ` Brett McCormick
1997-01-27 20:37 ` Lev D Gelb
1997-01-27 21:15 ` Jim Nance
1997-01-27 22:13 ` Scott Locklin
1997-01-27 22:41 ` Michal Jaegermann
1997-01-27 23:35 ` Richard Henderson
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