00001 /* oslConfig.h 00002 */ 00003 #ifndef OSL_OSLCONFIG_H 00004 #define OSL_OSLCONFIG_H 00005 00006 #include "osl/config.h" 00007 #include <boost/thread/mutex.hpp> 00008 #include <stdexcept> 00009 #include <string> 00010 00011 namespace osl 00012 { 00014 struct OslConfig 00015 { 00016 static const int MaxThreads=16; 00018 static const std::string& home(); 00019 static const char * home_c_str(); 00020 static const std::string gpsusiConf(); 00021 00023 static const std::string test(); 00024 static const char *testFile(const std::string& filename); 00025 static const char *testCsaFile(const std::string& filename); 00026 00031 static const char *openingBook(const std::string& filenamme=""); 00032 00033 static void setVerbose(bool verbose); 00034 static bool verbose(); 00035 00036 static void showOslHome(); 00037 static void setNumCPUs(int ncpu); 00038 static int numCPUs(); 00039 00040 static bool usiMode(); 00041 static void setUsiMode(bool enable=true); 00042 static bool usiModeInSilent(); 00043 static void setUsiSilent(bool silent=true); 00044 00045 static size_t residentMemoryUse(); 00046 static size_t memoryUseLimit() { return memory_use_limit; } 00047 static void setMemoryUseLimit(size_t limit) { memory_use_limit = limit; } 00048 static double memoryUseRatio() 00049 { 00050 return residentMemoryUse() * 1.0 / memoryUseLimit(); 00051 } 00052 static bool isMemoryLimitEffective() 00053 { 00054 return memory_use_limit != memory_use_limit_system_max 00055 && residentMemoryUse() > 0; 00056 } 00058 static unsigned int evalRandom() { return eval_random; } 00059 static void setEvalRandom(unsigned int sigma) { eval_random = sigma; } 00060 00061 static bool useLogLinearProbability(); 00063 static void enableLogLinearProbability(bool enabled); 00064 static void setUsiOutputPawnValue(int new_value) { usi_output_pawn_value = new_value; } 00065 static int usiOutputPawnValue() { return usi_output_pawn_value; } 00066 static bool forceRootNullWindow() { return force_root_null_window; } 00067 static int rootNullWindow() { return root_null_window; } 00068 static void setRootNullWindow(int value) 00069 { 00070 root_null_window = value; 00071 force_root_null_window = true; 00072 } 00073 static void resetRootNullWindow() { force_root_null_window = false; } 00074 private: 00075 static const std::string makeHome(); 00076 static const std::string makeTest(); 00077 static bool isGoodDir(const std::string&); 00078 static void trySetDir(std::string&, const std::string&); 00079 static void showOslHome(const std::string&); 00080 static size_t memory_use_limit; 00081 static const size_t memory_use_limit_system_max; 00082 static unsigned int eval_random; 00083 static bool is_verbose; 00084 static const int default_ncpus; 00085 static int num_cpu; 00086 static volatile bool usi_mode, usi_mode_silent, 00087 use_log_linear_probability; 00088 static int usi_output_pawn_value; 00089 static volatile bool force_root_null_window; 00090 static volatile int root_null_window; 00091 public: 00092 static boost::mutex lock_io; 00093 }; 00094 00095 struct NoMoreMemory : std::runtime_error 00096 { 00097 NoMoreMemory() : std::runtime_error("memory exhausted") 00098 { 00099 } 00100 }; 00101 } 00102 00103 #endif /* OSL_OSLCONFIG_H */ 00104 // ;;; Local Variables: 00105 // ;;; mode:c++ 00106 // ;;; c-basic-offset:2 00107 // ;;; End: