Skip to content

Commit

Permalink
Set CountTranspositionTables from 1 to sqrt(threads_count) + tune and…
Browse files Browse the repository at this point in the history
… print nextDepthThreshold
  • Loading branch information
bagaturchess committed Feb 5, 2023
1 parent 276217b commit 5b6e5d8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public SearchersInfo(int startDepth, double _nextDepthThreshold) {

searchers_searched_nodes_count = new HashMap<IRootSearch, Long>();
searchers_tb_hits = new HashMap<IRootSearch, Long>();

ChannelManager.getChannel().dump("SearchersInfo.init(...): nextDepthThreshold=" + nextDepthThreshold);
}


Expand Down
2 changes: 1 addition & 1 deletion Sources/UCI/src/bagaturchess/uci/impl/StateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 5b6e5d8

Please sign in to comment.