Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Tables or Calculation

Author: Russell Reagan

Date: 19:00:16 01/17/03

Go up one level in this thread


On January 17, 2003 at 20:28:03, David Rasmussen wrote:

>I profiled my code and found (not very surprisingly) that
>
>INLINE BitBoard Mask(Square square) { return mask[square]; }
>
>was a hotspot.
>
>I tried to change it to
>
>INLINE BitBoard Mask(Square square) { return BitBoard(1) << square; }
>
>I've tried that many times before, and this time too, the latter was slower. But
>why? I mean, the latter is one instruction on x86 or something like that, and
>square is probably in a register anyway. I would think that it would be faster
>than a table lookup which accesses slow memory.
>
>How come?

Well, neither of those are one instruction unless you are using 32-bit
bitboards, or you are writing a checkers program, or you have a 64-bit computer.
The table lookup shouldn't have any "slow memory accesses", but rather in the
cache. I would think that the table lookup in the cache would be faster than a
64-bit shift.



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.