From e4868cb59e83baf3a3950ae043bd5d04c75acc2f Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sat, 24 Oct 2020 23:17:56 +0200 Subject: [PATCH] Move setting learn search limits to learner. --- src/learn/learn.cpp | 53 +++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/src/learn/learn.cpp b/src/learn/learn.cpp index 90e6cb0f..5bb41213 100644 --- a/src/learn/learn.cpp +++ b/src/learn/learn.cpp @@ -467,6 +467,8 @@ namespace Learner void learn(uint64_t epochs); private: + static void set_learning_search_limits(); + void learn_worker(Thread& th, std::atomic& counter, uint64_t limit); void update_weights(const PSVector& psv, uint64_t epoch); @@ -510,13 +512,37 @@ namespace Learner AtomicLoss learn_loss_sum; }; + void LearnerThink::set_learning_search_limits() + { + Threads.main()->ponder = false; + + // About Search::Limits + // Be careful because this member variable is global and affects other threads. + auto& limits = Search::Limits; + + limits.startTime = now(); + + // Make the search equivalent to the "go infinite" command. (Because it is troublesome if time management is done) + limits.infinite = true; + + // Since PV is an obstacle when displayed, erase it. + limits.silent = true; + + // If you use this, it will be compared with the accumulated nodes of each thread. Therefore, do not use it. + limits.nodes = 0; + + // depth is also processed by the one passed as an argument of Learner::search(). + limits.depth = 0; + } + void LearnerThink::learn(uint64_t epochs) { - #if defined(_OPENMP) omp_set_num_threads((int)Options["Threads"]); #endif + set_learning_search_limits(); + Eval::NNUE::verify_any_net_loaded(); const PSVector sfen_for_mse = @@ -929,27 +955,6 @@ namespace Learner return false; } - static void set_learning_search_limits() - { - // About Search::Limits - // Be careful because this member variable is global and affects other threads. - auto& limits = Search::Limits; - - limits.startTime = now(); - - // Make the search equivalent to the "go infinite" command. (Because it is troublesome if time management is done) - limits.infinite = true; - - // Since PV is an obstacle when displayed, erase it. - limits.silent = true; - - // If you use this, it will be compared with the accumulated nodes of each thread. Therefore, do not use it. - limits.nodes = 0; - - // depth is also processed by the one passed as an argument of Learner::search(). - limits.depth = 0; - } - // Learning from the generated game record void learn(istringstream& is) { @@ -1159,10 +1164,6 @@ namespace Learner out << "INFO: Started initialization." << endl; - Threads.main()->ponder = false; - - set_learning_search_limits(); - Eval::NNUE::initialize_training(params.seed, out); Eval::NNUE::set_batch_size(nn_batch_size); Eval::NNUE::set_options(nn_options);