Author: Dan Newman
Date: 02:15:15 06/16/01
Go up one level in this thread
On June 14, 2001 at 19:34:09, Dann Corbit wrote: >Using this "darn-fast" branchless first-bit location routine: >int FirstPiece(BITBOARD bits) >{ >// if (bits == 0) return -1; >__asm { >; 64-bit number to move into ECX:EBX, will never be zero! > mov ecx,dword ptr [bits+4] > mov ebx,dword ptr [bits] > bsf eax,ecx > add eax,32 > bsf eax,ebx > } >} > >I would think that iterating over the board would be just as fast (or possibly >faster) than using piece lists. > >I am curious if others who use bitboards find piece lists to be valuable. >I am somewhat surprised to see that FirstPiece() is consuming a lot of CPU. I tried the above trick to make Shrike's next_one() function branchless and got > 5% speedup :). Thanks, Dann! It's not every day I get that much... I found it a little bit faster to use the bitboard halves directly as bsf operands (maybe due to using fewer registers and fewer instructions): __asm { mov ebx, this bsf eax, [ebx].upper add eax, 32 bsf eax, [ebx].lower } The above is inside a member function of the bitboard class which is why I have the "mov ebx, this" line. As far as piece lists go, I was *very* happy to be able to get rid of them when I went over to bitboards. In fact I think of the bitboards as piece lists quite frequently. All that trouble keeping the piece lists up-to-date is removed which is perhaps the principal reason I like bitboards... If by iterating over the board you are refering to the array board of a non-bitboard program, that's actually quite a bit slower than using piece lists. (I've tried it.) But if you are refering to extracting piece coords from bitboards, I actually think that that can be as fast or faster, except in the endgame where short piece lists will tend to win. -Dan.
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.