Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Fun with assembler
  1998-06-02  9:29 DU C/C++ compiler Vladimir Kamenov
@ 1998-06-04 16:14 ` Shane Steven Sturrock
  1998-06-05  3:35   ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Shane Steven Sturrock @ 1998-06-04 16:14 UTC (permalink / raw)
  To: axp-list

Finally getting somewhere with this alpha.

First some history.

We are working on some 64 bit code which isn't being optimised very well with 
gcc/egcs and as a result our 533Mhz alpha was being trounced by the MIPS 
R10000s in our SGI Challenge which only run at 200Mhz.  Said trouncing was of 
the order of 15% poorer performance for the alpha.  Grim situation for us, big 
laughs from the SGI boys.

Needless to say the problem is with the compilers.  The one on the SGI is smart 
enough to know how to get the best out of the chip, gcc/egcs is not.  Of course 
there is the option of DU C which is supposed to give about 30% better results 
than gcc.  I can now believe this having improved the performance of our code 
by a similar amount by a few simple changes to the assembler output of egcs.

The problem is that the alpha quite often gets stalled if you write code which 
is very tight, ie plenty of registers used and each instruction relies on the 
previous one.  The trick to getting better performance is to try and pair up 
your instructions but you can only really do this at the assembly level.  The 
good news is it is easy, you just need to find the busiest part of your 
program, in our case its an intensive repetitive operation in a loop.  Going 
through this code it quickly became apparent that the alpha was being stalled 
like mad, a typical example being:

   srl $3,7,$1
   srl $4,7,$2

The srl instruction must go down pipeline E0 and because there are two of these 
you end up with pipe E1 doing nothing.  The solution, stick an instruction in 
between the two:

   srl $3,7,$1
   addq $8,$6,$8
   srl $4,7,$2

Now the addq is using the second pipeline.  Do the same for the second srl and 
you're off and running.

Most instructions can run in both E0 and E1 but some are E0 or E1 only.  Mix 
and match, don't be affraid to put nop instructions in to pair up with an srl 
or whatever that you can't pair up with something else, you must try and keep 
things in step.

I have put the pdf files I got this from on my machine for anonymous ftp, you 
can get it from nova.bru.ed.ac.uk in the /pub directory, the original site for 
these is
 http://www.partner.digital.com/www-swdev/pages/Home/TECH/documents/alpha_cookboo
k/biblio.htm.  

The most interesting section is on the internal architecture.  There are good 
descriptions and examples of code to look at.  Now, if I can just squeeze a bit 
more out of it, we're already 30% faster than the MIPS, there must be something 
more I can do...... :-)

Dr. Shane Sturrock - sss@holyrood.ed.ac.uk
kernel: Calibrating delay loop.. ok - 529.53 BogoMIPS
Mmmmmmmmmmm :-)


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

* Re: Fun with assembler
@ 1998-06-04 18:18 Greg Lindahl
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Lindahl @ 1998-06-04 18:18 UTC (permalink / raw)
  To: Shane.Sturrock; +Cc: axp-list

> We are working on some 64 bit code which isn't being optimised very well with 
> gcc/egcs and as a result our 533Mhz alpha was being trounced by the MIPS 
> R10000s in our SGI Challenge which only run at 200Mhz.  Said trouncing was of 
> the order of 15% poorer performance for the alpha.  Grim situation for us, big 
> laughs from the SGI boys.

15% slower, for a machine which costs 1/3 as much? Yeah, that's a
trouncing all right.

I think that the egcs folks are working on some instruction
scheduling. But you shouldn't be dismayed by losing by 15%. I just
presented a poster at the DoD HPC User's Group meeting in which
a CFD code on my 64-node Alpha cluster was beaten by 30% by a 64-node
SGI O2k. My cluster costs 1/10 as much, and I can scale it much bigger
than 128 nodes. For this code, that's a great result, even though
I know the compiler could do a better job.

Has anyone played with the egcs instruction scheduler?

-- g


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

* Re: Fun with assembler
  1998-06-04 16:14 ` Fun with assembler Shane Steven Sturrock
@ 1998-06-05  3:35   ` Richard Henderson
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Henderson @ 1998-06-05  3:35 UTC (permalink / raw)
  To: Shane Steven Sturrock, axp-list

On Thu, Jun 04, 1998 at 04:14:39PM +0000, Shane Steven Sturrock wrote:
> Needless to say the problem is with the compilers.  The one on the SGI
> is smart enough to know how to get the best out of the chip, gcc/egcs
> is not.

Compiler version and source used?  

> The trick to getting better performance is to try and pair up 
> your instructions but you can only really do this at the assembly level.

The Haifa scheduler used in EGCS knows about instruction issue and
pipelines.  It doesn't know about how alignment affects issue, but
that's not nearly as drastic a problem.

You may be interested to look at the scheduling visualizations
produced by the Haifa scheduler when you give gcc the -dR option.

So the claim is that we should be doing the right thing now.

> ... there must be something more I can do...... :-)

The best thing that you can do is to examine your source code, identify
the hot spots that are not being optimized properly, and submit reports
with example source to the egcs list.


r~


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

end of thread, other threads:[~1998-06-05  3:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-06-04 18:18 Fun with assembler Greg Lindahl
  -- strict thread matches above, loose matches on Subject: below --
1998-06-02  9:29 DU C/C++ compiler Vladimir Kamenov
1998-06-04 16:14 ` Fun with assembler Shane Steven Sturrock
1998-06-05  3:35   ` Richard Henderson

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