Author: Robert Hyatt
Date: 20:36:39 07/11/01
Go up one level in this thread
On July 11, 2001 at 22:56:44, Artem Pyatakov wrote: >I was checking out the way crafty does hashing today. (yes, I've probably looked >at the way every single open-source engine does hashing today :-) ) > >I noticed that each of it's HASH_ENTRY structures information is just two 64-bit >numbers. Then in extracts this info using statements like these: > >val=(word1r & 0377777)-65536; > >I know C allows for bitfields (fields that just take up a couple of bits), but >does anyone know how fast these are? > >In other words, is it better to extract info from bits MYSELF (like Crafty does >it) or let C bitfields handle this for me? > >Thanks. > >Artem Pyatakov Bit fields have two problems... 1. they are slower in every implementation I tried. One reason is that the compiler doesn't know which bits are guaranteed to be zero and don't need to be "scrubbed off". There are others as well, such as defaulting to signed on some architectures, which requires sign extension which slows them further. 2. The ANSI standards committee did the same stupid thing with bit fields that they did with other key issues, "this is left to the vendor's discretion..." Ie is a char signed or unsigned by default? Depends on the compiler. In the case of bit fields, do the fields start at the MSB or LSB? Again, depends on the compiler. Since they are slower, and also not-so-portable if you want to transport 64 bit values across machines, I chose to "roll my own" and use and/or bitwise operators to put things where I want them. IE if I want to look at a compressed move and ask "is this a promotion or a capture" I can AND everything away but the captured piece and promotion piece fields and if the result is non-zero, I answer "yes". If I don't know which end the fields start on, I can't do it the same way nor as efficiently... They are a good idea, but with the absence of a real specification for them in the standard, they are less useful than they might have been with more precise definititions.
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.