Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: speed question

Author: Dezhi Zhao

Date: 06:41:35 02/19/03

Go up one level in this thread


On February 19, 2003 at 06:39:49, Uri Blass wrote:

>I try to do movei faster and there are things that are supposed to do it
>slightly faster but for some reasons do it slower so I deleted them(Maybe it is
>better if I ignore it because it is a compiler optimization noise but I do not
>like to see the program slower even if it is only 0.1% slower).
>
>Note that I do not use now compiler optimization except optimize for speed with
>visual C++6.
>
>
>Here is an example:
>My function of adding pawn moves to the stack of moves get 2 numbers(from,to).
>
>I found that special functions to generate white moves one square forward,white
>moves 2 pawns forward,black pawns one square forward,...helped me to do movei
>faster.
>
>Common sense say that now I do not need 2 numbers in my functions because
>I always have to=from-8 in
>
>Here is my function.
>to is always from-8 and the question is if I can take advantage of that fact.
>
>static void gen_quietblackslowpawns(int from,int to)
>{
>	gen_t *g;
>	if (to<=7)
>	{
>		gen_promote(from,to);
>		return;
>	}
>	g=&gen_dat[first_move[ply+1]++];
>	g->m.b.from=(char)from;
>	g->m.b.to=(char) to;
>	g->m.b.promote=0;
>	g->m.b.bits=16;
>	#if MODE!=MODE_PERFT
>	g->score = history[from][to];
>	g->index=-10000;
>    #endif
>}

I think you can get a little from that fact. It will save a few push and pop
operations.

By the way, if you really want to optimize this function, you should consider
re-designing the b structure so that the move can be saved in a single write
operation, instead of 4.  After this optimization, you may find out this
function is too small and fast to be a function entity, and get it inlined.



This page took 0.02 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.