Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: BSF/R not working well for me...

Author: Bas Hamstra

Date: 12:33:39 04/24/01

Go up one level in this thread


On April 23, 2001 at 19:30:20, Alex Boby wrote:

>
>I used to have this:
>
>------------
>void parseBitboard (int from, struct MoveList *ml, bitboard attack)
>  {
>  int i;
>
>  for (i=0; i<64; i++)
>    {
>    if (attack&mask[i])
>      [add move to list]
>    }
>  }
>------------
>and got this in the profile:
>7301.351   3.9    37127.739  19.6   538488 _parseBitboard (pierre.obj)
>
>and then, figuring I would get a significant speed increase, I switched to this:
>
>-----------------
>int findBitIndex(bitboard data)
>  {
>  int index;
>
>  __asm
>    {
>        bsr edx, dword ptr data+4
>        mov eax, 32
>        jnz s1
>        bsr edx, dword ptr data
>        mov eax, 0
>        jnz s1
>        mov edx, -1
>    s1:	add edx, eax
>        mov index, edx
>    }
>
>  return index;
>  }
>
>void parseBitboard (int from, struct MoveList *ml, bitboard attack)
>  {
>  int index;
>
>  while ((index = findBitIndex(attack))!=-1)
>    {
>      [add move to list]
>      attack -= mask[index];
>    }
>  }
>-------------
>and then got this in the profile:
>    6763.331   4.4    32424.707  21.1   530420 _parseBitboard (pierre.obj)
>    1313.554   0.9     1313.554   0.9  3523746 _findBitIndex (pierre.obj)
>
>with about a 10% drop in nodes/sec.
>
>I thought that BSF & BSR were supposed to be fast! What am I doing wrong?
>This is on an Intel P3/500 w/ win2k.

I use:

int LastOne(BB M)
{   __asm
    {   mov EAX, dword ptr [M]
        bsf EAX, EAX
        jnz Done
	mov EAX, dword ptr [M+4]
        bsf EAX, EAX
        add EAX, 32
        Done:
    }
}

That saves one jump. Also, VC inlines the assembly flawlessly, while Borland
does NOT inline asm. IE in Borland when you use "inline LastOne()" it ignores
it. I am curious if the other routines posted are faster.

Best regards,
Bas.














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.