Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Huw Davies <H.Davies@latrobe.edu.au>
Subject: Re: compiler efficency
Date: Wed, 29 Jan 1997 10:23:50 +1100	[thread overview]
Message-ID: <40ffdccf8758a12e2e23c40f2d24e75d.axp-list@archive.invalid> (raw)

At 09:02 PM 1/28/97 +0100, 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

To improve numerical precision, you should start with the smallest fractions
first. I had to post this as it's the first time I can show off all those
years spent playing Numerical Analyst... A simple change gives:

        PROGRAM EULER
        DOUBLE PRECISION GAM, FAC
        GAM = 1.0d0
        NMAX=100000000
        FAC = dble(NMAX) 
        DO I=2,NMAX
          GAM=GAM+1.0d0/FAC
          FAC=FAC-1.0d0
        ENDDO
        GAM = GAM - DLOG(dble(NMAX))
        WRITE(*,*) GAM
        WRITE(*,*) 'Exact: 0,57721566490153286060'
        END

And run times (where linux.f is the original program and linux2.f is the
modified version) for a alphastation 200 4/166 with Digital Unix are:

lux-1> time ./linux
  0.577215669900188     
 Exact: 0,57721566490153286060

real   40.3
user   38.1
sys    0.1
lux-2> time ./linux2
  0.577215669898866     
 Exact: 0,57721566490153286060

real   38.4
user   37.1
sys    0.1

 Huw Davies                      | e-mail: Huw.Davies@latrobe.edu.au
 Information Technology Services | Phone: +61 3 9479 1550  Fax: +61 3 9479 1999
 La Trobe University             | "My Alfas keep me poor in a monetary
 Melbourne Australia 3083        | sense, but rich in so many other ways"

--
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 23:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-28 23:23 Huw Davies [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 20:02 Toon Moene
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