Author: martin fierz
Date: 07:13:54 06/06/01
Go up one level in this thread
On June 06, 2001 at 09:38:47, Vincent Diepeveen wrote: >On June 06, 2001 at 09:33:00, martin fierz wrote: > >>On June 06, 2001 at 09:31:32, martin fierz wrote: >> >>>[snip] >>>> >>>>In this piece of crap code i see everywhere: >>>> >>>> if (side == WHITE) >>>> tsq = B->WhiteKnights; >>>> else >>>> tsq = B->BlackKnights; >>>> >>>>Note you can eliminate these branches, which speeds code up bigtime. >>>[snip] >>> >>>so, who can enlighten a dummy like me? how exactly can i eliminate >>>branches like this? i admit that my checkers program has some of these >>>too... although i mostly do it like this >>> >>>if(color==WHITE) >>argh... i hit tab return instead of return, ok, again: > >The logical thing to do which saves a dead slow branch is: > > tsq = globaltable[side]; > >Basically you can get rid of any easy branch you want to >even without using Pentiumpro instructions. > >Just create some tables. so how slow is the branch in fact? i once tried using the visual C profiler to find out how much time i was spending in various places of my code. it told me that 40% were in my makemovelist. now if i turned off move ordering, that went down to 1%. if i used only static move ordering with things like if(square_to & CENTER) eval[i]+=CENTERVAL and other statements like this, it still said 1%. when i turned on the history table eval[i]+=history[from][to] i suddenly used 20% again - only for this single statement! now i am sure that this profiler is not really useful, because it takes up space in the cache and distorts things. but this single table lookup might take much more time than all these if-clauses - i have about 10 of them. also, when i turn off the profiler and look at my nodes/sec, i see that the history table costs me more than the static eval. are you quite sure that table lookups are much better? a miss in the L2 cache would cost 20-40 cycles, isnt a branch faster? on another note, i tried some char[] and short[] arrays to test bobs statement that these are faster - on the P3 they were faster, on the P4 they were slower. i know, i know, i shouldnt have bought a P4 :-) cheers martin
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.