Only the previous, the current and the next ply SearchStack
are copied.
This reduces split overhead especially at low depth (high ply)
and with many threads.
Possibly no functional change (it is not easy to prove in SMP)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
for (i = 0; i < ActiveThreads; i++)
splitPoint->slaves[i] = 0;
for (i = 0; i < ActiveThreads; i++)
splitPoint->slaves[i] = 0;
- // Copy the current search stack to the master thread
- memcpy(splitPoint->sstack[master], sstck, (ply+1) * sizeof(SearchStack));
+ // Copy the tail of current search stack to the master thread
+ memcpy(splitPoint->sstack[master] + ply - 1, sstck + ply - 1, 3 * sizeof(SearchStack));
Threads[master].splitPoint = splitPoint;
// Make copies of the current position and search stack for each thread
for (i = 0; i < ActiveThreads && splitPoint->cpus < MaxThreadsPerSplitPoint; i++)
if (thread_is_available(i, master))
{
Threads[master].splitPoint = splitPoint;
// Make copies of the current position and search stack for each thread
for (i = 0; i < ActiveThreads && splitPoint->cpus < MaxThreadsPerSplitPoint; i++)
if (thread_is_available(i, master))
{
- memcpy(splitPoint->sstack[i], sstck, (ply+1) * sizeof(SearchStack));
+ memcpy(splitPoint->sstack[i] + ply - 1, sstck + ply - 1, 3 * sizeof(SearchStack));
Threads[i].splitPoint = splitPoint;
splitPoint->slaves[i] = 1;
splitPoint->cpus++;
Threads[i].splitPoint = splitPoint;
splitPoint->slaves[i] = 1;
splitPoint->cpus++;