Author: Dieter Buerssner
Date: 13:18:29 12/05/03
Go up one level in this thread
On December 05, 2003 at 15:53:19, Russell Reagan wrote:
>Also, using a function pointer also adds some extra overhead (I think as much as
>a mispredicted branch, or maybe a little more).
Hmmm, I cannot understand this. Why should it take so much time? Are you
thinking perhaps of arrays of function pointers (where the array index is more
or less random). Note, that the rate, at which the function pointer changes is
extremely low (say once in a few seconds at most in a typical scenario).
What you are saying almost implies, that
extern int use_low_material_incheck; /* perhaps static, accessed often,
probably allways in cache */
[...]
inc = use_low_material_incheck ? Incheck_low(side) : Incheck_high(side);
is faster than the alternative. Note, that there is even no mispredicted branch
here.
Alternative
extern int (*Incheck)(int);
/* somewhere close to the root of the search, executed very rarely */
Incheck = use_low_material_incheck Incheck_low ? Incheck_low : Incheck_high;
/* and inside search */
inc = Incheck(side);
Perhaps I will check it (could be done by a macro), if this can really be
slower.
Regards,
Dieter
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.