Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Question for Gerd: reduce rbb lookup tables

Author: Gerd Isenberg

Date: 12:51:13 07/15/03

Go up one level in this thread


On July 15, 2003 at 14:44:16, Robert Hyatt wrote:

>On July 14, 2003 at 19:38:40, Sune Fischer wrote:
>
>>On July 14, 2003 at 18:59:16, Gerd Isenberg wrote:
>>>
>>>Read again, the ShiftL45[s] lookup is not necessary.
>>>
>>>__forceinline
>>>BitBoard A1H8Attacks(unsigned int sq) const
>>>{
>>>  return sA1H8Atta[sq]
>>>   [(*(((BYTE*)&(m_OccuBBA1H8))+((sq-Rank(sq))&7))&0x7e)>>1];
>>>   // diaindex = (file-rank) & 7
>>>}
>>>
>>>Gerd
>>>
>>
>>Thanks Gerd, I'll think it over.
>>
>>My transformation is a little different I think, though you also have one shift
>>and one AND, you've just replaced the table with some "magic", could be faster I
>>guess.
>>
>>I once heard that working with byte size variables is slower than native
>>integers (32 bit) sizes, so I'm not fully convinced 8 bit casting it that much
>>faster(?).
>>
>>-S.
>
>The point of 8 bit stuff is that while it might execute a cycle slower, it is
>much more cache-friendly.  That pays off big overall.  IE 64 chars vs 64 ints
>is a 75% cache footprint reduction.
>
>I do a lot of that in Crafty, and trust me, I benchmarked both ways before
>leaving the char stuff in.  :)

Yes, for small but often used arrays with 32-256 elements i prefere int arrays.
And i tend to pack bytes in structures, if i need several byte-values of one
index in one context, without changing index between these lookups, eg. some
[from][to] arrays.

But the point here was to fiddle one byte for one ray out of a rotated occupied
bitboard. Interpreting the bitboard as an eight BYTE array and index via file,
rank or packed diagonal index, or fetching the whole 64bit and shifting and
masking 64bit wise, where number of shifts is computed from file, rank or
diagonal index.

I prefere the 8-BYTE array - at least with x86-32. But with x86-64 things may
change. But movzx is still a fast 1 cycle one with Opteron:

MOVZX reg16/32/64, mreg8 0Fh B6h 11-xxx-xxx DirectPath 1

Gerd



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.