Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: eliminating function calls from static evaluation

Author: Dezhi Zhao

Date: 08:40:27 02/09/99

Go up one level in this thread


On February 08, 1999 at 14:46:31, Stuart Cracraft wrote:

>
>Hi,
>
>I'm thinking of eliminating the majority of function calls
>from the GNU 5.0 static evaluator.
>
>For example, right now, about 12 function calls are used per
>static evaluation of one position.
>
>These function calls are to the individual piece evaluators
>(pawn, knight, etc.) for white and black.
>
>Since this would potentially eliminate an order of 10^3 .. 10^4
>or more function calls per search, before I do the work, I
>want to know what other people's experiences have been.
>
>For example, Crafty has a giant Evaluate () routine wherein
>it looks like individual piece evaluations for each side
>(duplicate code) are enclosed in that giant routine.
>
>--Stuart


While starting to optimize the code, one often begins with eliminating
function calls. However, excessive inlining often overloads cache and
hurts performence. Here is what I do.
1. Only inline very short and time-critical functions. I think this is what
inlining is intended for.
2. If a function of some length is called in more than 1 place, I will keep it a
function. This will reduce code size and save room for new code.
3. In some case, it's better to seperate some less-often-exacuted lengthy
statements out into  a function, even though it will be called in only one
place. This will help to reduce cache misses.

int caller_func()
{
    do
    {
      a = b;
      c = d;
      .....
      if (less_likely_cond)
          a_good_func();       // the net effect is that u get a smaller loop
      .....
    }
    while(loop_cond)
}


Dezhi Zhao



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.