Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: questions about using popcount function to count bitboard

Author: Robert Hyatt

Date: 14:17:49 01/10/03

Go up one level in this thread


On January 10, 2003 at 15:30:20, Bruce Moreland wrote:

>On January 10, 2003 at 15:16:52, Uri Blass wrote:
>
>>1)How do I use assembler code under C to count the number of 1's in a bitboard?
>>I do not know how to copy assembler code from crafty.
>>
>>I understood from previous post that the relevant code is in crafty but I do not
>>know how to copy it correctly with all the #defines in crafty.
>>
>>I understood that there are some relevant codes(x86.s, vcline.h that I could not
>>find and boolean.h
>>
>>2)I tried a code of dieter and got warning from the compiler(see the bottom of
>>this post for that code)
>>
>>warning C4244: '=' : conversion from 'unsigned __int64 ' to 'unsigned long ',
>>possible loss of data
>>
>>Note that I changed
>>int PopCount(unsigned long long a)
>>to
>>int PopCount(BitBoard a)
>>
>>I also have in my code
>>typedef unsigned __int64 BitBoard;
>>
>>I also never use the word long in my program except the code that I copied from
>>Dieter and I use int for 32 bit numbers.
>>
>>The warning was about w=
>>
>>int PopCount(BitBoard a)
>>{
>>  unsigned long w;
>>  int n = 0;
>>  w = a&0xffffffffUL;
>>  if (w)
>>    do
>>    {
>>      n++;
>>    }
>>    while ((w &= w-1) != 0);
>>  w = (a>>32)&0xffffffffUL;
>>  if (w)
>>    do
>>    {
>>      n++;
>>    }
>>    while ((w &= w-1) != 0);
>>  return n;
>>}
>>
>>Uri
>
>What percentage of its time does Crafty spend in the popcount() function if the
>C version is used?
>
>bruce


I haven't tested in a while.  Last time I did it was something like a couple of
percent...

Not very significant, overall...

However I did some optimizations that eliminate some of the PopCnt usage by pre-
computing popcounts for the mobility stuff, for example...




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.