Author: Dann Corbit
Date: 10:44:01 01/19/06
Go up one level in this thread
On January 19, 2006 at 12:45:10, Chan Rasjid wrote:
>
>When using bitboards, often we have arrays that require only indices 0 / 1.
>eg if we have no underpromotions, then there is either 1/2 knights per color.
>Sometimes ,in such situations, codes may be re-written without using the if ()
>statement. But whether such simple tricks can avoid the cost of branch
>misprediction ( I only have a vague idea about this ).
>
>X[i] where i = 0 / 1;
>
>1) if ( a & b ){
> j = X[1];
> }else{
> j = X[0];
> }
> //etc.. codes dependent on j.
>
>2) Now without if() :-
>
> j = X[(a & b)!= 0];
> //etc.. codes dependent on j.
>
>How (if ? ) can such a simple re-coding cause an improvement. Can there
>be some situations related to the above with significanr misprediction
>overheads ?
If you have only 0 and 1 outcomes:
Use an array of 2 function pointers and do this:
assert(expression == 0 || expression == 1);
foo[expression]();
Not any great shakes, but it might be worthwhile.
Most of the time, this sort of stuff is a complete waste of time.
The best way to speed up your program is to improve the algorithms.
The best goal would be to reduce the branching factor while maintaining the good
decisions.
IMO-YMMV.
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.