Author: Matthew White
Date: 17:17:26 09/05/03
Go up one level in this thread
On September 05, 2003 at 16:39:17, Dezhi Zhao wrote: >On September 05, 2003 at 16:17:48, Uri Blass wrote: > >>I want to have some rule when it is a good idea to use local varaibles. >> >>I believe that it is clear that when instead of changing the hash key zob[hply] >>many times in my makemove it is better to start using local varaible and start >>my makemove with >> __int64 zob=zobkey[hply]; >>and finish it with when hply was already increased by 1 with >>zobkey[hply]=zob; >> >>My question is how many times using the same expression zobkey[hply] >>justify using local varaible >> >> >>I am not sure what is the correct decision for the function >>probehash,recordhash,donullmove. >> >>In these functions the zobrist key is not changed a lot of time >>and I am not sure if it is better to use a local varaible or to use the global >>array. >> >>Uri > >You can do it either way. It makes no difference for a decent compiler. An excerpt from the common misconceptions section of Paul Hsieh's optimization page (http://www.azillionmonkeys.com/qed/optimize.html which, coincidentally, I was reading yesterday for unrelated reasons): Globals are faster than locals Most modern C compilers will alias local variables to your CPUs register's or SRAM. Furthermore, if all variables in a given scope are local, then an optimizing compiler, can forgo maintaining the variable outside the scope, and therefore has more simplification optimization opportunities than with globals. So, in fact, you should find the opposite tends to be true more of the time.
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.