DroidFish: Recognize UCI option "Cores" to set number of search threads.

This commit is contained in:
Peter Osterlund
2014-04-19 10:21:49 +00:00
parent c9b019e581
commit bcc8353129
5 changed files with 16 additions and 5 deletions

View File

@@ -553,7 +553,7 @@ public class DroidComputerPlayer {
} }
uciEngine.setOption("Ponder", sr.ponderEnabled); uciEngine.setOption("Ponder", sr.ponderEnabled);
uciEngine.setOption("UCI_AnalyseMode", false); uciEngine.setOption("UCI_AnalyseMode", false);
uciEngine.setOption("Threads", sr.engineThreads > 0 ? sr.engineThreads : numCPUs); uciEngine.setNThreads(sr.engineThreads > 0 ? sr.engineThreads : numCPUs);
uciEngine.writeLineToEngine(posStr.toString()); uciEngine.writeLineToEngine(posStr.toString());
if (sr.wTime < 1) sr.wTime = 1; if (sr.wTime < 1) sr.wTime = 1;
if (sr.bTime < 1) sr.bTime = 1; if (sr.bTime < 1) sr.bTime = 1;
@@ -590,7 +590,7 @@ public class DroidComputerPlayer {
} }
uciEngine.writeLineToEngine(posStr.toString()); uciEngine.writeLineToEngine(posStr.toString());
uciEngine.setOption("UCI_AnalyseMode", true); uciEngine.setOption("UCI_AnalyseMode", true);
uciEngine.setOption("Threads", sr.engineThreads > 0 ? sr.engineThreads : numCPUs); uciEngine.setNThreads(sr.engineThreads > 0 ? sr.engineThreads : numCPUs);
StringBuilder goStr = new StringBuilder(96); StringBuilder goStr = new StringBuilder(96);
goStr.append("go infinite"); goStr.append("go infinite");
if (sr.searchMoves != null) { if (sr.searchMoves != null) {

View File

@@ -200,7 +200,7 @@ public class ExternalEngine extends UCIEngineBase {
return true; return true;
if (hashMB != getHashMB(engineOptions.hashMB)) if (hashMB != getHashMB(engineOptions.hashMB))
return false; return false;
if (haveOption("gaviotatbpath") && !gaviotaTbPath.equals(engineOptions.gtbPath)) if (hasOption("gaviotatbpath") && !gaviotaTbPath.equals(engineOptions.gtbPath))
return false; return false;
return true; return true;
} }

View File

@@ -223,7 +223,7 @@ public class NetworkEngine extends UCIEngineBase {
return false; return false;
if (hashMB != engineOptions.hashMB) if (hashMB != engineOptions.hashMB)
return false; return false;
if (haveOption("gaviotatbpath") && !gaviotaTbPath.equals(engineOptions.gtbPath)) if (hasOption("gaviotatbpath") && !gaviotaTbPath.equals(engineOptions.gtbPath))
return false; return false;
return true; return true;
} }

View File

@@ -71,4 +71,7 @@ public interface UCIEngine {
/** Register an option as supported by the engine. */ /** Register an option as supported by the engine. */
public void registerOption(String optName); public void registerOption(String optName);
/** Set number of search threads to use. */
public void setNThreads(int nThreads);
} }

View File

@@ -89,7 +89,7 @@ public abstract class UCIEngineBase implements UCIEngine {
} }
/** Return true if engine has option optName. */ /** Return true if engine has option optName. */
protected boolean haveOption(String optName) { protected boolean hasOption(String optName) {
return allOptions.contains(optName); return allOptions.contains(optName);
} }
@@ -114,4 +114,12 @@ public abstract class UCIEngineBase implements UCIEngine {
writeLineToEngine(String.format(Locale.US, "setoption name %s value %s", name, value)); writeLineToEngine(String.format(Locale.US, "setoption name %s value %s", name, value));
currOptions.put(lcName, value); currOptions.put(lcName, value);
} }
@Override
public void setNThreads(int nThreads) {
if (allOptions.contains("threads"))
setOption("Threads", nThreads);
else if (allOptions.contains("cores"))
setOption("Cores", nThreads);
}
} }