Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: advantages to board pointers

Author: Russell Reagan

Date: 15:59:49 06/10/04

Go up one level in this thread


On June 10, 2004 at 16:26:01, Eric Oldre wrote:

>I've decided to stop development on the vb.net version of my engine (Murderhole)
>in order to focus on a new version written in C that has a chance to be
>competitive eventually. (eventually=hopefully in my lifetime)
>
>Considering that a large chuck of the code I’ve ever written in C has had the
>words "Hello" and "World" in it, this could end up being quite a process for me.
>However I feel pretty good since after a few nights I now have methods for
>fenset, fenget, move_make, reset_board, as well as functions to get ranks from
>positions etc.
>
>In the VB.net version of my engine I ended up having 1 global board, And I’ve
>began to program my new engine the same way.
>
>Reading the Crafty source, I see that Mr. Hyatt is passing around pointers to
>some object that (among other things) has a board position type struct. (I’m not
>sure of the details, don't have the source in front of me).
>
>I'm guessing that he needs to pass this tree around to so that crafty can take
>advantage of multiple processors. I.e., each thread is going to need its own
>version of the board to pass around.
>
>My questions are:
>1) Am I right that the pointers to the board are used so that crafty can use
>multiple processors? Would there be a way to use multiple processors without
>this technique or something similar?
>
>2) What other advantages would there be to passing the pointers to the tree? (if
>any). It would seem to me to cause some performance hit on single processors.
>
>3) What other advice or experience would other authors like to give me
>concerning this architecture decision?
>
>4) So far I've been studying the source to crafty, tscp, and gerbil. Anyone have
>examples of other engines that I could study to get a handle on some of the
>different techniques used?
>
>Thanks,
>Eric Oldre
>
>http://www.oldre.com/Murderhole
>
>PS... I'm not going to be at home tonight, so i may not be able to respond to
>any answers right away.

In general, it is a good idea to use the approach of passing around a pointer to
a board because it gives you more flexibility. Other people have given you
examples where it would make it much easier on you if you could make a copy of
the board and work on the copy, then throw the copy away without ever having to
make changes to the main board. Making your program support multiple processors
is just another example of the added flexibility that it gives you.

Another advantage that using a pointer to a struct is that you know that all of
the data in the struct will be in contiguous memory, which is better for the
cache. So it may end up making your program run _faster_, not slower.

With modern computers, micro-optimization can be tricky. Sometimes what you
think will make your program go faster actually makes it go slower, and vice
versa.



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.