Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: For compiler gurus about Bit fields

Author: Peter Fendrich

Date: 09:30:04 11/13/04

Go up one level in this thread


On November 13, 2004 at 11:13:17, Robert Hyatt wrote:

>On November 12, 2004 at 09:18:09, Peter Fendrich wrote:
>
>>Will C++ compilers (especially .NET) handle bit fields with decent performance?
>>It is very tempting to use them in hash tables for instance.
>>Something like this:
>>
>>struct Hash
>>{
>>   unsigned KeyPart    : 48;   // 32+16
>>   unsigned Eval       : 16;
>>   unsigned Flag       :  2;   // FH, FL, Inside
>>   unsigned FrPiece    :  4;   // Move
>>   unsigned Fr         :  6;   // Move
>>   unsigned To         :  6;   // Move
>>   unsigned Threat     :  1;
>>   unsigned Depth      : 10;
>>   unsigned Generation :  3;
>>} hash;
>>
>>hash.KeyPart = HashKey;
>>etc...
>>
>>/Peter
>
>Forget it.  You notice I don't use 'em in Crafty?  I did early on.  I think
>comments in main.c explain why.
>
>I don't know why compilers were so bad doing this when I tried it, but they
>really were bad.  And I'm not talking just about gcc.


Maybe they are better now, I will try and report. Don't you think it matters
the way the fields are stuffed? Alignment of course but also in what order they
are placed ans accessed.
Another thing I'm probably no master myself with ANDing and SHIFTing which is
the way I use right now so the compiler might as well keep up!
/Peter






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.