Author: Russell Reagan
Date: 13:35:26 12/05/03
Go up one level in this thread
On December 05, 2003 at 16:18:29, Dieter Buerssner wrote: >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 I think you are right. I was thinking of a situation like Ed Schröder describes on his webpage (http://members.home.nl/matador/chess840.htm#INTRO). Either Ed or Eugene Nalimov (I think) said that using function pointers in this way would be at least as slow as a mispredicted branch. Is it a different situation when you only have one function pointer instead of an array of them like Ed's page does?
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.