Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Population of disjoint Attacksets

Author: Gerd Isenberg

Date: 08:43:31 05/28/04

Go up one level in this thread


On May 28, 2004 at 11:13:09, Dieter Buerssner wrote:

>On May 28, 2004 at 10:56:59, Gerd Isenberg wrote:
>
>>int popCount(BitBoard bb)
>>{
>>   unsigned int l = low(bb);
>>   unsigned int h = high(bb);
>>   l -= (l >> 1) & 0x55555555;	// count 2-bit groups
>>   h -= (h >> 1) & 0x55555555;	// count 2-bit groups
>>   l  = (l & 0x33333333) + ((l >> 2) & 0x33333333); // count 4-bit groups
>>   h  = (h & 0x33333333) + ((h >> 2) & 0x33333333); // count 4-bit groups
>
>l += h; // and do the next stage on l only
>
>>   l  = (l + (l >> 4)) & 0x0f0f0f0f;	 // count 8-bits groups
>>   h  = (h + (h >> 4)) & 0x0f0f0f0f;	 // count 8-bits groups
>>   return ((h+l) * 0x01010101) >> 24;	 // sum 8-bit results
>>}
>
>Gerd, I think, you can combine the 2 halves already one stage earlier. Or did I
>miscaclulate this? I thought, the individual counters cannot overflow at that
>stage already. See also my post
>http://chessprogramming.org/cccsearch/ccc.php?art_id=349781
>
>For me, adding two counter combining stages was faster, than the multiplication.
>
>Regards,
>Dieter

I wrote it from scratch to verify the "packing" trick.
But it seems your add is a bit too early, since 8+8 may overflow to 0x10.

Cheers,
Gerd






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.