Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Tables or Calculation

Author: Matt Taylor

Date: 02:00:16 01/18/03

Go up one level in this thread


On January 17, 2003 at 22:00:16, Russell Reagan wrote:

>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.

64-bit shift in something like 3 cycles when count is < 32. Pentium 4 L1 cache
latency -- 2 clocks. Athlon L1 cache latency -- 3 clocks.

Bad performance of former indicitive of poor optimization.

-Matt



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.