Author: Robert Hyatt
Date: 09:12:05 06/24/04
Go up one level in this thread
On June 24, 2004 at 04:56:02, Dann Corbit wrote: >On June 24, 2004 at 03:38:35, José Carlos wrote: >[snip] >> A possibly better way to do this is to have a struct with all related data, >>for example struct GameData which includes nodes, ply, hply, etc. Then declare a >>global variable of that type and use it everywhere. You keep exacly the same >>easyness as today, you also add variables easily (inside the struct), and if you >>decide to go multithreaded tomorrow, you need only to declare new instances of >>one variable. Additionally, you avoid the problem Dann mentioned. >> >> José C. > >I second this notion. Collection into structs in C (and classes in C++) has >many benefits. Orgainization into logical collections is one of them. There are others. 1. Arrange the data so that items that are used close together in time are close in the struct, to take advantage of a cache-line-miss fetching "all" the data that is close to the value being accessed. 2. Makes multi-threading easier. This was the first step I took, collecting everything that is modified within the search into a TREE struct, then referencing it through a pointer. For multiple threads, the pointer points to different struct instances for each different thread. 3. Makes the code easier to read since these "global" values are really accessed through a local pointer, making it easier to see what is being modified and by whom... Updating _real_ global values is a pain as you have to search through every line of code to see what it might modify and what might need a "lock" to protect it.
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.