From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,3626ccca6bb70e55 X-Google-Attributes: gid111c93,public X-Google-Thread: 102b75,4820dfa6cb2bff3e,start X-Google-Attributes: gid102b75,public From: anton@mips.complang.tuwien.ac.at (Anton Ertl) Subject: 21264 performance anomalies (was: Compaq to port ...) Date: 1999/04/08 Message-ID: <7ej80q$o1a$1@news.tuwien.ac.at>#1/1 X-Deja-AN: 464192905 References: <87d81hkqw0.fsf@pfaffben.user.msu.edu> <7eemp3$11ap@news1.newsguy.com> <370BA607.1F391244@moene.indiv.nluug.nl> <7ei0gg$1kg$1@news.tuwien.ac.at> <370CF898.BD85182@moene.indiv.nluug.nl> Organization: Institut fuer Computersprachen, Technische Universitaet Wien Newsgroups: comp.os.linux.alpha,comp.arch In article <370CF898.BD85182@moene.indiv.nluug.nl>, Toon Moene writes: > Anton Ertl wrote: > > And no, appendix A of the Alpha AXP Architecture reference manual does > > not cut it. Its "factor of" terminology is unclear, and, e.g., it does > > not explain the results I see on a 21264 when I vary > > http://www.complang.tuwien.ac.at/forth/threading/direct.c. > > Hmmm, I didn't realize there's actual evidence that the information in > the Alpha Architecture Manual is not sufficient Ok, I wanted to write this for some time, so here we go: The C program is this: #define NEXT goto **ip++ main() { static void *prog[] = {&&next,&&next,&&next,&&next,&&next, &&next,&&next,&&next,&&next,&&loop}; void **ip=prog; int count = 10000000; next: NEXT; loop: if (count>0) { count--; ip=prog; NEXT; } } Here's what egcs-1.03 produces for the first NEXT: 0x120000690 : ldah t2,153(t2) next: 0x120000694 : ldq t0,0(t1) 0x120000698 : addq t1,0x8,t1 0x12000069c : jmp zero,(t0),0x1200006a0 This takes 3.45s (~17 cycles/NEXT) Here are various variations on this code, with instructions before the "next:" jump target in parentheses: 0x1200006a0 ldq (nop) (ldah) (addq) nop 0x1200006a4 addq ldq ldq ldq nop 0x1200006a8 jmp addq addq addq ldq 0x1200006ac jmp jmp jmp addq 0x1200006b0 jmp 1.12s 2.56s 3.48s 3.45s 0.72s The conclusions I draw are: 1) Code should be aligned to 16-byte boundaries; Penalty for non-conformance: ~8 cycles/NEXT in this benchmark. Why so much? 2) In an unaligned block the kind of instruction *before* the jump target does play a role. nops are cheap, while the other instructions I tried apparently cost another ~5 cycles/NEXT. Why is that and why so much? 3) Pushing the jmp into the next 16-byte block by adding nops saves ~2cycles/NEXT. Why? Overall I see a factor of five variation in speed by simply inserting a few nops in the right spots. Crossposted to comp.os.linux.alpha,comp.arch. - anton -- M. Anton Ertl Some things have to be seen to be believed anton@mips.complang.tuwien.ac.at Most things have to be believed to be seen http://www.complang.tuwien.ac.at/anton/home.html