diff --git a/DroidFish/jni/nativeutil.cpp b/DroidFish/jni/nativeutil.cpp index 83520d0..7ff5c85 100644 --- a/DroidFish/jni/nativeutil.cpp +++ b/DroidFish/jni/nativeutil.cpp @@ -21,17 +21,6 @@ #include #include -/* - * Class: org_petero_droidfish_engine_EngineUtil - * Method: getNPhysicalProcessors - * Signature: ()I - */ -extern "C" JNIEXPORT jint JNICALL Java_org_petero_droidfish_engine_EngineUtil_getNPhysicalProcessors - (JNIEnv *, jclass) -{ - return sysconf(_SC_NPROCESSORS_ONLN); -} - /* * Class: org_petero_droidfish_engine_EngineUtil * Method: chmod diff --git a/DroidFish/res/values/strings.xml b/DroidFish/res/values/strings.xml index bf4f59b..28572cc 100644 --- a/DroidFish/res/values/strings.xml +++ b/DroidFish/res/values/strings.xml @@ -1,7 +1,6 @@ DroidFish - 1 16 60 120000 @@ -262,8 +261,6 @@ you are not actively using the program.\ Only supported by internal engines. Analysis mode always uses full strength. Pondering Let engine think while waiting for opponent\'s move. Supported by most engines. - Threads - Number of engine threads (CPU cores) to use. Not supported by all engines. Hash Table Hash table size in megabytes Time Control @@ -422,26 +419,6 @@ you are not actively using the program.\ Mode button Backward button Forward button - - Automatic - 1 - 2 - 3 - 4 - 6 - 8 - 16 - - - 0 - 1 - 2 - 3 - 4 - 6 - 8 - 16 - English letters Local language letters diff --git a/DroidFish/res/xml/preferences.xml b/DroidFish/res/xml/preferences.xml index 08fc4d7..f5ad12b 100644 --- a/DroidFish/res/xml/preferences.xml +++ b/DroidFish/res/xml/preferences.xml @@ -42,14 +42,6 @@ android:summary="@string/prefs_ponderMode_summary" android:defaultValue="false"> - - 1 if multiPV mode is supported. */ private int maxPV = 1; - private int numCPUs = 1; private String engineName = "Computer"; /** Engine state. */ @@ -118,7 +117,6 @@ public class DroidComputerPlayer { int movesToGo; // Number of moves to next time control String engine; // Engine name (identifier) - int engineThreads; // Number of engine threads to use int strength; // Engine strength setting (0 - 1000) int numPV; // Number of PV lines to compute @@ -156,7 +154,6 @@ public class DroidComputerPlayer { * @param ponderEnabled True if pondering is enabled in the GUI. Can affect time management. * @param ponderMove Move to ponder, or null for non-ponder search. * @param engine Chess engine to use for searching. - * @param engineThreads Number of engine threads to use, if supported by engine. * @param strength Engine strength setting. */ public static SearchRequest searchRequest(int id, long now, @@ -164,8 +161,7 @@ public class DroidComputerPlayer { Position currPos, boolean drawOffer, int wTime, int bTime, int wInc, int bInc, int movesToGo, boolean ponderEnabled, Move ponderMove, - String engine, int engineThreads, - int strength) { + String engine, int strength) { SearchRequest sr = new SearchRequest(); sr.searchId = id; sr.startTime = now; @@ -181,7 +177,6 @@ public class DroidComputerPlayer { sr.bInc = bInc; sr.movesToGo = movesToGo; sr.engine = engine; - sr.engineThreads = engineThreads; sr.strength = strength; sr.numPV = 1; sr.ponderEnabled = ponderEnabled; @@ -199,7 +194,6 @@ public class DroidComputerPlayer { * @param currPos Position to analyze. * @param drawOffer True if other side have offered draw. * @param engine Chess engine to use for searching - * @param engineThreads Number of threads to use, or 0 for default value. * @param numPV Multi-PV mode. */ public static SearchRequest analyzeRequest(int id, Position prevPos, @@ -207,7 +201,6 @@ public class DroidComputerPlayer { Position currPos, boolean drawOffer, String engine, - int engineThreads, int numPV) { SearchRequest sr = new SearchRequest(); sr.searchId = id; @@ -220,7 +213,6 @@ public class DroidComputerPlayer { sr.isAnalyze = true; sr.wTime = sr.bTime = sr.wInc = sr.bInc = sr.movesToGo = 0; sr.engine = engine; - sr.engineThreads = engineThreads; sr.strength = 1000; sr.numPV = numPV; sr.ponderEnabled = false; @@ -574,7 +566,6 @@ public class DroidComputerPlayer { } uciEngine.setOption("Ponder", sr.ponderEnabled); uciEngine.setOption("UCI_AnalyseMode", false); - uciEngine.setNThreads(sr.engineThreads > 0 ? sr.engineThreads : numCPUs); uciEngine.writeLineToEngine(posStr.toString()); if (sr.wTime < 1) sr.wTime = 1; if (sr.bTime < 1) sr.bTime = 1; @@ -611,7 +602,6 @@ public class DroidComputerPlayer { } uciEngine.writeLineToEngine(posStr.toString()); uciEngine.setOption("UCI_AnalyseMode", true); - uciEngine.setNThreads(sr.engineThreads > 0 ? sr.engineThreads : numCPUs); StringBuilder goStr = new StringBuilder(96); goStr.append("go infinite"); if (sr.searchMoves != null) { @@ -655,9 +645,6 @@ public class DroidComputerPlayer { uciEngine.clearOptions(); uciEngine.writeLineToEngine("uci"); - int nThreads = getNumCPUs(); - if (nThreads > 8) nThreads = 8; - numCPUs = nThreads; maxPV = 1; engineState.engine = searchRequest.engine; engineState.setState(MainState.READ_OPTIONS); @@ -1022,46 +1009,6 @@ public class DroidComputerPlayer { } } - /** Try to find out how many CPU cores are present. */ - private static final int getNumCPUs() { - int nCPUsFromProc = getNumCPUsFromProc(); - int nCPUsFromSys = getNumCPUsFromSys(); - int nCPUsFromOS = EngineUtil.getNPhysicalProcessors(); - return Math.max(Math.max(nCPUsFromProc, nCPUsFromSys), nCPUsFromOS); - } - - private static final int getNumCPUsFromProc() { - int nCPUsFromProc = 1; - try { - FileReader fr = new FileReader("/proc/stat"); - BufferedReader inBuf = new BufferedReader(fr, 8192); - String line; - int nCPUs = 0; - while ((line = inBuf.readLine()) != null) { - if ((line.length() >= 4) && line.startsWith("cpu") && Character.isDigit(line.charAt(3))) - nCPUs++; - } - inBuf.close(); - if (nCPUs > 1) - nCPUsFromProc = nCPUs; - } catch (IOException e) { - } - return nCPUsFromProc; - } - - private static final int getNumCPUsFromSys() { - File dir = new File("/sys/devices/system/cpu"); - File[] files = dir.listFiles(new FileFilter() { - @Override - public boolean accept(File pathname) { - return Pattern.matches("cpu[0-9]+", pathname.getName()); - } - }); - if (files == null) - return 1; - return Math.max(files.length, 1); - } - private final static void myAssert(boolean b) { if (!b) throw new RuntimeException(); diff --git a/DroidFish/src/org/petero/droidfish/engine/EngineUtil.java b/DroidFish/src/org/petero/droidfish/engine/EngineUtil.java index 6299a36..9168b4e 100644 --- a/DroidFish/src/org/petero/droidfish/engine/EngineUtil.java +++ b/DroidFish/src/org/petero/droidfish/engine/EngineUtil.java @@ -33,9 +33,6 @@ public class EngineUtil { System.loadLibrary("nativeutil"); } - /** Return number of physical processors, i.e. hyper-threading ignored. */ - final static native int getNPhysicalProcessors(); - /** Return file name of the internal stockfish executable. */ public static String internalStockFishName() { String abi = Build.CPU_ABI; diff --git a/DroidFish/src/org/petero/droidfish/engine/UCIEngine.java b/DroidFish/src/org/petero/droidfish/engine/UCIEngine.java index 2eb2e92..ffaa64e 100644 --- a/DroidFish/src/org/petero/droidfish/engine/UCIEngine.java +++ b/DroidFish/src/org/petero/droidfish/engine/UCIEngine.java @@ -85,7 +85,4 @@ public interface UCIEngine { /** Register an option as supported by the engine. * @param tokens The UCI option line sent by the engine, split in words. */ public UCIOptions.OptionBase registerOption(String[] tokens); - - /** Set number of search threads to use. */ - public void setNThreads(int nThreads); } diff --git a/DroidFish/src/org/petero/droidfish/engine/UCIEngineBase.java b/DroidFish/src/org/petero/droidfish/engine/UCIEngineBase.java index 578dca3..fdc0810 100644 --- a/DroidFish/src/org/petero/droidfish/engine/UCIEngineBase.java +++ b/DroidFish/src/org/petero/droidfish/engine/UCIEngineBase.java @@ -140,7 +140,7 @@ public abstract class UCIEngineBase implements UCIEngine { name = name.toLowerCase(Locale.US); if (name.startsWith("uci_") || name.equals("hash") || name.equals("ponder") || name.equals("multipv") || name.equals("gaviotatbpath") || - name.equals("syzygypath") || name.equals("threads") || name.equals("cores")) + name.equals("syzygypath")) return false; return true; } @@ -285,12 +285,4 @@ public abstract class UCIEngineBase implements UCIEngine { } return false; } - - @Override - public final void setNThreads(int nThreads) { - if (options.contains("Threads")) - setOption("Threads", nThreads); - else if (options.contains("Cores")) - setOption("Cores", nThreads); - } } diff --git a/DroidFish/src/org/petero/droidfish/gamelogic/DroidChessController.java b/DroidFish/src/org/petero/droidfish/gamelogic/DroidChessController.java index 4f1d629..791aeb6 100644 --- a/DroidFish/src/org/petero/droidfish/gamelogic/DroidChessController.java +++ b/DroidFish/src/org/petero/droidfish/gamelogic/DroidChessController.java @@ -938,8 +938,7 @@ public class DroidChessController { SearchRequest sr = DroidComputerPlayer.SearchRequest.analyzeRequest( searchId, ph.first, ph.second, new Position(game.currPos()), - game.haveDrawOffer(), engine, - gui.engineThreads(), numPV); + game.haveDrawOffer(), engine, numPV); computerPlayer.queueAnalyzeRequest(sr); } else if (computersTurn || ponder) { listener.clearSearchInfo(searchId); @@ -963,8 +962,7 @@ public class DroidChessController { game.haveDrawOffer(), wTime, bTime, wInc, bInc, movesToGo, gui.ponderMode(), fPonderMove, - engine, gui.engineThreads(), - strength); + engine, strength); computerPlayer.queueSearchRequest(sr); } else { computerPlayer.queueStartEngine(searchId, engine);