From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 102b75,4820dfa6cb2bff3e X-Google-Attributes: gid102b75,public X-Google-Thread: 111c93,3626ccca6bb70e55 X-Google-Attributes: gid111c93,public From: Michael Gschwind Subject: Re: 21264 performance anomalies (was: Compaq to port ...) Date: 1999/04/11 Message-ID: <3710F546.CBA9A872@watson.ibm.com>#1/1 X-Deja-AN: 465192400 Content-Transfer-Encoding: 7bit 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> <7ej80q$o1a$1@news.tuwien.ac.at> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: news@btv.ibm.com X-Trace: news.btv.ibm.com 923858253 10390 32.226.106.186 (11 Apr 1999 19:17:33 GMT) Organization: IBM Research Mime-Version: 1.0 NNTP-Posting-Date: 11 Apr 1999 19:17:33 GMT Newsgroups: comp.os.linux.alpha,comp.arch Anton Ertl wrote: > > 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) The following behavior may be explained by the cache architecture? Here a short description of the prefetch unit on the 21264, a more detailed discussion can probably be found in Microprocessor Report (just don't read the sections which explain why Intel will inevitably win...) Each line in the instruction cache holds four instructions along with a "next-line" predictor and a set predictor. These two fields are immediately sent back to the cache inputs to start the next access. If the line contains a branch that is predicted taken, the predictor fields point to the cache line and set of the predicted target; otherwise, they simply point to the next sequential address. > > > 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? Yoy probably read the whole line, whether you need it or not -- the fetch probably decodes the whole line also, since the predictor described above does not actually indicate that you know WHERE in the line you will land... you later may have to discard those instructions? > > > 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? Maybe the architecture always decodes everything, even if it would not have to -- see above... NOPs would be cheaper in this scheme of things. > > > 3) Pushing the jmp into the next 16-byte block by adding nops saves > ~2cycles/NEXT. Why? > Two guesses for (3) 1 - Some bias for double word aligned lines (one MUX level less), combined with the cheapness of NOPs? 2 - Maybe the architects tried to be really smart about this, and can get the branch for free with some trickery, e.g., set the current lines next line predictor to itself and skip the branch??? This is just a wild guess, since to actually get something like this correct could be truely painful... M. Gschwind IBM TJ Watson Disclaimer: All the above are my personal opinions only, and in no way reflect my employer's opinions.