Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: about SEE of Crafty

Author: Robert Hyatt

Date: 11:09:05 01/06/04

Go up one level in this thread


On January 06, 2004 at 12:44:07, Uri Blass wrote:

>On January 06, 2004 at 10:56:00, martin fierz wrote:
>
>>On January 06, 2004 at 09:40:33, Robert Hyatt wrote:
>>
>>>Maybe there is some confusion here.  There is _no_ cost for "allocating"
>>>local variables in a function.  And I _do_ mean _NO_.  These values are
>>>simply "on the stack" and when the function is entered, the stack pointer has
>>>some constant subtracted from it to leave a "hole" that is used to hold local
>>>function variables.  no malloc() or anything like that is done by modern
>>>compilers, hence zero cost.
>>
>>hi bob,
>>
>>is this really true? i used to have a HUGE structure describing a move in the
>>first version of my chess program (don't ask, please...). in my negamax function
>>i had this
>>
>>int negamax(int alpha, int beta, int depth)
>>   {
>>   MOVE movelist[MAXMOVES];
>>   ...other variables...
>>
>>   ...typical negamax code...
>>
>>   }
>>
>>i saw clear speed differences depending on the value i used for MAXMOVES - and
>>in my tests, i made sure that using 100 would never overflow in the positions i
>>was searching, then i set it to e.g. 200 and the program would get a few %
>>slower, although these additional 100 array elements were never used.
>>
>>how can this be explained? i'm not memsetting the array to 0 or anything.
>>
>>like uri, i thought the program was allocating memory every time it entered the
>>function, and that that was taking time. i ended up making my MOVE variable much
>>smaller - although it's still much larger than crafty's :-)
>>
>>i thought perhaps i should allocate the movelist beforehand as a global, like
>>this:
>>
>>MOVE *movelist[MAX_SEARCH_DEPTH]
>>for(i=0;i<MAX_SEARCH_DEPTH;i++)
>>   movelist[i] = malloc(sizeof(MOVE)*MAXMOVES)
>
>My move list is in a global varaible like tscp
>
>gen_t gen_dat[GEN_STACK];
>
>The list include legal moves of all plies.
>
>For example if I search the line 1.e4 e5  the list includes legal move of white
>in the initial position,legal moves of black after 1.e4 and legal moves of white
>after 1.e4 e5
>
>GEN_STACK is 30,000 that is clearly more than enough but I remember from
>exeperience that changing the size of the global array did not make big
>difference.
>
>I do not use pointers when I do not need them and I see no reason to use malloc
>for the move list.
>
>Uri


No, but if you _ever_ do a parallel search, you will quickly see a reason to
not use a global move list.  :)



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.