oslConfig.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
oslConfig.h
Go to the documentation of this file.
1 /* oslConfig.h
2 */
3 #ifndef OSL_OSLCONFIG_H
4 #define OSL_OSLCONFIG_H
5
6 #include "osl/config.h"
7 #include <boost/thread/mutex.hpp>
8 #include <stdexcept>
9 #include <string>
10 #include <utility>
11
12 namespace osl
13 {
15 struct OslConfig
16 {
17 static const int MaxThreads=16;
19 static const std::string& home(const std::string& initialize_if_first_invocation="");
20 static const char * home_c_str();
21 static const std::string gpsusiConf();
22
24 static const std::string testPrivate();
25 static const std::string testPublic();
26 static const char *testPrivateFile(const std::string& filename);
27 static const char *testPublicFile(const std::string& filename);
28 static const char *testCsaFile(const std::string& filename);
29
34 static const char *openingBook(const std::string& filenamme="");
35
36 static void setVerbose(bool verbose);
37 static bool verbose();
38
39 static void showOslHome();
40 static void setNumCPUs(int ncpu);
41 static int numCPUs();
42
43 static int dfpnMaxDepth();
44 static void setDfpnMaxDepth(int);
45
46 enum UsiMode { NoUSI, PortableUSI, ExtendedUSI };
47 static UsiMode usiMode();
48 static void setUsiMode(UsiMode new_mode=PortableUSI);
49 static bool usiModeInSilent();
50 static void setUsiSilent(bool silent=true);
51
52 static bool searchExactValueInOneReply();
53 static void setSearchExactValueInOneReply(bool new_value);
54
55 static size_t residentMemoryUse();
56 static size_t memoryUseLimit()
57 {
58 return static_cast<size_t>(memory_use_limit * memory_use_percent / 100.0);
59 }
60 static void setMemoryUseLimit(size_t limit) { memory_use_limit = limit; }
61 static double memoryUseRatio()
62 {
63 return residentMemoryUse() * 1.0 / memoryUseLimit();
64 }
65 static bool isMemoryLimitEffective()
66 {
67 return memory_use_limit != memory_use_limit_system_max
68 && residentMemoryUse() > 0;
69 }
70 static void setMemoryUsePercent(double limit)
71 {
72 assert(limit > 0.0 && limit <= 100.0);
73 limit = std::max(0.01, limit);
74 limit = std::min(100.0, limit);
75 memory_use_percent = limit;
76 }
78 static unsigned int evalRandom() { return eval_random; }
79 static void setEvalRandom(unsigned int sigma) { eval_random = sigma; }
80
81 static void setUsiOutputPawnValue(int new_value) { usi_output_pawn_value = new_value; }
82 static int usiOutputPawnValue() { return usi_output_pawn_value; }
84 static int inUnitTest() { return in_unit_test; }
85 static bool inUnitTestShort() { return in_unit_test == 1; }
86 static bool inUnitTestLong() { return in_unit_test == 2; }
87 static void setInUnitTest(int new_value) { in_unit_test = new_value; }
88
90 static void setUp();
91 static bool hasByoyomi();
92 static void setHasByoyomi(bool);
93
94 static bool healthCheck();
95 static int resignThreshold();
96 static std::string configuration();
97 private:
98 static const std::string makeHome(const std::string& first_try="");
99 static const std::string makeTest();
100 static const std::string makeTestPublic();
101 static bool isGoodDir(const std::string&);
102 static void trySetDir(std::string&, const std::string&);
103 static void showOslHome(const std::string&);
104 static size_t memory_use_limit;
105 static double memory_use_percent;
106 static const size_t memory_use_limit_system_max;
107 static unsigned int eval_random;
108 static bool is_verbose;
109 static const int default_ncpus;
110 static int num_cpu;
111 static volatile UsiMode usi_mode;
112 static volatile bool usi_mode_silent;
113 static int usi_output_pawn_value;
114 static bool search_exact_value_in_one_reply, has_byoyomi;
115 static volatile bool force_root_window;
116 static volatile int root_window_alpha, root_window_beta;
117 static volatile int in_unit_test;
118 static int dfpn_max_depth;
119 public:
120 static boost::mutex lock_io;
121 };
122
123 struct NoMoreMemory : std::runtime_error
124 {
125 NoMoreMemory() : std::runtime_error("memory exhausted")
126 {
127 }
128 };
129 }
130
131 #endif /* OSL_OSLCONFIG_H */
132 // ;;; Local Variables:
133 // ;;; mode:c++
134 // ;;; c-basic-offset:2
135 // ;;; End: