Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Multithreading and how to use it

Author: Bruce Moreland

Date: 09:21:47 08/12/01

Go up one level in this thread


On August 12, 2001 at 09:06:02, Kim Roper Jensen wrote:

>I have made a little chess program with some very ordinary stuff, and would like
>to implement multiprocessing( i just recently bought a dual 1GHz with 2Gb of
>memory, its real cheap here in denmark it only costed approx $1000)
>
>But i wondered how do you guys implement it, i was thinking about having a pool
>of threads that the search could grab if there is some available, then it would
>be easy to test to see which amount of threads would be the most efficient and
>it could be adjusted easily.
>
>Or do you just have a finite amount of threads that you start at once ????

I allocate a bunch of threads. The main search starts, and when it gets to a
split point it asks to see if there are any processors available.  If so, one of
these threads gets grabbed, and off we go.

The reason I have more threads than processors is that perhaps at one point a
thread realizes that it's done, but needs to wait for a child thread to finish.
At that point it blocks, which means that neither the thread nor the processor
are doing anything.

In order to avoid wasting the processor time, I increment the number of
procesors available.  The threads that are still running are free to split work
as of that point.

Due to race conditions I end up with more threads active and running than I have
processors sometimes, maybe 1% of the time.

bruce

>
>I just had some thoughts that maybe the amount of threads that would yield the
>best perfomance could change in the course of the game and it would be more
>efficient to adjust the poolsize of threads in the different stages of the game.
>
>and how about having each thread using its own hashtable ?? This maybe sound
>silly but the we shouldnt check all kinds of things( is there another thread
>locking the table at the location etc.) maybe the there would be some small
>speed benefit( I mean, I read that implementing hashtables only gives approx. 70
>ratingpoints, so maybe it isnt so critical to use one big table)
>
>just some thoughts ............
>
>(if it sounds really crazy, then it must be because its late and im tired :) )



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.