I am trying to add the YBWC in my engine, and I have a problem with data structures.
I have a global lockless hash table, killers, history and pawn hash table will be declared for each threads, but I don't understand how many elements I need to allocate for board positions, moves lists, pv, and repetitions.
Looking at Viper source code, I see that each thread have an array with a maximum number of split points, but I am not sure to understand why in the split_point_t structure, position_t, search_stack_t, move_stack_t are declared for each threads ?
Is it possible to allocate less elements ?
YBWC implementation questions
Moderator: Ras
-
- Posts: 194
- Joined: Sat May 25, 2013 11:17 am
- Location: France
- Full name: Patrice Duhamel
-
- Posts: 4396
- Joined: Fri Mar 10, 2006 5:23 am
- Location: http://www.arasanchess.org
Re: YBWC implementation questions
You are going to need a fair number of data structures.
Each searching thread has its own stack that maintains move history.
Each searching thread also has a split point stack. This is used to keep track of the places within that thread's execution where a split has occurred. One reason you need this is the rule that a thread that has spawned child threads but is now idle, because its own work has completed, can only be allocated again to help complete work that its own child threads have started.
I have implemented this but I am not sure my code is a model of clarity. It has some comments that might be helpful though:
https://github.com/jdart1/arasan-chess.
--Jon
Each searching thread has its own stack that maintains move history.
Each searching thread also has a split point stack. This is used to keep track of the places within that thread's execution where a split has occurred. One reason you need this is the rule that a thread that has spawned child threads but is now idle, because its own work has completed, can only be allocated again to help complete work that its own child threads have started.
I have implemented this but I am not sure my code is a model of clarity. It has some comments that might be helpful though:
https://github.com/jdart1/arasan-chess.
--Jon
-
- Posts: 194
- Joined: Sat May 25, 2013 11:17 am
- Location: France
- Full name: Patrice Duhamel
Re: YBWC implementation questions
I need only one stack for move history by thread, or one stack for move history at each new thread assigned to a split point ?jdart wrote: Each searching thread has its own stack that maintains move history.
Thanks, I will try to look at Arasan source code.jdart wrote: I have implemented this but I am not sure my code is a model of clarity. It has some comments that might be helpful though:
https://github.com/jdart1/arasan-chess.
-
- Posts: 4396
- Joined: Fri Mar 10, 2006 5:23 am
- Location: http://www.arasanchess.org
Re: YBWC implementation questions
I have a Search class, one per thread. That contains the stack.I need only one stack for move history by thread, or one stack for move history at each new thread assigned to a split point ?
--Jon
-
- Posts: 194
- Joined: Sat May 25, 2013 11:17 am
- Location: France
- Full name: Patrice Duhamel
Re: YBWC implementation questions
Sorry I didn't explain my problem very well.jdart wrote: I have a Search class, one per thread. That contains the stack.
In Arasan, before calling your searchSMP() function, you allocate a NodeInfo array (in the thread stack memory).
If I want to allocate all data for the NodeInfo arrays outside of the thread idle loop, at the start of the program (in the heap),
how many elements I will need ?
Is it possible in a search that all threads are working and have all created their maximum number of split points ?
-
- Posts: 4396
- Joined: Fri Mar 10, 2006 5:23 am
- Location: http://www.arasanchess.org
Re: YBWC implementation questions
You want it in the thread stack memory, because of the "first touch" rule (the first access to the memory causes the page to be allocated in the memory local to the thread that is accessing it). In a NUMA system locality is important.you allocate a NodeInfo array (in the thread stack memory)
Re your other question: I think it is rare that the split stack is full. But if this worries you can always increase the size.
--Jon
-
- Posts: 194
- Joined: Sat May 25, 2013 11:17 am
- Location: France
- Full name: Patrice Duhamel
Re: YBWC implementation questions
Thanks for your help.jdart wrote: You want it in the thread stack memory, because of the "first touch" rule (the first access to the memory causes the page to be allocated in the memory local to the thread that is accessing it). In a NUMA system locality is important.
I will use the thread stack memory.