oslConfig.h
Go to the documentation of this file.
/* oslConfig.h
*/
#ifndef OSL_OSLCONFIG_H
#define OSL_OSLCONFIG_H
#include "osl/config.h"
#include <stdexcept>
#include <string>
#include <utility>
#include <mutex>
#include <functional>
#include <cassert>
#include <vector>
namespace osl
{
struct OslConfig
{
static const int MaxThreads=64;
static const std::string& home(const std::string& initialize_if_first_invocation="");
static const char * home_c_str();
static const std::string gpsusiConf();
static const std::string testPrivate();
static const std::string testPublic();
static const char *testPrivateFile(const std::string& filename);
static const char *testPublicFile(const std::string& filename);
static const char *testCsaFile(const std::string& filename);
static const char *openingBook(const std::string& filenamme="");
static void setVerbose(bool verbose);
static bool verbose();
static void showOslHome();
static void setNumCPUs(int ncpu);
static int concurrency();
static int dfpnMaxDepth();
static void setDfpnMaxDepth(int);
enum UsiMode { NoUSI, PortableUSI, ExtendedUSI };
static UsiMode usiMode();
static void setUsiMode(UsiMode new_mode=PortableUSI);
static bool usiModeInSilent();
static void setUsiSilent(bool silent=true);
static bool searchExactValueInOneReply();
static void setSearchExactValueInOneReply(bool new_value);
static size_t residentMemoryUse();
static size_t memoryUseLimit()
{
return static_cast<size_t>(memory_use_limit * memory_use_percent / 100.0);
}
static void setMemoryUseLimit(size_t limit) { memory_use_limit = limit; }
static double memoryUseRatio()
{
return residentMemoryUse() * 1.0 / memoryUseLimit();
}
static bool isMemoryLimitEffective()
{
return memory_use_limit != memory_use_limit_system_max
&& residentMemoryUse() > 0;
}
static void setMemoryUsePercent(double limit)
{
assert(limit > 0.0 && limit <= 100.0);
limit = std::max(0.01, limit);
limit = std::min(100.0, limit);
memory_use_percent = limit;
}
static unsigned int evalRandom() { return eval_random; }
static void setEvalRandom(unsigned int sigma) { eval_random = sigma; }
static void setUsiOutputPawnValue(int new_value) { usi_output_pawn_value = new_value; }
static int usiOutputPawnValue() { return usi_output_pawn_value; }
static int inUnitTest() { return in_unit_test; }
static bool inUnitTestShort() { return in_unit_test == 1; }
static bool inUnitTestLong() { return in_unit_test == 2; }
static void setInUnitTest(int new_value) { in_unit_test = new_value; }
static void setUp();
static bool hasByoyomi();
static void setHasByoyomi(bool);
static bool healthCheck();
static int resignThreshold();
static std::string configuration();
private:
static const std::string makeHome(const std::string& first_try="");
static const std::string makeTest();
static const std::string makeTestPublic();
static bool isGoodDir(const std::string&);
static void trySetDir(std::string&, const std::string&);
static void showOslHome(const std::string&);
static size_t memory_use_limit;
static double memory_use_percent;
static const size_t memory_use_limit_system_max;
static unsigned int eval_random;
static bool is_verbose;
static const int default_ncpus;
static int num_cpu;
static volatile UsiMode usi_mode;
static volatile bool usi_mode_silent;
static int usi_output_pawn_value;
static bool search_exact_value_in_one_reply, has_byoyomi;
static volatile bool force_root_window;
static volatile int root_window_alpha, root_window_beta;
static volatile int in_unit_test;
static int dfpn_max_depth;
public:
static std::mutex lock_io;
// designed to be called before main
static void registerInitializer(std::function<void()>);
};
struct SetUpRegister
{
SetUpRegister(std::function<void()> f) {
OslConfig::registerInitializer(f);
}
};
struct NoMoreMemory : std::runtime_error
{
NoMoreMemory() : std::runtime_error("memory exhausted")
{
}
};
}
#endif /* OSL_OSLCONFIG_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
config.h
osl
Definition additionalEffect.h:6
std
Definition basic_type.h:1353
osl::NoMoreMemory::NoMoreMemory
NoMoreMemory()
Definition oslConfig.h:135
osl::OslConfig
osl の実行環境に関する指定
Definition oslConfig.h:19
osl::OslConfig::lock_io
static std::mutex lock_io
Definition oslConfig.h:123
osl::OslConfig::is_verbose
static bool is_verbose
Definition oslConfig.h:111
osl::OslConfig::registerInitializer
static void registerInitializer(std::function< void()>)
Definition oslConfig.cc:449
osl::OslConfig::showOslHome
static void showOslHome()
Definition oslConfig.cc:191
osl::OslConfig::concurrency
static int concurrency()
Definition oslConfig.cc:133
osl::OslConfig::in_unit_test
static volatile int in_unit_test
Definition oslConfig.h:120
osl::OslConfig::usi_output_pawn_value
static int usi_output_pawn_value
Definition oslConfig.h:116
osl::OslConfig::inUnitTest
static int inUnitTest()
Definition oslConfig.h:87
osl::OslConfig::trySetDir
static void trySetDir(std::string &, const std::string &)
Definition oslConfig.cc:202
osl::OslConfig::root_window_alpha
static volatile int root_window_alpha
Definition oslConfig.h:119
osl::OslConfig::resignThreshold
static int resignThreshold()
Definition oslConfig.cc:267
osl::OslConfig::verbose
static bool verbose()
Definition oslConfig.cc:145
osl::OslConfig::testPublic
static const std::string testPublic()
Definition oslConfig.cc:306
osl::OslConfig::setUsiSilent
static void setUsiSilent(bool silent=true)
Definition oslConfig.cc:162
osl::OslConfig::gpsusiConf
static const std::string gpsusiConf()
Definition oslConfig.cc:250
osl::OslConfig::force_root_window
static volatile bool force_root_window
Definition oslConfig.h:118
osl::OslConfig::dfpn_max_depth
static int dfpn_max_depth
Definition oslConfig.h:121
osl::OslConfig::setUsiOutputPawnValue
static void setUsiOutputPawnValue(int new_value)
Definition oslConfig.h:84
osl::OslConfig::memory_use_percent
static double memory_use_percent
Definition oslConfig.h:108
osl::OslConfig::search_exact_value_in_one_reply
static bool search_exact_value_in_one_reply
Definition oslConfig.h:117
osl::OslConfig::home_c_str
static const char * home_c_str()
Definition oslConfig.cc:245
osl::OslConfig::healthCheck
static bool healthCheck()
Definition oslConfig.cc:453
osl::OslConfig::eval_random
static unsigned int eval_random
Definition oslConfig.h:110
osl::OslConfig::setMemoryUseLimit
static void setMemoryUseLimit(size_t limit)
Definition oslConfig.h:63
osl::OslConfig::searchExactValueInOneReply
static bool searchExactValueInOneReply()
Definition oslConfig.cc:166
osl::OslConfig::setEvalRandom
static void setEvalRandom(unsigned int sigma)
Definition oslConfig.h:82
osl::OslConfig::memoryUseLimit
static size_t memoryUseLimit()
Definition oslConfig.h:59
osl::OslConfig::UsiMode
UsiMode
Definition oslConfig.h:49
osl::OslConfig::PortableUSI
@ PortableUSI
Definition oslConfig.h:49
osl::OslConfig::ExtendedUSI
@ ExtendedUSI
Definition oslConfig.h:49
osl::OslConfig::NoUSI
@ NoUSI
Definition oslConfig.h:49
osl::OslConfig::dfpnMaxDepth
static int dfpnMaxDepth()
Definition oslConfig.cc:491
osl::OslConfig::setUsiMode
static void setUsiMode(UsiMode new_mode=PortableUSI)
Definition oslConfig.cc:154
osl::OslConfig::makeHome
static const std::string makeHome(const std::string &first_try="")
Definition oslConfig.cc:213
osl::OslConfig::setMemoryUsePercent
static void setMemoryUsePercent(double limit)
Definition oslConfig.h:73
osl::OslConfig::memory_use_limit_system_max
static const size_t memory_use_limit_system_max
Definition oslConfig.h:109
osl::OslConfig::isGoodDir
static bool isGoodDir(const std::string &)
Definition oslConfig.cc:196
osl::OslConfig::setUp
static void setUp()
評価関数等を初期化.
Definition oslConfig.cc:438
osl::OslConfig::openingBook
static const char * openingBook(const std::string &filenamme="")
標準の定跡ファイルを返す
Definition oslConfig.cc:369
osl::OslConfig::setNumCPUs
static void setNumCPUs(int ncpu)
Definition oslConfig.cc:124
osl::OslConfig::setInUnitTest
static void setInUnitTest(int new_value)
Definition oslConfig.h:90
osl::OslConfig::memory_use_limit
static size_t memory_use_limit
Definition oslConfig.h:107
osl::OslConfig::usi_mode
static volatile UsiMode usi_mode
Definition oslConfig.h:114
osl::OslConfig::hasByoyomi
static bool hasByoyomi()
Definition oslConfig.cc:175
osl::OslConfig::has_byoyomi
static bool has_byoyomi
Definition oslConfig.h:117
osl::OslConfig::default_ncpus
static const int default_ncpus
Definition oslConfig.h:112
osl::OslConfig::configuration
static std::string configuration()
Definition oslConfig.cc:500
osl::OslConfig::usiOutputPawnValue
static int usiOutputPawnValue()
Definition oslConfig.h:85
osl::OslConfig::makeTest
static const std::string makeTest()
Definition oslConfig.cc:274
osl::OslConfig::usiModeInSilent
static bool usiModeInSilent()
Definition oslConfig.cc:158
osl::OslConfig::setHasByoyomi
static void setHasByoyomi(bool)
Definition oslConfig.cc:180
osl::OslConfig::testPrivate
static const std::string testPrivate()
テストケースのデータ
Definition oslConfig.cc:300
osl::OslConfig::isMemoryLimitEffective
static bool isMemoryLimitEffective()
Definition oslConfig.h:68
osl::OslConfig::num_cpu
static int num_cpu
Definition oslConfig.h:113
osl::OslConfig::setSearchExactValueInOneReply
static void setSearchExactValueInOneReply(bool new_value)
Definition oslConfig.cc:170
osl::OslConfig::makeTestPublic
static const std::string makeTestPublic()
Definition oslConfig.cc:287
osl::OslConfig::root_window_beta
static volatile int root_window_beta
Definition oslConfig.h:119
osl::OslConfig::evalRandom
static unsigned int evalRandom()
Definition oslConfig.h:81
osl::OslConfig::setDfpnMaxDepth
static void setDfpnMaxDepth(int)
Definition oslConfig.cc:495
osl::OslConfig::testCsaFile
static const char * testCsaFile(const std::string &filename)
Definition oslConfig.cc:359
osl::OslConfig::testPublicFile
static const char * testPublicFile(const std::string &filename)
Definition oslConfig.cc:349
osl::OslConfig::setVerbose
static void setVerbose(bool verbose)
Definition oslConfig.cc:140
osl::OslConfig::usiMode
static UsiMode usiMode()
Definition oslConfig.cc:150
osl::OslConfig::residentMemoryUse
static size_t residentMemoryUse()
Definition oslConfig.cc:388
osl::OslConfig::inUnitTestLong
static bool inUnitTestLong()
Definition oslConfig.h:89
osl::OslConfig::usi_mode_silent
static volatile bool usi_mode_silent
Definition oslConfig.h:115
osl::OslConfig::memoryUseRatio
static double memoryUseRatio()
Definition oslConfig.h:64
osl::OslConfig::testPrivateFile
static const char * testPrivateFile(const std::string &filename)
Definition oslConfig.cc:339
osl::OslConfig::inUnitTestShort
static bool inUnitTestShort()
Definition oslConfig.h:88
osl::OslConfig::home
static const std::string & home(const std::string &initialize_if_first_invocation="")
compile時に指定されたディレクトリを返す.
Definition oslConfig.cc:239
osl::OslConfig::MaxThreads
static const int MaxThreads
Definition oslConfig.h:20
osl::SetUpRegister::SetUpRegister
SetUpRegister(std::function< void()> f)
Definition oslConfig.h:129