Page 1 of 5

Speedup with bitboards on 64-bit CPUs

Posted: Fri Apr 27, 2007 10:39 am
by Tord Romstad
I've been using bitboards for a while, and I am somewhat disappointed with the performance. On my 32-bit Core Duo, they are about 20-30% slower than my old mailbox board, it is therefore tempting to revert to the old board representation. Before I do so, I would like to know: How much of a speedup do bitboard programs usually see when running on a 64-bit CPU? Can I expect bitboards to be competitive with a mailbox board for my program if I upgrade to the 64-bit Core 2 Duo?

Tord

Re: Speedup with bitboards on 64-bit CPUs

Posted: Fri Apr 27, 2007 11:34 am
by mjlef
I think it has been reported here Rybka, which Vasik says uses bitboards, runs about 60% faster on a 64 bit processor. I think the speed difference will depend greatly on what is being represented with 64 bit values.

Lately, I have kept my mailbox move generation, but use some incrementally update bitboards too. In this hybrid approach, pawn attacks, knight attacks and king attacks can easily be update with a could of simple XORs. I have a bit for each pawn position, so detection of isolated and passed pawns is very fast (not much faster than the older array poitning to the least advanced pawn on each file though). I then OR in other attacks for sweep pieces for mobility/space control and so on. Of course my program is very slow anyway.

Mark

Re: Speedup with bitboards on 64-bit CPUs

Posted: Fri Apr 27, 2007 12:20 pm
by hgm
I would not expect any speedup from bitboards compaired to mailbox, even in 64-bit mode, if you jsut use them to replace the move generator. For bulk move generation bitboards cannot beat mailbox. They are very much faster than mailbox for generating moves selectively (e.g. only captures, only checks), though. But if your program should be doing that a lot in order to see any benefits.

Re: Speedup with bitboards on 64-bit CPUs

Posted: Fri Apr 27, 2007 1:04 pm
by Tord Romstad
mjlef wrote:I think it has been reported here Rybka, which Vasik says uses bitboards, runs about 60% faster on a 64 bit processor. I think the speed difference will depend greatly on what is being represented with 64 bit values.
60% is a lot, but of course we don't know exactly what Rybka is doing. Does anyone have any numbers for Crafty, SmarThink or other bitboard engines?
Lately, I have kept my mailbox move generation, but use some incrementally update bitboards too. In this hybrid approach, pawn attacks, knight attacks and king attacks can easily be update with a could of simple XORs. I have a bit for each pawn position, so detection of isolated and passed pawns is very fast (not much faster than the older array poitning to the least advanced pawn on each file though). I then OR in other attacks for sweep pieces for mobility/space control and so on. Of course my program is very slow anyway.
So is mine. My program with a material only eval is slower than Crafty with a full eval.

Tord

Re: Speedup with bitboards on 64-bit CPUs

Posted: Fri Apr 27, 2007 1:13 pm
by Tord Romstad
hgm wrote:I would not expect any speedup from bitboards compaired to mailbox, even in 64-bit mode, if you jsut use them to replace the move generator. For bulk move generation bitboards cannot beat mailbox. They are very much faster than mailbox for generating moves selectively (e.g. only captures, only checks), though. But if your program should be doing that a lot in order to see any benefits.
I do generate moves incrementally with bitboards, and have separate move generation functions for captures, checks, non-captures and check evasions. But move generation doesn't consume a significant fraction of the CPU time in my program in any case, neither with bitboards nor with mailbox. The places where bitboards seem to be significantly slower are king safety evaluation, scanning for attacks in a single direction, and making and unmaking moves.

Tord

Re: Speedup with bitboards on 64-bit CPUs

Posted: Fri Apr 27, 2007 1:15 pm
by Pradu
Tord Romstad wrote:
mjlef wrote:I think it has been reported here Rybka, which Vasik says uses bitboards, runs about 60% faster on a 64 bit processor. I think the speed difference will depend greatly on what is being represented with 64 bit values.
60% is a lot, but of course we don't know exactly what Rybka is doing. Does anyone have any numbers for Crafty, SmarThink or other bitboard engines?
Lately, I have kept my mailbox move generation, but use some incrementally update bitboards too. In this hybrid approach, pawn attacks, knight attacks and king attacks can easily be update with a could of simple XORs. I have a bit for each pawn position, so detection of isolated and passed pawns is very fast (not much faster than the older array poitning to the least advanced pawn on each file though). I then OR in other attacks for sweep pieces for mobility/space control and so on. Of course my program is very slow anyway.
So is mine. My program with a material only eval is slower than Crafty with a full eval.

Tord
I get 2.2x speedup for Buzz from 32-bits to 64-bits on Core2. There's an open-source version of my program so you can see exactly what I'm doing.

Re: Speedup with bitboards on 64-bit CPUs

Posted: Fri Apr 27, 2007 1:18 pm
by Pradu
Tord Romstad wrote:
hgm wrote:I would not expect any speedup from bitboards compaired to mailbox, even in 64-bit mode, if you jsut use them to replace the move generator. For bulk move generation bitboards cannot beat mailbox. They are very much faster than mailbox for generating moves selectively (e.g. only captures, only checks), though. But if your program should be doing that a lot in order to see any benefits.
I do generate moves incrementally with bitboards, and have separate move generation functions for captures, checks, non-captures and check evasions. But move generation doesn't consume a significant fraction of the CPU time in my program in any case, neither with bitboards nor with mailbox. The places where bitboards seem to be significantly slower are king safety evaluation, scanning for attacks in a single direction, and making and unmaking moves.

Tord
Making and unmaking moves is slow for bitboard regardless. But perhaps you can optimize your kingsafety code with either flood-filling or specialized magic routines and have it be significantly faster than mailbox for this. I haven't looked into Glaurung to see how you do kingsafety but I suppose it is the usual way of counting the number/type of attackers to squares around the king. It is quite strange scanning for attacks in a single direction is faster for you, do you have a SEE to bench for mailbox and bitboards?

Re: Speedup with bitboards on 64-bit CPUs

Posted: Fri Apr 27, 2007 3:45 pm
by CRoberson
Telepath (bitboard) is slower than NoonianChess in NPS by about 2x using a 32 bit complier (g++) for both on a Core2Duo and an AMD 4400+.
Both machines using a 32 bit version of windows.

When I went to the newer version of MSVC, Telepath gained a 33% speedup and it still was a 32 bit compile running on a 32 bit OS.

When I recompiled Telepath with g++ (64 bit version) and ran on the AMD with a 64 bit version of Linux, Telepath was 20% faster than NoonianChess was.

Telepath is bitboard (nonrotated) and NoonianChess uses a 64 element array and two piecelists.

Re: Speedup with bitboards on 64-bit CPUs

Posted: Fri Apr 27, 2007 8:25 pm
by jdart
Arasan uses bitboards extensively (including rotated). The 64-bit version is faster but not by much (10-25%). I am not sure why.

--Jon

Re: Speedup with bitboards on 64-bit CPUs

Posted: Sat Apr 28, 2007 1:32 am
by Michael Sherwin
jdart wrote:Arasan uses bitboards extensively (including rotated). The 64-bit version is faster but not by much (10-25%). I am not sure why.

--Jon
Rotated bitboards use lots and lots of multidimentional look-ups which is great for 32 bit processors, because it keeps 64 bit access to a minimum. However, when compiled for 64 bits all the same array indexing must be done and 64 bit access is still minimized. There are other bitboard methods that minimize look-ups and maximize 64 operations that run much faster on 64 bit processors when compiled to 64 bit code.