diff --git a/src/Makefile b/src/Makefile index 75f31108159..672171bcd59 100644 --- a/src/Makefile +++ b/src/Makefile @@ -63,7 +63,7 @@ HEADERS = benchmark.h bitboard.h evaluate.h misc.h movegen.h movepick.h \ nnue/layers/sqr_clipped_relu.h nnue/nnue_accumulator.h nnue/nnue_architecture.h \ nnue/nnue_common.h nnue/nnue_feature_transformer.h position.h \ search.h syzygy/tbprobe.h thread.h thread_win32_osx.h timeman.h \ - tt.h tune.h types.h uci.h ucioption.h perft.h nnue/network.cpp + tt.h tune.h types.h uci.h ucioption.h perft.h nnue/network.h OBJS = $(notdir $(SRCS:.cpp=.o)) diff --git a/src/misc.cpp b/src/misc.cpp index 4885a5cd35c..270d25ad4bc 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -596,14 +596,15 @@ namespace WinProcGroup { #ifndef _WIN32 -void bindThisThread(size_t) {} +void bind_this_thread(size_t) {} #else +namespace { // Retrieves logical processor information using Windows-specific // API and returns the best node id for the thread with index idx. Original // code from Texel by Peter Ă–sterlund. -static int best_node(size_t idx) { +int best_node(size_t idx) { int threads = 0; int nodes = 0; @@ -668,10 +669,11 @@ static int best_node(size_t idx) { // then return -1 and let the OS to decide what to do. return idx < groups.size() ? groups[idx] : -1; } +} // Sets the group affinity of the current thread -void bindThisThread(size_t idx) { +void bind_this_thread(size_t idx) { // Use only local variables to be thread-safe int node = best_node(idx); diff --git a/src/misc.h b/src/misc.h index 9ad5c3ca57e..de34ee111f7 100644 --- a/src/misc.h +++ b/src/misc.h @@ -200,7 +200,7 @@ inline uint64_t mul_hi64(uint64_t a, uint64_t b) { // called to set group affinity for each thread. Original code from Texel by // Peter Ă–sterlund. namespace WinProcGroup { -void bindThisThread(size_t idx); +void bind_this_thread(size_t idx); } diff --git a/src/nnue/nnue_misc.cpp b/src/nnue/nnue_misc.cpp index c443aaf19b2..7005a61025e 100644 --- a/src/nnue/nnue_misc.cpp +++ b/src/nnue/nnue_misc.cpp @@ -51,10 +51,10 @@ void hint_common_parent_position(const Position& pos, const Networks& networks) networks.big.hint_common_access(pos, false); } - +namespace { // Converts a Value into (centi)pawns and writes it in a buffer. // The buffer must have capacity for at least 5 chars. -static void format_cp_compact(Value v, char* buffer) { +void format_cp_compact(Value v, char* buffer) { buffer[0] = (v < 0 ? '-' : v > 0 ? '+' : ' '); @@ -90,7 +90,7 @@ static void format_cp_compact(Value v, char* buffer) { // Converts a Value into pawns, always keeping two decimals -static void format_cp_aligned_dot(Value v, std::stringstream& stream) { +void format_cp_aligned_dot(Value v, std::stringstream& stream) { const double pawns = std::abs(0.01 * UCI::to_cp(v)); @@ -99,6 +99,7 @@ static void format_cp_aligned_dot(Value v, std::stringstream& stream) { : ' ') << std::setiosflags(std::ios::fixed) << std::setw(6) << std::setprecision(2) << pawns; } +} // Returns a string with the value of each piece on a board, diff --git a/src/thread.cpp b/src/thread.cpp index d968271f1e6..90add4ad059 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -91,7 +91,7 @@ void Thread::idle_loop() { // just check if running threads are below a threshold, in this case, all this // NUMA machinery is not needed. if (nthreads > 8) - WinProcGroup::bindThisThread(idx); + WinProcGroup::bind_this_thread(idx); while (true) { diff --git a/src/tt.cpp b/src/tt.cpp index e62e0c17053..9d4d2eca47c 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -95,7 +95,7 @@ void TranspositionTable::clear(size_t threadCount) { threads.emplace_back([this, idx, threadCount]() { // Thread binding gives faster search on systems with a first-touch policy if (threadCount > 8) - WinProcGroup::bindThisThread(idx); + WinProcGroup::bind_this_thread(idx); // Each thread will zero its part of the hash table const size_t stride = size_t(clusterCount / threadCount), start = size_t(stride * idx), diff --git a/src/tune.cpp b/src/tune.cpp index 88b3b7912d5..3e5ebe5e6c3 100644 --- a/src/tune.cpp +++ b/src/tune.cpp @@ -30,37 +30,22 @@ using std::string; namespace Stockfish { -bool Tune::update_on_last; -const Option* LastOption = nullptr; -OptionsMap* Tune::options; -static std::map TuneResults; +bool Tune::update_on_last; +const Option* LastOption = nullptr; +OptionsMap* Tune::options; -string Tune::next(string& names, bool pop) { - - string name; - - do - { - string token = names.substr(0, names.find(',')); - - if (pop) - names.erase(0, token.size() + 1); - std::stringstream ws(token); - name += (ws >> token, token); // Remove trailing whitespace - - } while (std::count(name.begin(), name.end(), '(') - std::count(name.begin(), name.end(), ')')); - - return name; -} +namespace { +std::map TuneResults; -static void on_tune(const Option& o) { +void on_tune(const Option& o) { if (!Tune::update_on_last || LastOption == &o) Tune::read_options(); } -static void make_option(OptionsMap* options, const string& n, int v, const SetRange& r) { + +void make_option(OptionsMap* options, const string& n, int v, const SetRange& r) { // Do not generate option when there is nothing to tune (ie. min = max) if (r(v).first == r(v).second) @@ -77,6 +62,27 @@ static void make_option(OptionsMap* options, const string& n, int v, const SetRa << (r(v).second - r(v).first) / 20.0 << "," << "0.0020" << std::endl; } +} + +string Tune::next(string& names, bool pop) { + + string name; + + do + { + string token = names.substr(0, names.find(',')); + + if (pop) + names.erase(0, token.size() + 1); + + std::stringstream ws(token); + name += (ws >> token, token); // Remove trailing whitespace + + } while (std::count(name.begin(), name.end(), '(') - std::count(name.begin(), name.end(), ')')); + + return name; +} + template<> void Tune::Entry::init_option() {