Counting bits...

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Desperado
Posts: 879
Joined: Mon Dec 15, 2008 11:45 am

Re: Counting bits...

Post by Desperado »

Desperado wrote:Hello Marco,

as i remember you are using magicBitboards, if not just
forget what i write now.

Because you mentioned, the most important "bitcounts" are
done for the mobility, you may think about to extend the
MagicTables with a precalculated bitCountValue.
So to say, simple lookup.

Only an idea, of course memory issues are important too....

Unfortunatelly i cannot help with the xmm stuff. good luck

cheers Michael
Hello Marco,

It looks like Bob has elaborated and improved this idea.
At least it is introduced in Crafty 23.2 as posted in the general forum.

maybe it is also a profitable idea for stockfish, or at least
interesting enough to have a look at it.

regards, Micha
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Counting bits...

Post by mcostalba »

Desperado wrote:
Hello Marco,

It looks like Bob has elaborated and improved this idea.
At least it is introduced in Crafty 23.2 as posted in the general forum.

maybe it is also a profitable idea for stockfish, or at least
interesting enough to have a look at it.

regards, Micha
Hi Michael,

these are the cons I see with a very quick analysis, so perhaps very incorrect:

1) In SF mobility is not an attack bitboard but is further 'anded' with some others bitboards so that the resulting mobility bitboard set is much bigger then the attack set for a given piece. So the magic tables seems would be much more bigger and complicated, also the creation of the tables is absolutely not trivial and is not easy to prove the correctness under all cases.

2) Bob states a small speed gain, this means that it simply the additional complexity is hardly accettable in SF where we put an higher priority on simplicity then on performance.

3) There is a good possibility that this will be obsoleted out by the spread and increasing support of hardware POPCNT instruction (that SF already supports) and that is available on i7 i5 and i3 Intel chips that are going to repleace current architecture within an year.


So my personal opinion is that in the medium / long term POPCNT support is the way to go for mobility processing.

Things _could_ change in case a more sophisticated mobility calculation would tried, for instance a square-weighted mobility where the presence bit is further combined with a per-square specific weight. In this case a vectorial dot product hardware instruction would allow this technique to be explored and perhaps adopted (as was adopted by Bob in his Cray for the same reason: hardware support of dot product).