From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 19158 invoked from network); 4 Jun 1998 16:09:20 -0000 Received: from hayes.bru.ed.ac.uk (sss@129.215.237.131) by mail2.redhat.com with SMTP; 4 Jun 1998 16:09:20 -0000 Received: (from sss@localhost) by hayes.bru.ed.ac.uk (8.8.7/8.8.7) id QAA25947 for axp-list@redhat.com; Thu, 4 Jun 1998 16:14:39 GMT Date: Thu, 4 Jun 1998 16:14:39 GMT From: Shane Steven Sturrock Message-Id: <199806041614.QAA25947@hayes.bru.ed.ac.uk> To: axp-list@redhat.com Reply-To: Shane.Sturrock@ed.ac.uk Subject: Fun with assembler In-Reply-To: X-Mailer: Applixware 4.3 (807.65.0.22) 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 :-)