Author: Robert Hyatt
Date: 07:13:25 12/04/03
Go up one level in this thread
On December 04, 2003 at 02:49:27, Tony Werten wrote: >On December 03, 2003 at 11:14:24, Robert Hyatt wrote: > >>On December 03, 2003 at 03:05:03, Tony Werten wrote: >> >>>On December 02, 2003 at 04:19:24, Gian-Carlo Pascutto wrote: >>> >>>>On December 01, 2003 at 02:41:28, Tony Werten wrote: >>>> >>>>>When my masterthread is spinning, waiting for results from it's workers >threads, how do I keep it from burning CPU time ? >>>> >>>>Turn it into a worker thread. >>> >>>Brilliant ! >>> >>>And then not having a masterthread hand out moves, but have the worker threads >>>pick moves themselves from "some global structure" ? >> >>:) >> >>That is why Crafty always starts exactly N-1 threads on an N processor box. >>The original thread plus the new N-1 are just enough to keep all 4 >>processors busy. The data structures are a bit messy, because you reach >>a point where there are no more moves at some point, and processors have >>to go to work somewhere else as they finish. And the _original_ process >>has to be the one to "return" if you are using are using a recursive search, >>of course. >> >>But I do that and it has worked just fine for years. > >So I do want to do it the CRafty way :) > >> >>> >>>And then have only the "master thread" return a score in the search (upwards >>>that is) and have the worker just "disconnect" and reconnect at another movelist >>>in the global structure ? >> >>Yes... >>I call those "reconnects" "split points". >> >>> >>>I think I'm starting to see the picture now. >>> >>>A "master" thread filling an array index by depth wich contains all the moves >>>from that depth and a flag SHAREABLE (or not). Then the workers pick moves ( >>>preferably as high as possible) and post result ( if important) >> >>I would not go with the global stuff. You have to stop and think why. IE >>at ply=5, two processors split. No problem. But now processor 1 wants >>to split at ply=7 with processor 3, while processor 2 wants to split at >>ply=7 with processor 4. note that 1 and 2 are the ones splitting at ply=5. > >I almost had it. Shouldn't I prefer to let 3 and 4 join the splitting at depth 5 >? What if you are out of moves there? Where do they go now? When you split, you now have two separate sub-trees to deal with. I don't see any way to make a single global structure to deal with that since each "fork" of the tree must be kept separate. And later you might want to further split one fork as another processor becomes idle/available. You might look at thread.c in Crafty for an initial approach. I'd be happy to explain the data structure, but you had better like bi-directional linked lists and the like as the tree gets very complicated when you choose to let things be split at any point... recursively... > >> >>A global structure will not allow that. > >Yes, I see that. When processor 1 and 2 have just picked the last 2 moves, 3 and >4 will have to split somewhere else. Yes... > >OTOH Maybe I should get it to work at a dual first ( wich would allow me to use >a global struct ) and use to knowledge I get from that to later make a N >processor version. > >BTW what do you do when the master can't find a move in the list anymore, >because the workers are searching the last moves ? I was thinking about keeping >it simple, kicking one of the workers off a move and hoping the hashtable will >keep me from wasting too much nodes in the "research". The master then simply calls a function ThreadWait() which puts him into a "busy - I want to help somebody" state. One of the still busy threads will say "join right here and search this stuff."
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.