Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: advantages to board pointers

Author: Robert Hyatt

Date: 14:35:54 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?

You are correct.  And the main thing is that you have to have a different
"board" for each processor or a parallel search can't work.  I use threads,
which I consider to be the best way to write parallel code for a SMP box, and
there the pointer is the most direct way to do things.  You can set up an array
of board structures, and let each thread (processor) use its internal thread id
as an index to get to the right one, and avoid the pointer.  But I believe the
pointer makes the code much easier to read and has no significant performance
cost.

>
>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.

The "hit" is about 3%.  If you use one processor, you can avoid it by just
making the board global.  But then you will never use more than one processor
without a re-design.

>
>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.



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.