From 56e09b4cc82c1cda42815482967670499fc64b61 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Mon, 25 Jan 2010 11:07:30 +0100 Subject: [PATCH] Copy only the search stack tail in split() 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 --- src/search.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index df74d580..f2057741 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -2986,15 +2986,15 @@ namespace { 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)) { - 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++; -- 2.39.2