Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Re: Perf. of F77 on Alpha
@ 1997-11-13 22:16 Claus Denk
  0 siblings, 0 replies; 14+ messages in thread
From: Claus Denk @ 1997-11-13 22:16 UTC (permalink / raw)


David van der Spoel wrote:
> >
> Actually, I just did. I had C-code from when we used to do these
> computation on i860 chips. The DEC compiler does *not* inline intrinsic
> functions, at least I have not found a way how to do it.
> The fortran compiler will inline it for me I hope...

Hi David,

wouldn't the compiler need the library functions (as sqrt) in 
assembler or in its internal format in order to be able to inline 
them ? At the moment of inlining, the compiler needs to know
about register usage and all that, so it think that the compiler
would probably need an internal representation of sqrt in order to
be able to inline it.

If you write your own fortran code for sqrt, it suppose it should
be quite difficult to write a function that comes even close to
the Digital "-math_library fast" sqrt, as these functions are
heavily optimized for the alpha. And even if your new sqrt now
might be inlined, the result would probably be a slower code.

The following (stupid) program:

        PROGRAM SQRTTEST
        REAL*8 A(0:9),SUM
        DO I=0,9
         A(I)=1.0D10*(I+1)
        ENDDO
        DO K=1,10000000
          DO I=0,9
            A(I)=dsqrt(A(I))
          ENDDO
        ENDDO
        SUM=0.0d0
        DO I=0,9
         SUM=SUM+A(I)
        ENDDO
        write(*,*) SUM
        END

takes 21 seconds when compiled with g77 -O2 -funroll-loops and 11
seconds when compiled with Digital f77 -fast on our 500 MHz 21164.
This difference should be mainly due to the efficient implementation
of the Digital sqrt library function.

By the way, does this mean that you are optimizing gromacs for the
alpha ?

regards, Claus

-- 
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

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Perf. of F77 on Alpha
@ 1997-11-13 22:13 Toon Moene
  0 siblings, 0 replies; 14+ messages in thread
From: Toon Moene @ 1997-11-13 22:13 UTC (permalink / raw)


[ I finally managed to re-subscribe ]

>  Actually if this would be really true that would be very
>  surprising.  It is really hard to slow down any sane
>  implementation of sqrt to that extent.  Newton-Raphson
>  converges very fast and there are some shortcuts (Alpha
>  does not have a sqrt in a hardware, does it?).

Ah, but the original code has this inner loop:

DO I=0,9
A(I)=dsqrt(A(I))
ENDDO

and recent Digital Fortran releases have ways to invoke a (special)  
runtime library routine to compute 4 sqrt's at a time - so as a  
free compiler competitor, you just can't win :-(

Of course, this is all moot once the 21264 arrives in quantity  
(Samsung !!!)

[ Intel ?  Whatsdat ?  Oh, yeah, I remember, ... those Pentium bugs ]

--
Toon Moene (mailto:toon@moene.indiv.nluug.nl)
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Phone: +31 346 214290; Fax: +31 346 214286
g77 Support: mailto:fortran@gnu.org; NWP: http://www.knmi.nl/hirlam

-- 
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

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Perf. of F77 on Alpha
@ 1997-11-13 22:08 Wes Bauske
  0 siblings, 0 replies; 14+ messages in thread
From: Wes Bauske @ 1997-11-13 22:08 UTC (permalink / raw)


Michal Jaegermann wrote:
> 
> >
> > Some tests I did indicate any Alpha divide (float/int) is slow.
> > The table lookup for sqrt() is probably the fastest technique for
> > an approximation.
> 
> Actually on machines like Alpha a table lookup is NOT a good technique
> in general.  It tends to generate page faults and kills caches.
> For a fast RISC a short localized computation can be vastly preferable
> over a table lookup.  Things were different in the past.

That's true if the table is large. Not true if the table is "reasonable"
Depends on page size but a 4K page gives you 1024 floats for a table,
sufficient for lots of types of calculations. In fact, certain RISC
vendor high performance libraries use this technique plus a twiddle.

> 
> If 1/sqrt() is on a critical path then a specialized code which computes
> this function instead of calling sqrt and dividing 1.0 by results
> could be a much better answer.

I agree. For mis-behaved functions, this is the only way to go.

> 
>   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

-- 
Regards,

Wes

-- 
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

^ permalink raw reply	[flat|nested] 14+ messages in thread
[parent not found: <346B7C36.F55B1A2@cica.es>]
* RE: Perf. of F77 on Alpha
@ 1997-11-13 20:16 Barksdale, Ray
  0 siblings, 0 replies; 14+ messages in thread
From: Barksdale, Ray @ 1997-11-13 20:16 UTC (permalink / raw)


Look at this paper. It mentions something about Alphas not having a int
divide instruction (section 4.1)

http://www.linuxexpo.org/1997/after/papers/davidm/paper-html/doc005.html

It mentions a few workarounds. It may help.

JRBiii

> Tom/David,
> 
> Actually the divide may be as much trouble as the sqrt() function.
> Some tests I did indicate any Alpha divide (float/int) is slow.
> The table lookup for sqrt() is probably the fastest technique for
> an approximation. Maybe you could modify your code to move the
	[Barksdale, Ray]  <snip>

-- 
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

^ permalink raw reply	[flat|nested] 14+ messages in thread
[parent not found: <346B57C0.41C6@paralleldata.com>]
* Re: Perf. of F77 on Alpha
@ 1997-11-13 19:40 Wes Bauske
  0 siblings, 0 replies; 14+ messages in thread
From: Wes Bauske @ 1997-11-13 19:40 UTC (permalink / raw)


Tom/David,

Actually the divide may be as much trouble as the sqrt() function.
Some tests I did indicate any Alpha divide (float/int) is slow.
The table lookup for sqrt() is probably the fastest technique for
an approximation. Maybe you could modify your code to move the
divide/sqrt() out of the loop?? Can it be pre-computed and reused
repeatedly? Maybe you can eliminate both the divide and sqrt()
with a table lookup/interpolate?? That works if you "know" the
range of values the code will use and you can tolerate the
error in the calculations. Stuff I do can tolerate such errors
if the table is reasonably finely sampled.

Wes

Tom Linden wrote:
> 
> You don't want to write your own routine (reinvent the wheel)  If you did,
> the most efficient would be a table lookup for a seed to a Newton=Raphson
> loop.  But how are you going to inline it?  with F77 this wont fit into an
> arithmetic statement function, with C you could build  macro, but this
> is a regressive computing technique.  Its the compiler!  Find a copiler
> that does the inlining.  I haven't looked at it but I would bet that DEC
> Fortran does this, I think they used to on the VAX.
> 
> On Thu, 13 Nov 1997, David van der Spoel wrote:
> 
> > Yes I have profiled my app, 80 % of the time is in one loop that has
> > the sqrt, or actually 1/sqrt which the DEC F77 compiler recognizes
> > and puts in a call to rsqrtf. However, the compiler should inline the
> > code for the rsqrt and then pipeline my loop, which now it doesn't.
> >
> > So I will probably write F77 code for the 1/sqrt (I have C-code for it)
> > unless I can find a smarter compiler
> >
> > Groeten, David.
> > ________________________________________________________________________
> > Dr. David van der Spoel               Biomedical center, Dept. of Biochemistry
> > s-mail:       Husargatan 3, Box 576,  75123 Uppsala, Sweden
> > e-mail: spoel@xray.bmc.uu.se  www: http://zorn.bmc.uu.se/~spoel
> > phone:        46 18 471 4205          fax: 46 18 511 755
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> >
> > --
> > 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
> >
> >
> 
> --
> 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

-- 
Regards,

Wes

-- 
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

^ permalink raw reply	[flat|nested] 14+ messages in thread
[parent not found: <Pine.SGI.3.96.971113110232.6251A-100000@zorn>]
* Re: Perf. of F77 on Alpha
@ 1997-11-13 10:06 David van der Spoel
  0 siblings, 0 replies; 14+ messages in thread
From: David van der Spoel @ 1997-11-13 10:06 UTC (permalink / raw)


Yes I have profiled my app, 80 % of the time is in one loop that has
the sqrt, or actually 1/sqrt which the DEC F77 compiler recognizes
and puts in a call to rsqrtf. However, the compiler should inline the
code for the rsqrt and then pipeline my loop, which now it doesn't.

So I will probably write F77 code for the 1/sqrt (I have C-code for it)
unless I can find a smarter compiler

Groeten, David.
________________________________________________________________________
Dr. David van der Spoel		Biomedical center, Dept. of Biochemistry
s-mail:	Husargatan 3, Box 576,  75123 Uppsala, Sweden
e-mail: spoel@xray.bmc.uu.se	www: http://zorn.bmc.uu.se/~spoel
phone:	46 18 471 4205		fax: 46 18 511 755
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-- 
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

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Perf. of F77 on Alpha
@ 1997-11-13  9:25 Stefan Schroepfer
  0 siblings, 0 replies; 14+ messages in thread
From: Stefan Schroepfer @ 1997-11-13  9:25 UTC (permalink / raw)


An 21164A does not have a hardware sqrt instruction, so changing
compiler will not improve the performance of your code, if sqrt
is really the critical part of it (profiled your app?).

So you have the options
- to write code that approximates sqrt
- to use a CPU with sqrt instruction (I think both the 21164PC
  an the still not released 21264 do have one)

David van der Spoel wrote:
> 
> Hi.
> 
> I am interested in the performance of fortran code on DEC
> Alpha/Linux machines generated by different compilers.
> Did anyone do a comparison of say,
> g77 / Microway NDP F77 / DEC F77 ? (anyone else?)
> On our DEC Workstation (@ 400 MHz) I find the performance of my
> computational chemistry (Molecular Dynamics) code rather disappointing:
> it runs at aboud 60% of the performance of an SGI R10k @ 195 Mhz.
> This probably has to do with a sqrt operation which the R10k has in
> hardware, but the silly DEC compiler just puts a function call in my code,
> probably inhibiting any pipelining...
> 
> Will my code improve if I compile with NDP fortran?
> Does NDP inline intrinsic math functions?
> Does G77?
> 
> Groeten, David.
>

-- 
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

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Perf. of F77 on Alpha
@ 1997-11-12 22:23 David van der Spoel
  0 siblings, 0 replies; 14+ messages in thread
From: David van der Spoel @ 1997-11-12 22:23 UTC (permalink / raw)


Hi.

I am interested in the performance of fortran code on DEC
Alpha/Linux machines generated by different compilers. 
Did anyone do a comparison of say,
g77 / Microway NDP F77 / DEC F77 ? (anyone else?)
On our DEC Workstation (@ 400 MHz) I find the performance of my
computational chemistry (Molecular Dynamics) code rather disappointing:
it runs at aboud 60% of the performance of an SGI R10k @ 195 Mhz.
This probably has to do with a sqrt operation which the R10k has in
hardware, but the silly DEC compiler just puts a function call in my code,
probably inhibiting any pipelining...

Will my code improve if I compile with NDP fortran?
Does NDP inline intrinsic math functions?
Does G77?

Groeten, David.
________________________________________________________________________
Dr. David van der Spoel		Biomedical center, Dept. of Biochemistry
s-mail:	Husargatan 3, Box 576,  75123 Uppsala, Sweden
e-mail: spoel@xray.bmc.uu.se	www: http://zorn.bmc.uu.se/~spoel
phone:	46 18 471 4205		fax: 46 18 511 755
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-- 
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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~1997-11-13 22:34 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <Pine.SGI.3.96.971112231225.4609A-100000@zorn>
1997-11-13  6:37 ` Perf. of F77 on Alpha Maurice W. Hilarius
1997-11-13 22:16 Claus Denk
  -- strict thread matches above, loose matches on Subject: below --
1997-11-13 22:13 Toon Moene
1997-11-13 22:08 Wes Bauske
     [not found] <346B7C36.F55B1A2@cica.es>
1997-11-13 21:41 ` Michal Jaegermann
1997-11-13 22:34   ` Tom Linden
1997-11-13 20:16 Barksdale, Ray
     [not found] <346B57C0.41C6@paralleldata.com>
1997-11-13 19:52 ` Michal Jaegermann
1997-11-13 19:40 Wes Bauske
     [not found] <Pine.SGI.3.96.971113110232.6251A-100000@zorn>
1997-11-13 16:00 ` Tom Linden
1997-11-13 16:18   ` David van der Spoel
1997-11-13 10:06 David van der Spoel
1997-11-13  9:25 Stefan Schroepfer
1997-11-12 22:23 David van der Spoel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox