Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Bitboards

Author: Roberto Waldteufel

Date: 18:36:46 12/05/98

Go up one level in this thread



On December 05, 1998 at 17:22:43, Frank Phillips wrote:

>On a PII are programs based on bitboards inherently faster than those based  on
>integer arrays?

Hi Frank,

On the Pentium, you have two very useful assembler instructions for bitboards,
the bsf and bsr instructions that find the first or last 1 bit in a 32-bit
number. These instructions are ideally suited to bitboard operations, but they
used to be terribly slow. Not any more, however: on the PII and PPro processors,
these instructions are very fast. As long as the testing is done on CPU
registers (not in memory), a bsf or bsr instruction executes in either 1 or 2
CPU clocks (depending on pipelining efficiency). So on a PII or PPro I think
bitboards are a really big win, but if your program is going to be used on older
machines, you might think twice about using the bit scan instructions - they can
by more than 300 times slower in the worst case.

Be careful how you code your bitboard routines if you try them. You will need to
code them in assembler, and it's quite fiddly to get right. But when you do,
bitboards fly on a PII. You might gain a good insight into bitboards by looking
at Earnst Heinz's Darkthought web site. If you are interested in implementing
rotated bitboards, Bob Hyatt is preparing (has prepared?) an article for ICCA
publication on the subject. He sent me a rough draft copy, and I found it
explains rotated bitboard implementation very well indeed. Whether or not
rotated bitboards are right for you depends on your program's data structures
and also on your implementation. My own experiments on a PII have shown that I
can generate the same information using ordinary bitboards faster than I can
using rotated bitboards, but the implementation I use relies very heavily on the
bit scan instructions, and as I said, these only became fast on the more recent
pentiums, and the rotated bitboards would undoubtedly be far superior on any
machine that did not offer this fast bit scan capability (eg pentium plain and
pentium MMX, also 486 has bit scans but they are slow)

Hope this helps. Good luck!

Roberto



This page took 0.01 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.