From 5b6e5d81cf31da65a1e406002dd8d459ac888fe3 Mon Sep 17 00:00:00 2001 From: Krasimir Topchiyski Date: Sun, 5 Feb 2023 14:21:31 +0200 Subject: [PATCH] Set CountTranspositionTables from 1 to sqrt(threads_count) + tune and print nextDepthThreshold --- .../cfg/base/RootSearchConfig_BaseImpl_SMP.java | 11 +++++++---- .../parallel/MTDParallelSearch_ThreadsImpl.java | 15 +++++++++++++-- .../impl/rootsearch/parallel/SearchersInfo.java | 2 ++ .../src/bagaturchess/uci/impl/StateManager.java | 2 +- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Sources/Engines/src/bagaturchess/engines/cfg/base/RootSearchConfig_BaseImpl_SMP.java b/Sources/Engines/src/bagaturchess/engines/cfg/base/RootSearchConfig_BaseImpl_SMP.java index bf758b14..c44d2c85 100644 --- a/Sources/Engines/src/bagaturchess/engines/cfg/base/RootSearchConfig_BaseImpl_SMP.java +++ b/Sources/Engines/src/bagaturchess/engines/cfg/base/RootSearchConfig_BaseImpl_SMP.java @@ -30,18 +30,21 @@ public abstract class RootSearchConfig_BaseImpl_SMP extends RootSearchConfig_BaseImpl implements IRootSearchConfig_SMP, IUCIOptionsProvider { - private static final int DEFAULT_SMP_Threads = getDefaultThreadsCount(); + private static final int DEFAULT_SMP_Threads = getDefaultThreadsCount(); - private static final int DEFAULT_CountTranspositionTables = 1; + private static final int DEFAULT_CountTranspositionTables = 1; + //private static final int MAX_CountTranspositionTables = DEFAULT_SMP_Threads; + private static final int MAX_CountTranspositionTables = (int) Math.sqrt(DEFAULT_SMP_Threads); - //setoption name UCIOptions.OPTION_NAME_SMP_Threads value 16 + + //setoption name CountTranspositionTables (UCIOptions.OPTION_NAME_CountTranspositionTables) value 8 private UCIOption[] options = new UCIOption[] { new UCIOptionSpin_Integer(UCIOptions.OPTION_NAME_CountTranspositionTables , DEFAULT_CountTranspositionTables, "type spin default " + DEFAULT_CountTranspositionTables + " min 1" - + " max " + Math.max(2, DEFAULT_SMP_Threads) + + " max " + MAX_CountTranspositionTables ), new UCIOptionSpin_Integer(UCIOptions.OPTION_NAME_SMP_Threads , DEFAULT_SMP_Threads, diff --git a/Sources/Search/src/bagaturchess/search/impl/rootsearch/parallel/MTDParallelSearch_ThreadsImpl.java b/Sources/Search/src/bagaturchess/search/impl/rootsearch/parallel/MTDParallelSearch_ThreadsImpl.java index 0129cd67..01397e20 100644 --- a/Sources/Search/src/bagaturchess/search/impl/rootsearch/parallel/MTDParallelSearch_ThreadsImpl.java +++ b/Sources/Search/src/bagaturchess/search/impl/rootsearch/parallel/MTDParallelSearch_ThreadsImpl.java @@ -100,12 +100,23 @@ protected void sequentialSearchers_Negamax(IRootSearch searcher, IBitBoard _bitb @Override - // Only one thread is enough to finish the depth protected SearchersInfo createSearchersInfo(final int startIteration) { + // Is one thread is enough to start the new depth? //return new SearchersInfo(startIteration, 0.00001d); //0.00001d (small 0+ number) - Send info when the first thread reaches new depth - return new SearchersInfo(startIteration, 1d); //1d - Send info when all threads reach the current depth //return new SearchersInfo(startIteration, 0.5d); //0.5d - Send info when the half of the threads reach the current depth + //return new SearchersInfo(startIteration, 1d); //1d - Send info when all threads reach the current depth. 1d is a risky extreme - if one thread hangs, search of the current depth will never end. + //0.75d - Send info when 75% of the threads reach the current depth + + //Assumptions what is the difference: + //1. If there is 1 TT (or less TTs) than the consensus of a smaller amount of threads should be necessary to prove the new_depth move is valid and search errors are compensated, because they share mostly the same search data stored in the TT(s). + //3. The small amount of TTs is used, the more help each thread receives (although the NPS degradation on some OS/Java versions), the bigger depth each one thread will reach faster. + //4. We use at min 2 threads and max MAX_THREADS - 2, in order to stay away from both extremes. + //2. Just note: The more aggressive static and forward pruning in the single core version of the search is, the more need of validation of the move in the new depth is necessary. + double at_least_2_threads = 2 * 1 / (double) getRootSearchConfig().getThreadsCount(); + //double max_threads_minus_2 = Math.min(1, 1 / (double) getRootSearchConfig().getTPTsCount()) - at_least_2_threads; + //return new SearchersInfo(startIteration, Math.max(at_least_2_threads, max_threads_minus_2)); + return new SearchersInfo(startIteration, at_least_2_threads); } diff --git a/Sources/Search/src/bagaturchess/search/impl/rootsearch/parallel/SearchersInfo.java b/Sources/Search/src/bagaturchess/search/impl/rootsearch/parallel/SearchersInfo.java index 739bd53b..979b0be5 100644 --- a/Sources/Search/src/bagaturchess/search/impl/rootsearch/parallel/SearchersInfo.java +++ b/Sources/Search/src/bagaturchess/search/impl/rootsearch/parallel/SearchersInfo.java @@ -34,6 +34,8 @@ public SearchersInfo(int startDepth, double _nextDepthThreshold) { searchers_searched_nodes_count = new HashMap(); searchers_tb_hits = new HashMap(); + + ChannelManager.getChannel().dump("SearchersInfo.init(...): nextDepthThreshold=" + nextDepthThreshold); } diff --git a/Sources/UCI/src/bagaturchess/uci/impl/StateManager.java b/Sources/UCI/src/bagaturchess/uci/impl/StateManager.java index aba02622..54293592 100644 --- a/Sources/UCI/src/bagaturchess/uci/impl/StateManager.java +++ b/Sources/UCI/src/bagaturchess/uci/impl/StateManager.java @@ -281,7 +281,7 @@ private void sendHello() throws IOException { String result = "\r\n\r\n"; result += "***************************************************************************"; result += "\r\n"; - result += "* Copyright (C) 2005-2022 Krasimir I. Topchiyski (k_topchiyski@yahoo.com) *"; + result += "* Copyright (C) 2005-2023 Krasimir I. Topchiyski (k_topchiyski@yahoo.com) *"; result += "\r\n"; result += "* *"; result += "\r\n";