Computer Chess Club Archives


Search

Terms

Messages

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

Author: Alex Boby

Date: 16:30:20 04/23/01



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.






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.