Author: Vincent Diepeveen
Date: 16:52:29 06/05/01
Go up one level in this thread
On June 05, 2001 at 11:49:20, Daniel Clausen wrote: >Hi > >On June 05, 2001 at 11:28:27, Vincent Diepeveen wrote: >> >>In this piece of crap code i see everywhere: >> >> if (side == WHITE) >> tsq = B->WhiteKnights; >> else >> tsq = B->BlackKnights; >> >>Note you can eliminate these branches, which speeds code up bigtime. >> >>In a test to generate for white a few million of times a list of moves >>the branches will be correctly predicted, but normally spoken you get >>a big misprediction there as then you generate for white and next >>move for black, that hurts :) > >First, note that the same if (side == WHITE) appears in the same function >several times so if side is WHITE on the first check, it's likely that it stays >WHITE until the end of the function. I'm no expert on how P3 does BTB. Doesn't BTB reference adresses rather than variables? Because otherwise it must remember the value of a variable and not a few bits of the branch... Now it will never be a perfect 1111 prediction. It won't be a 1010101010101 prediction either, because you have moves stored. So it will be a very weird sequence. Hence 50% chance at misprediction *each branch*. If BTB references adresses as i guess it does do that, then it'll have a hard time. note that all this discussion about BTB is useless anyway, because a chessprogram has way more as 512 branches i may hope for it, which is the size of the PII BTB. That means if it's first-in-last-out system this BTB, that it will always predict fall through. So a perfect 50% chance that something gets mispredicted... >Second, there are processors which use more than 1 bit for branch prediction. (I >think the Sparc-architecture is one of them, but I'm not sure) So recognizing >simple patterns like 101010 or thelike would not be a problem for such >architectures either. > >Note that I don't imply with this posting that I actually like the code you >[Diep] quoted. But it's also not as simple as replacing "B->WhitePawns" and >"B->BlackPawns" etc with "B->Piece[PieceType][sideToMove]". I guess that it's >more likely for bitboard programs that different pieces need special treatment. >This is because information tends to be 'scattered' in different bitboards for >different pieces. > >Regards, > >Sargon
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.