Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: a question about speed difference that I do not understand

Author: Uri Blass

Date: 04:24:26 12/05/01

Go up one level in this thread


On December 05, 2001 at 06:46:07, Severi Salminen wrote:

>>>#define color(target) (((info[target])>>3)&3)
>>>
>>>
>>>my data.c file includes
>>>
>>>int info[64];
>>>int side;
>>>int direction[64][64];
>>>int kingsquare[2];
>>>int pin[64];
>>>
>>
>>Perhaps the data types could be a reason for some microscopic effects. If the
>>variable "side" is for instance of type "short", the compiler has to zero-extend
>>the variable to word-size before indexing (because of the array access).
>
>But as you can see the variables are all ints. So no type conversions needed. I
>believe there is just some stupid alignment thing happening or something and
>that's why the program slows down a bit. I'd use side instead of color(sq) and
>hopefully the speedup will show up later.
>
>Severi

Fortunately I believe that I have other ideas to save speed when I do not need
to use the variable side or the expression color(square) after the condition.

I now check every square in the board in order to update the pin array for it
(-1 when there is no piece of the side to move or when the piece of the side to
move is not pinned and another number in other cases).

I think to check only squares that are in queen direction with the king of the
side to move
(I can save time for example by the fact that I do not need to check if there is
something between the king and the piece that is a candidate to be pinned).

It may be not the optimal way to update my pin array and the best way should use
the move in order to detect relevant squares but this way is needed when the
king moves and it is not so simple to detect relevant squares to change  based
on the move when the move can be a capture.

I guess that the way that I plan is going to help me to improve the time of
perft 6 in the initial position from 25 seconds on p800 to less than 20 seconds

Uri



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.