Computer Chess Club Archives




Subject: Re: Differences between 0x88 ,10x12 and Bitboards!?

Author: Gerd Isenberg

Date: 09:09:33 11/20/02

Go up one level in this thread

On November 19, 2002 at 19:09:23, Vincent Diepeveen wrote:

>On November 19, 2002 at 15:48:57, Gerd Isenberg wrote:
>>>If you agree with me that the focus in the future is on evaluation,
>>>it will not come as a surprise that more complex patterns get more
>>>Let me present you a simple example. suppose you are scanning the board
>>>for example for your king safety, mobility or whatever, for complex
>>>patterns to evaluate:
>>>We are now at square sq and want to know whether a complex pattern is
>>>happening. For example:
>>>if( sq >= 8 && board[sq-8] == bishop && board[sq-7] == rook && ...
>>>What's your bitboard equivalent here?
>>>snelbord is in the L1 cache of course. Let's not worry about L1 or L2
>>>caches here. Also let's not worry about that both in bitboards *and*
>>>non bitboards you can get rid of at least 1 compare here.
>>>AFAIK you need an array for each value sq-8 and sq-7 to lookup the
>>>mask needed for the bitboard to AND with.
>>>lemme give a shot out of the hand, writing compatible code
>>>(so not writing out black & white :
>>>So here the bitboard equivalent without caring that in both
>>>examples we can save out a CMP:
>>>if( sq >= 8 && (Bishops[side]&Mask[sq-8]) && (Rooks[side]&Mask[sq-7]) && ...
>>>Best regards,
>>Yes Vincent, exactly.
>>But the sequence is wrong and that's the point.
>>Instead of a loop over all squares looking for one ore more properties, one get
>>a set of squares with the desired property, simply with a few bitwise
>>operations. Then you may traverse the found bits, if any.
>>Bitboards work like SIMD.
>That is not possible with a big evaluation.

Hi Vincent,

What a thread, simply about the mapping of some bits.

What is not possible?
Don't know what you mean with big evaluation.

>That is like doing n operations at n elements instead of log n.

Hmm, i find your sample pattern approach behaves more O(2) like:
May be the reason you call your eval big :-)

>Also another effect is there which is very intuitively true and very
>easy to understand for everyone except Bob.

I don't understand it too. Do you mean the mapping of square (0x88) coordinates
to board coordinates in your head?

I use a simple MFC-MDI-Bitboard viewer for debug purposes.
Just copying bitboard values from watch-window (decimal or hex) via clipboard to
this bitboard viewer makes things quite easy to inspect.

>That's that with more difficult knowledge patterns, the bitboard
>pseudo code is too difficult to read and bugfix a month later.

I found the opposite is true. Using type safe inlined functions (or defined
macros) gains a lot of abstraction level without any loss of performance. But
that's independent from using bitboards or not.

Sometimes an initial animosity with some "new" paradigmns becomes a "severe"
prejudice. Some of our customers, sitting in a gas distributors control room,
not familar with GUIs, even claim "only a dead mouse is a good one".

>>Btw. instead of Mask[sq] you should use 1<<sq on 64 bit hardware. Often, if you
>SHL is too slow on P4 to use. 2 cycles. Array lookup might be faster
>than that.

P4 is no reference cpu for me.
But the 2 cycles are not so bad if other pipes are busy.
I am always fighting with lookup versus computation. Often i try both with some
conditional compiles and look from time to time what is currently faster.

All the athlon direct path mmx-instructions i used in generating attack
bitboards via dumb7fill or Kogge-Stone have also 2 cycles execution latency.
Even if there are only two mmx-integer pipes (not quite sure about that one with
xp+), i got an average latency of 0.5 cycles instead of the expected one cycle!
So two cycles seem to be a worst case latency including instruction

Athlon XP 2.1+ is about twice as fast as 2GHz P4 here.

Btw. i'm also impressed by some 0x88 properties, pointed out by Tony and Heiner
recently, the implicite unique distance relationship of square differences is a
quite nice feature.


This page took 0.02 seconds to execute

Last modified: Thu, 07 Jul 11 08:48:38 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.