From d33e7a9b07d1aae2edf72f87ae0ba00db5a15cd9 Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sat, 12 Sep 2020 16:19:24 +0200 Subject: [PATCH 01/17] Remove conditional compilation on EVAL_LEARN --- src/eval/evaluate_common.h | 4 ---- src/evaluate.cpp | 5 ----- src/evaluate.h | 7 ++----- src/learn/convert.cpp | 3 --- src/learn/convert.h | 2 -- src/learn/gensfen.cpp | 5 +---- src/learn/gensfen.h | 2 -- src/learn/learn.cpp | 4 ---- src/learn/learn.h | 4 ---- src/learn/learning_tools.cpp | 4 ---- src/learn/learning_tools.h | 3 --- src/learn/multi_think.cpp | 7 +------ src/learn/multi_think.h | 4 ---- src/learn/packed_sfen.h | 3 --- src/learn/sfen_packer.cpp | 7 +------ src/learn/sfen_packer.h | 4 ---- src/nnue/evaluate_nnue_learner.cpp | 4 ---- src/nnue/evaluate_nnue_learner.h | 4 ---- src/nnue/trainer/trainer.h | 4 ---- src/nnue/trainer/trainer_affine_transform.h | 4 ---- src/nnue/trainer/trainer_clipped_relu.h | 4 ---- src/nnue/trainer/trainer_feature_transformer.h | 4 ---- src/nnue/trainer/trainer_input_slice.h | 4 ---- src/nnue/trainer/trainer_sum.h | 4 ---- src/position.cpp | 6 ------ src/position.h | 4 ---- src/search.cpp | 10 ---------- src/search.h | 9 --------- src/tt.cpp | 4 ---- src/tt.h | 2 -- src/uci.cpp | 7 +------ src/ucioption.cpp | 8 -------- 32 files changed, 6 insertions(+), 144 deletions(-) diff --git a/src/eval/evaluate_common.h b/src/eval/evaluate_common.h index 7799fe79b..47e69a442 100644 --- a/src/eval/evaluate_common.h +++ b/src/eval/evaluate_common.h @@ -1,8 +1,6 @@ #ifndef _EVALUATE_COMMON_H_ #define _EVALUATE_COMMON_H_ -#if defined(EVAL_LEARN) - // A common header-like function for modern evaluation functions. #include @@ -21,6 +19,4 @@ namespace Eval double get_eta(); } -#endif // defined(EVAL_LEARN) - #endif // _EVALUATE_KPPT_COMMON_H_ diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 3b0b0f888..e619a747f 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -43,11 +43,8 @@ namespace Eval { return UseNNUEMode::False; else if (mode == "true") return UseNNUEMode::True; - -#ifdef EVAL_LEARN else if (mode == "pure") return UseNNUEMode::Pure; -#endif return UseNNUEMode::False; } @@ -955,11 +952,9 @@ make_v: /// evaluation of the position from the point of view of the side to move. Value Eval::evaluate(const Position& pos) { -#ifdef EVAL_LEARN if (useNNUE == UseNNUEMode::Pure) { return NNUE::evaluate(pos); } -#endif bool classical = useNNUE == UseNNUEMode::False || abs(eg_value(pos.psq_score())) * 16 > NNUEThreshold1 * (16 + pos.rule50_count()); diff --git a/src/evaluate.h b/src/evaluate.h index 61052e907..900a77fc7 100644 --- a/src/evaluate.h +++ b/src/evaluate.h @@ -29,11 +29,8 @@ namespace Eval { enum struct UseNNUEMode { False, - True - -#ifdef EVAL_LEARN - ,Pure -#endif + True, + Pure }; std::string trace(const Position& pos); diff --git a/src/learn/convert.cpp b/src/learn/convert.cpp index e9dcb10bc..483296a1f 100644 --- a/src/learn/convert.cpp +++ b/src/learn/convert.cpp @@ -1,5 +1,3 @@ -#if defined(EVAL_LEARN) - #include "convert.h" #include "multi_think.h" @@ -606,4 +604,3 @@ namespace Learner convert(args); } } -#endif diff --git a/src/learn/convert.h b/src/learn/convert.h index a79820a3b..a41885d9a 100644 --- a/src/learn/convert.h +++ b/src/learn/convert.h @@ -5,7 +5,6 @@ #include #include -#if defined(EVAL_LEARN) namespace Learner { void convert_bin_from_pgn_extract( const std::vector& filenames, @@ -32,6 +31,5 @@ namespace Learner { void convert(std::istringstream& is); } -#endif #endif diff --git a/src/learn/gensfen.cpp b/src/learn/gensfen.cpp index ebf47188d..afbcce374 100644 --- a/src/learn/gensfen.cpp +++ b/src/learn/gensfen.cpp @@ -1,6 +1,4 @@ -#if defined(EVAL_LEARN) - -#include "gensfen.h" +#include "gensfen.h" #include "packed_sfen.h" #include "multi_think.h" @@ -1207,4 +1205,3 @@ namespace Learner std::cout << "gensfen finished." << endl; } } -#endif diff --git a/src/learn/gensfen.h b/src/learn/gensfen.h index 45e4ca23b..d39e44c99 100644 --- a/src/learn/gensfen.h +++ b/src/learn/gensfen.h @@ -5,12 +5,10 @@ #include -#if defined(EVAL_LEARN) namespace Learner { // Automatic generation of teacher position void gen_sfen(Position& pos, std::istringstream& is); } -#endif #endif \ No newline at end of file diff --git a/src/learn/learn.cpp b/src/learn/learn.cpp index 0459dd907..3f9518887 100644 --- a/src/learn/learn.cpp +++ b/src/learn/learn.cpp @@ -17,8 +17,6 @@ // → I will not be involved in the engine because it is a problem that the GUI should assist. // etc.. -#if defined(EVAL_LEARN) - #include "learn.h" #include "convert.h" @@ -2048,5 +2046,3 @@ namespace Learner } } // namespace Learner - -#endif // EVAL_LEARN diff --git a/src/learn/learn.h b/src/learn/learn.h index 7ee89009d..4b09f8252 100644 --- a/src/learn/learn.h +++ b/src/learn/learn.h @@ -1,8 +1,6 @@ #ifndef _LEARN_H_ #define _LEARN_H_ -#if defined(EVAL_LEARN) - // ---------------------- // Floating point for learning // ---------------------- @@ -78,6 +76,4 @@ namespace Learner void learn(Position& pos, std::istringstream& is); } -#endif - #endif // ifndef _LEARN_H_ diff --git a/src/learn/learning_tools.cpp b/src/learn/learning_tools.cpp index 285b3487a..925905c6a 100644 --- a/src/learn/learning_tools.cpp +++ b/src/learn/learning_tools.cpp @@ -1,7 +1,5 @@ #include "learning_tools.h" -#if defined (EVAL_LEARN) - #include "misc.h" using namespace Eval; @@ -18,5 +16,3 @@ namespace EvalLearningTools uint64_t Weight::eta1_epoch; uint64_t Weight::eta2_epoch; } - -#endif diff --git a/src/learn/learning_tools.h b/src/learn/learning_tools.h index 194a97324..dcb2c4aa1 100644 --- a/src/learn/learning_tools.h +++ b/src/learn/learning_tools.h @@ -3,8 +3,6 @@ // A set of machine learning tools related to the weight array used for machine learning of evaluation functions -#if defined (EVAL_LEARN) - #include "learn.h" #include "misc.h" // PRNG , my_insertion_sort @@ -98,5 +96,4 @@ namespace EvalLearningTools }; } -#endif // defined (EVAL_LEARN) #endif diff --git a/src/learn/multi_think.cpp b/src/learn/multi_think.cpp index 28b3e1521..043238fa2 100644 --- a/src/learn/multi_think.cpp +++ b/src/learn/multi_think.cpp @@ -1,6 +1,4 @@ -#if defined(EVAL_LEARN) - -#include "multi_think.h" +#include "multi_think.h" #include "tt.h" #include "uci.h" @@ -118,6 +116,3 @@ void MultiThink::go_think() Options[s.first] = std::string(s.second); } - - -#endif // defined(EVAL_LEARN) diff --git a/src/learn/multi_think.h b/src/learn/multi_think.h index 4f423da09..7de9d6b9f 100644 --- a/src/learn/multi_think.h +++ b/src/learn/multi_think.h @@ -1,8 +1,6 @@ #ifndef _MULTI_THINK_ #define _MULTI_THINK_ -#if defined(EVAL_LEARN) - #include "learn.h" #include "misc.h" @@ -151,6 +149,4 @@ protected: std::mutex task_mutex; }; -#endif // defined(EVAL_LEARN) && defined(YANEURAOU_2018_OTAFUKU_ENGINE) - #endif diff --git a/src/learn/packed_sfen.h b/src/learn/packed_sfen.h index 101e5e34f..3aa4fcac2 100644 --- a/src/learn/packed_sfen.h +++ b/src/learn/packed_sfen.h @@ -4,7 +4,6 @@ #include #include -#if defined(EVAL_LEARN) namespace Learner { // packed sfen @@ -45,5 +44,3 @@ namespace Learner { using PSVector = std::vector; } #endif - -#endif diff --git a/src/learn/sfen_packer.cpp b/src/learn/sfen_packer.cpp index 791870ca2..734a477bb 100644 --- a/src/learn/sfen_packer.cpp +++ b/src/learn/sfen_packer.cpp @@ -1,6 +1,4 @@ -#if defined (EVAL_LEARN) - -#include "sfen_packer.h" +#include "sfen_packer.h" #include "packed_sfen.h" @@ -402,6 +400,3 @@ namespace Learner { return sfen; } } - - -#endif // USE_SFEN_PACKER diff --git a/src/learn/sfen_packer.h b/src/learn/sfen_packer.h index af9009021..533d3fc91 100644 --- a/src/learn/sfen_packer.h +++ b/src/learn/sfen_packer.h @@ -1,8 +1,6 @@ #ifndef _SFEN_PACKER_H_ #define _SFEN_PACKER_H_ -#if defined(EVAL_LEARN) - #include "types.h" #include "learn/packed_sfen.h" @@ -19,6 +17,4 @@ namespace Learner { PackedSfen sfen_pack(Position& pos); } -#endif - #endif \ No newline at end of file diff --git a/src/nnue/evaluate_nnue_learner.cpp b/src/nnue/evaluate_nnue_learner.cpp index 8b0413e54..ea680e31b 100644 --- a/src/nnue/evaluate_nnue_learner.cpp +++ b/src/nnue/evaluate_nnue_learner.cpp @@ -1,7 +1,5 @@ // Code for learning NNUE evaluation function -#if defined(EVAL_LEARN) - #include #include #include @@ -238,5 +236,3 @@ double get_eta() { } } // namespace Eval - -#endif // defined(EVAL_LEARN) diff --git a/src/nnue/evaluate_nnue_learner.h b/src/nnue/evaluate_nnue_learner.h index 0e5fbcd2b..e9bd2fd24 100644 --- a/src/nnue/evaluate_nnue_learner.h +++ b/src/nnue/evaluate_nnue_learner.h @@ -3,8 +3,6 @@ #ifndef _EVALUATE_NNUE_LEARNER_H_ #define _EVALUATE_NNUE_LEARNER_H_ -#if defined(EVAL_LEARN) - #include "../learn/learn.h" namespace Eval { @@ -41,6 +39,4 @@ void CheckHealth(); } // namespace Eval -#endif // defined(EVAL_LEARN) - #endif diff --git a/src/nnue/trainer/trainer.h b/src/nnue/trainer/trainer.h index 94553c072..659863ad8 100644 --- a/src/nnue/trainer/trainer.h +++ b/src/nnue/trainer/trainer.h @@ -3,8 +3,6 @@ #ifndef _NNUE_TRAINER_H_ #define _NNUE_TRAINER_H_ -#if defined(EVAL_LEARN) - #include "../nnue_common.h" #include "../features/index_list.h" @@ -120,6 +118,4 @@ std::shared_ptr MakeAlignedSharedPtr(ArgumentTypes&&... arguments) { } // namespace Eval -#endif // defined(EVAL_LEARN) - #endif diff --git a/src/nnue/trainer/trainer_affine_transform.h b/src/nnue/trainer/trainer_affine_transform.h index 4b5ddee67..50751ffe3 100644 --- a/src/nnue/trainer/trainer_affine_transform.h +++ b/src/nnue/trainer/trainer_affine_transform.h @@ -3,8 +3,6 @@ #ifndef _NNUE_TRAINER_AFFINE_TRANSFORM_H_ #define _NNUE_TRAINER_AFFINE_TRANSFORM_H_ -#if defined(EVAL_LEARN) - #include "../../learn/learn.h" #include "../layers/affine_transform.h" #include "trainer.h" @@ -296,6 +294,4 @@ class Trainer> { } // namespace Eval -#endif // defined(EVAL_LEARN) - #endif diff --git a/src/nnue/trainer/trainer_clipped_relu.h b/src/nnue/trainer/trainer_clipped_relu.h index 72575bf86..cf7a24473 100644 --- a/src/nnue/trainer/trainer_clipped_relu.h +++ b/src/nnue/trainer/trainer_clipped_relu.h @@ -3,8 +3,6 @@ #ifndef _NNUE_TRAINER_CLIPPED_RELU_H_ #define _NNUE_TRAINER_CLIPPED_RELU_H_ -#if defined(EVAL_LEARN) - #include "../../learn/learn.h" #include "../layers/clipped_relu.h" #include "trainer.h" @@ -137,6 +135,4 @@ class Trainer> { } // namespace Eval -#endif // defined(EVAL_LEARN) - #endif diff --git a/src/nnue/trainer/trainer_feature_transformer.h b/src/nnue/trainer/trainer_feature_transformer.h index 6b94d952f..190e009a4 100644 --- a/src/nnue/trainer/trainer_feature_transformer.h +++ b/src/nnue/trainer/trainer_feature_transformer.h @@ -3,8 +3,6 @@ #ifndef _NNUE_TRAINER_FEATURE_TRANSFORMER_H_ #define _NNUE_TRAINER_FEATURE_TRANSFORMER_H_ -#if defined(EVAL_LEARN) - #include "../../learn/learn.h" #include "../nnue_feature_transformer.h" #include "trainer.h" @@ -372,6 +370,4 @@ class Trainer { } // namespace Eval -#endif // defined(EVAL_LEARN) - #endif diff --git a/src/nnue/trainer/trainer_input_slice.h b/src/nnue/trainer/trainer_input_slice.h index 6b0adc9f1..e2cd0c257 100644 --- a/src/nnue/trainer/trainer_input_slice.h +++ b/src/nnue/trainer/trainer_input_slice.h @@ -3,8 +3,6 @@ #ifndef _NNUE_TRAINER_INPUT_SLICE_H_ #define _NNUE_TRAINER_INPUT_SLICE_H_ -#if defined(EVAL_LEARN) - #include "../../learn/learn.h" #include "../layers/input_slice.h" #include "trainer.h" @@ -246,6 +244,4 @@ class Trainer> { } // namespace Eval -#endif // defined(EVAL_LEARN) - #endif diff --git a/src/nnue/trainer/trainer_sum.h b/src/nnue/trainer/trainer_sum.h index 0b7abe367..65a0b6810 100644 --- a/src/nnue/trainer/trainer_sum.h +++ b/src/nnue/trainer/trainer_sum.h @@ -3,8 +3,6 @@ #ifndef _NNUE_TRAINER_SUM_H_ #define _NNUE_TRAINER_SUM_H_ -#if defined(EVAL_LEARN) - #include "../../learn/learn.h" #include "../layers/sum.h" #include "trainer.h" @@ -185,6 +183,4 @@ class Trainer> { } // namespace Eval -#endif // defined(EVAL_LEARN) - #endif diff --git a/src/position.cpp b/src/position.cpp index 9465afbc7..38ac7c5c9 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -32,10 +32,8 @@ #include "uci.h" #include "syzygy/tbprobe.h" -#if defined(EVAL_LEARN) #include "learn/packed_sfen.h" #include "learn/sfen_packer.h" -#endif using std::string; @@ -1352,8 +1350,6 @@ bool Position::pos_is_ok() const { return true; } -#if defined(EVAL_LEARN) - // Add a function that directly unpacks for speed. It's pretty tough. // Write it by combining packer::unpack() and Position::set(). // If there is a problem with the passed phase and there is an error, non-zero is returned. @@ -1385,5 +1381,3 @@ void Position::sfen_pack(Learner::PackedSfen& sfen) { sfen = Learner::sfen_pack(*this); } - -#endif \ No newline at end of file diff --git a/src/position.h b/src/position.h index aa2d34e73..2163dca34 100644 --- a/src/position.h +++ b/src/position.h @@ -30,10 +30,8 @@ #include "nnue/nnue_accumulator.h" -#if defined(EVAL_LEARN) #include "learn/packed_sfen.h" #include "learn/sfen_packer.h" -#endif /// StateInfo struct stores information needed to restore a Position object to @@ -177,7 +175,6 @@ public: // Used by NNUE StateInfo* state() const; -#if defined(EVAL_LEARN) // --sfenization helper friend int Learner::set_from_packed_sfen(Position& pos, const Learner::PackedSfen& sfen, StateInfo* si, Thread* th, bool mirror); @@ -199,7 +196,6 @@ public: // Returns the position of the ball on the c side. Square king_square(Color c) const { return pieceList[make_piece(c, KING)][0]; } -#endif // EVAL_LEARN private: // Initialization helpers (used while setting up a position) diff --git a/src/search.cpp b/src/search.cpp index b92ea7c8f..f8cf3cbc6 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -54,9 +54,7 @@ using std::string; using Eval::evaluate; using namespace Search; -#if defined(EVAL_LEARN) bool Search::prune_at_shallow_depth_on_pv_node = false; -#endif namespace { @@ -991,9 +989,7 @@ moves_loop: // When in check, search starts from here ss->moveCount = ++moveCount; if (rootNode && thisThread == Threads.main() && Time.elapsed() > 3000 -#if defined(EVAL_LEARN) && !Limits.silent -#endif ) sync_cout << "info depth " << depth << " currmove " << UCI::move(move, pos.is_chess960()) @@ -1011,9 +1007,7 @@ moves_loop: // When in check, search starts from here // Step 12. Pruning at shallow depth (~200 Elo) if ( !rootNode -#ifdef EVAL_LEARN && (PvNode ? prune_at_shallow_depth_on_pv_node : true) -#endif && pos.non_pawn_material(us) && bestValue > VALUE_TB_LOSS_IN_MAX_PLY) { @@ -1564,10 +1558,8 @@ moves_loop: // When in check, search starts from here // Check for legality just before making the move if ( -#if defined(EVAL_LEARN) // HACK: pos.piece_on(from_sq(m)) sometimes will be NO_PIECE during machine learning. !pos.pseudo_legal(move) || -#endif // EVAL_LEARN !pos.legal(move) ) { @@ -1978,7 +1970,6 @@ void Tablebases::rank_root_moves(Position& pos, Search::RootMoves& rootMoves) { // --- expose the functions such as fixed depth search used for learning to the outside -#if defined (EVAL_LEARN) namespace Learner { @@ -2278,4 +2269,3 @@ namespace Learner } } -#endif diff --git a/src/search.h b/src/search.h index 5e0922738..20dfe909b 100644 --- a/src/search.h +++ b/src/search.h @@ -32,10 +32,7 @@ namespace Search { /// Threshold used for countermoves based pruning constexpr int CounterMovePruneThreshold = 0; - -#if defined(EVAL_LEARN) extern bool prune_at_shallow_depth_on_pv_node; -#endif /// Stack struct keeps track of the information we need to remember from nodes /// shallower and deeper in the tree during the search. Each search thread has @@ -90,9 +87,7 @@ struct LimitsType { time[WHITE] = time[BLACK] = inc[WHITE] = inc[BLACK] = npmsec = movetime = TimePoint(0); movestogo = depth = mate = perft = infinite = 0; nodes = 0; -#if defined (EVAL_LEARN) silent = false; -#endif } bool use_time_management() const { @@ -103,11 +98,9 @@ struct LimitsType { TimePoint time[COLOR_NB], inc[COLOR_NB], npmsec, movetime, startTime; int movestogo, depth, mate, perft, infinite; int64_t nodes; -#if defined (EVAL_LEARN) // Silent mode that does not output to the screen (for continuous self-play in process) // Do not output PV at this time. bool silent; -#endif }; extern LimitsType Limits; @@ -117,7 +110,6 @@ void clear(); } // namespace Search -#if defined(EVAL_LEARN) namespace Learner { // A pair of reader and evaluation value. Returned by Learner::search(),Learner::qsearch(). @@ -126,6 +118,5 @@ namespace Learner { ValueAndPV qsearch(Position& pos); ValueAndPV search(Position& pos, int depth_, size_t multiPV = 1, uint64_t nodesLimit = 0); } -#endif #endif // #ifndef SEARCH_H_INCLUDED diff --git a/src/tt.cpp b/src/tt.cpp index fc8ab3b1a..c64670acb 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -28,9 +28,7 @@ TranspositionTable TT; // Our global transposition table -#ifdef EVAL_LEARN bool TranspositionTable::enable_transposition_table = true; -#endif /// TTEntry::save() populates the TTEntry with a new node's data, possibly /// overwriting an old position. Update is not atomic and can be racy. @@ -120,12 +118,10 @@ void TranspositionTable::clear() { TTEntry* TranspositionTable::probe(const Key key, bool& found) const { -#ifdef EVAL_LEARN if (!enable_transposition_table) { found = false; return first_entry(0); } -#endif TTEntry* const tte = first_entry(key); const uint16_t key16 = (uint16_t)key; // Use the low 16 bits as key inside the cluster diff --git a/src/tt.h b/src/tt.h index e83b6f3c4..29072bd8d 100644 --- a/src/tt.h +++ b/src/tt.h @@ -84,9 +84,7 @@ public: return &table[mul_hi64(key, clusterCount)].entry[0]; } -#ifdef EVAL_LEARN static bool enable_transposition_table; -#endif private: friend struct TTEntry; diff --git a/src/uci.cpp b/src/uci.cpp index 0a28fc1f1..1128d4d92 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -245,7 +245,6 @@ double UCI::win_rate_model_double(double v, int ply) { // Call qsearch(),search() directly for testing // -------------------- -#if defined(EVAL_LEARN) void qsearch_cmd(Position& pos) { cout << "qsearch : "; @@ -277,8 +276,6 @@ void search_cmd(Position& pos, istringstream& is) cout << endl; } -#endif - /// UCI::loop() waits for a command from stdin, parses it and calls the appropriate /// function. Also intercepts EOF from stdin to ensure gracefully exiting if the /// GUI dies unexpectedly. When called with some command line arguments, e.g. to @@ -334,7 +331,7 @@ void UCI::loop(int argc, char* argv[]) { else if (token == "d") sync_cout << pos << sync_endl; else if (token == "eval") trace_eval(pos); else if (token == "compiler") sync_cout << compiler_info() << sync_endl; -#if defined (EVAL_LEARN) + else if (token == "gensfen") Learner::gen_sfen(pos, is); else if (token == "learn") Learner::learn(pos, is); else if (token == "convert") Learner::convert(is); @@ -343,8 +340,6 @@ void UCI::loop(int argc, char* argv[]) { else if (token == "qsearch") qsearch_cmd(pos); else if (token == "search") search_cmd(pos, is); -#endif - // test command else if (token == "test") test_cmd(pos, is); else diff --git a/src/ucioption.cpp b/src/ucioption.cpp index 91fa199bb..aa85dc07c 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -42,14 +42,12 @@ void on_threads(const Option& o) { Threads.set(size_t(o)); } void on_tb_path(const Option& o) { Tablebases::init(o); } void on_use_NNUE(const Option& ) { Eval::init_NNUE(); } void on_eval_file(const Option& ) { Eval::init_NNUE(); } -#ifdef EVAL_LEARN void on_prune_at_shallow_depth_on_pv_node(const Option& o) { Search::prune_at_shallow_depth_on_pv_node = o; } void on_enable_transposition_table(const Option& o) { TranspositionTable::enable_transposition_table = o; } -#endif /// Our case insensitive less() function as required by UCI protocol bool CaseInsensitiveLess::operator() (const string& s1, const string& s2) const { @@ -86,11 +84,7 @@ void init(OptionsMap& o) { o["SyzygyProbeDepth"] << Option(1, 1, 100); o["Syzygy50MoveRule"] << Option(true); o["SyzygyProbeLimit"] << Option(7, 0, 7); -#if defined(EVAL_LEARN) o["Use NNUE"] << Option("true var true var false var pure", "true", on_use_NNUE); -#else - o["Use NNUE"] << Option("true var true var false", "true", on_use_NNUE); -#endif // The default must follow the format nn-[SHA256 first 12 digits].nnue // for the build process (profile-build and fishtest) to work. o["EvalFile"] << Option("nn-82215d0fd0df.nnue", on_eval_file); @@ -102,7 +96,6 @@ void init(OptionsMap& o) { o["SkipLoadingEval"] << Option(false); // how many moves to use a fixed move // o["BookMoves"] << Option(16, 0, 10000); -#if defined(EVAL_LEARN) // When learning the evaluation function, you can change the folder to save the evaluation function. // Evalsave by default. This folder shall be prepared in advance. // Automatically create a folder under this folder like "0/", "1/", ... and save the evaluation function file there. @@ -111,7 +104,6 @@ void init(OptionsMap& o) { o["PruneAtShallowDepthOnPvNode"] << Option(false, on_prune_at_shallow_depth_on_pv_node); // Enable transposition table. o["EnableTranspositionTable"] << Option(true, on_enable_transposition_table); -#endif } From 1e2fca4040ef94c60c5318d1d707f395337fdb74 Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sat, 12 Sep 2020 16:23:49 +0200 Subject: [PATCH 02/17] Move learn target to build target and profile-learn to profile-build. --- src/Makefile | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/src/Makefile b/src/Makefile index 35030be74..b9ad8fbdc 100644 --- a/src/Makefile +++ b/src/Makefile @@ -735,22 +735,31 @@ endif clang-profile-use clang-profile-make build: config-sanity - $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all + $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ + EXTRACXXFLAGS=' -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \ + EXTRALDFLAGS=' $(BLASLDFLAGS) -fopenmp ' \ + all profile-build: net config-sanity objclean profileclean @echo "" @echo "Step 1/4. Building instrumented executable ..." - $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make) + $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make) \ + LEARNCXXFLAGS=' -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \ + LEARNLDFLAGS=' $(BLASLDFLAGS) -fopenmp ' @echo "" @echo "Step 2/4. Running benchmark for pgo-build ..." $(PGOBENCH) > /dev/null + $(PGOGENSFEN) > /dev/null @echo "" @echo "Step 3/4. Building optimized executable ..." $(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean - $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use) + $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use) \ + LEARNCXXFLAGS=' -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \ + LEARNLDFLAGS=' $(BLASLDFLAGS) -fopenmp ' @echo "" @echo "Step 4/4. Deleting profile data ..." $(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean + rm generated_kifu.bin strip: $(STRIP) $(EXE) @@ -901,32 +910,6 @@ icc-profile-use: EXTRACXXFLAGS='-prof_use -prof_dir ./profdir' \ all -learn: config-sanity - $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ - EXTRACXXFLAGS=' -DEVAL_LEARN -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \ - EXTRALDFLAGS=' $(BLASLDFLAGS) -fopenmp ' \ - all - -profile-learn: net config-sanity objclean profileclean - @echo "" - @echo "Step 1/4. Building instrumented executable ..." - $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make) \ - LEARNCXXFLAGS=' -DEVAL_LEARN -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \ - LEARNLDFLAGS=' $(BLASLDFLAGS) -fopenmp ' - @echo "" - @echo "Step 2/4. Running benchmark for pgo-build ..." - $(PGOGENSFEN) - @echo "" - @echo "Step 3/4. Building optimized executable ..." - $(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean - $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use) \ - LEARNCXXFLAGS=' -DEVAL_LEARN -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \ - LEARNLDFLAGS=' $(BLASLDFLAGS) -fopenmp ' - @echo "" - @echo "Step 4/4. Deleting profile data ..." - $(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean - rm generated_kifu.bin - .depend: -@$(CXX) $(DEPENDFLAGS) -MM $(SRCS) > $@ From 1da452029b3180769e206efc5a696fc37f37d1e6 Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sat, 12 Sep 2020 16:27:35 +0200 Subject: [PATCH 03/17] Update travis to use build target instead of learn. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 608d22c17..418888f64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -108,5 +108,5 @@ script: # NNUE testing - export CXXFLAGS="-O1 -fno-inline" - - make clean && make -j2 ARCH=x86-64-modern debug=no optimize=no learn > /dev/null && ../tests/instrumented_learn.sh --valgrind - - make clean && make -j2 ARCH=x86-64-modern sanitize=undefined optimize=no debug=no learn > /dev/null && ../tests/instrumented_learn.sh --sanitizer-undefined + - make clean && make -j2 ARCH=x86-64-modern debug=no optimize=no build > /dev/null && ../tests/instrumented_learn.sh --valgrind + - make clean && make -j2 ARCH=x86-64-modern sanitize=undefined optimize=no debug=no build > /dev/null && ../tests/instrumented_learn.sh --sanitizer-undefined From 9d84af11fe0fd1cf97f64efb490cd4fd35544326 Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sat, 12 Sep 2020 18:20:21 +0200 Subject: [PATCH 04/17] Remove remaining learn builds from CI. No replacement needed. --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 418888f64..6ebfeeb2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,11 +75,6 @@ script: # - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make clean && make -j2 ARCH=general-32 build && ../tests/signature.sh $benchref; fi - make clean && make -j2 ARCH=x86-64-modern profile-build && ../tests/signature.sh $benchref - # start some basic learner CI - - make clean && make -j2 ARCH=x86-64-modern learn - - make clean && make -j2 ARCH=x86-64-modern profile-learn - - make clean && make -j2 ARCH=x86-64-modern debug=yes optimize=no learn - # compile only for some more advanced architectures (might not run in travis) - make clean && make -j2 ARCH=x86-64-avx2 build - make clean && make -j2 ARCH=x86-64-bmi2 build From a6b02a61b7da82611a2f2f4227eb2308185b1b8b Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sat, 12 Sep 2020 18:22:09 +0200 Subject: [PATCH 05/17] Remove 32 bit builds. --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6ebfeeb2c..aa3254125 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,12 +67,6 @@ script: - make clean && make -j2 ARCH=x86-64 build && ../tests/signature.sh $benchref # TODO avoid _mm_malloc # - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make clean && make -j2 ARCH=general-64 build && ../tests/signature.sh $benchref; fi - # - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make clean && make -j2 ARCH=x86-32 optimize=no debug=yes build && ../tests/signature.sh $benchref; fi - - make clean && make -j2 ARCH=x86-32-sse41-popcnt build && ../tests/signature.sh $benchref - - make clean && make -j2 ARCH=x86-32-sse2 build && ../tests/signature.sh $benchref - # TODO avoid _mm_malloc - # - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make clean && make -j2 ARCH=x86-32 build && ../tests/signature.sh $benchref; fi - # - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make clean && make -j2 ARCH=general-32 build && ../tests/signature.sh $benchref; fi - make clean && make -j2 ARCH=x86-64-modern profile-build && ../tests/signature.sh $benchref # compile only for some more advanced architectures (might not run in travis) From 8d1ad6fbf6795f2574dc954ee6fc255b25e68761 Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sat, 12 Sep 2020 21:16:27 +0200 Subject: [PATCH 06/17] Add a makefile option to enable use of BLAS. Default to "no" --- src/Makefile | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/Makefile b/src/Makefile index b9ad8fbdc..1c43d6315 100644 --- a/src/Makefile +++ b/src/Makefile @@ -111,6 +111,7 @@ else SUPPORTED_ARCH=false endif +blas = no optimize = yes debug = no sanitize = no @@ -132,17 +133,25 @@ ARCH = x86-64-modern STRIP = strip ### BLAS libraries -ifeq ($(KERNEL),Linux) - BLASCXXFLAGS = - BLASLDFLAGS = -lopenblas -else - BLASCXXFLAGS = -I/mingw64/include/OpenBLAS - - ifeq ($(debug),yes) - BLASLDFLAGS = -lopenblas -Wl,-static +ifeq ($(blas), yes) + ifeq ($(KERNEL),Linux) + BLASCXXFLAGS = + BLASLDFLAGS = -lopenblas else - BLASLDFLAGS = -lopenblas -Wl,-s -static + BLASCXXFLAGS = -I/mingw64/include/OpenBLAS + + ifeq ($(debug),yes) + BLASLDFLAGS = -lopenblas -Wl,-static + else + BLASLDFLAGS = -lopenblas -Wl,-s -static + endif endif + + BLASDEFINE = -DUSE_BLAS +else + BLASCXXFLAGS = + BLASLDFLAGS = + BLASDEFINE = endif ### 2.2 Architecture specific @@ -736,7 +745,7 @@ endif build: config-sanity $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ - EXTRACXXFLAGS=' -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \ + EXTRACXXFLAGS=' $(BLASDEFINE) $(BLASCXXFLAGS) -fopenmp ' \ EXTRALDFLAGS=' $(BLASLDFLAGS) -fopenmp ' \ all @@ -744,7 +753,7 @@ profile-build: net config-sanity objclean profileclean @echo "" @echo "Step 1/4. Building instrumented executable ..." $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make) \ - LEARNCXXFLAGS=' -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \ + LEARNCXXFLAGS=' $(BLASDEFINE) $(BLASCXXFLAGS) -fopenmp ' \ LEARNLDFLAGS=' $(BLASLDFLAGS) -fopenmp ' @echo "" @echo "Step 2/4. Running benchmark for pgo-build ..." @@ -754,7 +763,7 @@ profile-build: net config-sanity objclean profileclean @echo "Step 3/4. Building optimized executable ..." $(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use) \ - LEARNCXXFLAGS=' -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \ + LEARNCXXFLAGS=' $(BLASDEFINE) $(BLASCXXFLAGS) -fopenmp ' \ LEARNLDFLAGS=' $(BLASLDFLAGS) -fopenmp ' @echo "" @echo "Step 4/4. Deleting profile data ..." From f049c4776a78ec3d3b44198c1972c0a6768815d7 Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sat, 12 Sep 2020 21:19:15 +0200 Subject: [PATCH 07/17] Add tests in CI to cover compilation of both blas=no and blas=yes. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index aa3254125..204f2657f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,6 +70,8 @@ script: - make clean && make -j2 ARCH=x86-64-modern profile-build && ../tests/signature.sh $benchref # compile only for some more advanced architectures (might not run in travis) + - make clean && make -j2 ARCH=x86-64-avx2 blas=yes build + - make clean && make -j2 ARCH=x86-64-avx2 build - make clean && make -j2 ARCH=x86-64-bmi2 build - make clean && make -j2 ARCH=x86-64-avx512 build From fbae6604b1332c64cef74e2f81c83b1ab8ba147b Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sun, 13 Sep 2020 00:18:01 +0200 Subject: [PATCH 08/17] Remove LEARNCXXFLAGS, LEARNLDFLAGS, BLASDEFINE, BLASCXXFLAGS, BLASLDFLAGS in favor of directly modifying CXXFLAGS and LDFLAGS. --- src/Makefile | 63 ++++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/src/Makefile b/src/Makefile index 1c43d6315..9b59c5bb4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -132,28 +132,6 @@ neon = no ARCH = x86-64-modern STRIP = strip -### BLAS libraries -ifeq ($(blas), yes) - ifeq ($(KERNEL),Linux) - BLASCXXFLAGS = - BLASLDFLAGS = -lopenblas - else - BLASCXXFLAGS = -I/mingw64/include/OpenBLAS - - ifeq ($(debug),yes) - BLASLDFLAGS = -lopenblas -Wl,-static - else - BLASLDFLAGS = -lopenblas -Wl,-s -static - endif - endif - - BLASDEFINE = -DUSE_BLAS -else - BLASCXXFLAGS = - BLASLDFLAGS = - BLASDEFINE = -endif - ### 2.2 Architecture specific ifeq ($(findstring x86,$(ARCH)),x86) @@ -330,9 +308,8 @@ endif ### ========================================================================== ### 3.1 Selecting compiler (default = gcc) -CXXFLAGS += -g -Wall -Wcast-qual -fno-exceptions -std=c++17 -I. $(EXTRACXXFLAGS) $(LEARNCXXFLAGS) -DEPENDFLAGS += -std=c++17 -I. -LDFLAGS += $(EXTRALDFLAGS) $(LEARNLDFLAGS) +CXXFLAGS += -g -Wall -Wcast-qual -fno-exceptions -std=c++17 -fopenmp -I. $(EXTRACXXFLAGS) +DEPENDFLAGS += -std=c++17 -I. $(EXTRALDFLAGS) ifeq ($(COMP),) COMP=gcc @@ -487,14 +464,33 @@ ifneq ($(comp),mingw) endif endif -### 3.2.1 Debugging +### 3.2.1. BLAS libraries +ifeq ($(blas), yes) + LDFLAGS += -lopenblas + + ifeq ($(KERNEL),Linux) + LDFLAGS += + else + CXXFLAGS += -I/mingw64/include/OpenBLAS + + ifeq ($(debug),yes) + LDFLAGS += -Wl,-static + else + LDFLAGS += -Wl,-s -static + endif + endif + + CXXFLAGS += -DUSE_BLAS +endif + +### 3.2.2 Debugging ifeq ($(debug),no) CXXFLAGS += -DNDEBUG else CXXFLAGS += -g endif -### 3.2.2 Debugging with undefined behavior sanitizers +### 3.2.3 Debugging with undefined behavior sanitizers ifneq ($(sanitize),no) CXXFLAGS += -g3 -fsanitize=$(sanitize) LDFLAGS += -fsanitize=$(sanitize) @@ -744,17 +740,12 @@ endif clang-profile-use clang-profile-make build: config-sanity - $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ - EXTRACXXFLAGS=' $(BLASDEFINE) $(BLASCXXFLAGS) -fopenmp ' \ - EXTRALDFLAGS=' $(BLASLDFLAGS) -fopenmp ' \ - all + $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all profile-build: net config-sanity objclean profileclean @echo "" @echo "Step 1/4. Building instrumented executable ..." - $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make) \ - LEARNCXXFLAGS=' $(BLASDEFINE) $(BLASCXXFLAGS) -fopenmp ' \ - LEARNLDFLAGS=' $(BLASLDFLAGS) -fopenmp ' + $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make) @echo "" @echo "Step 2/4. Running benchmark for pgo-build ..." $(PGOBENCH) > /dev/null @@ -762,9 +753,7 @@ profile-build: net config-sanity objclean profileclean @echo "" @echo "Step 3/4. Building optimized executable ..." $(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean - $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use) \ - LEARNCXXFLAGS=' $(BLASDEFINE) $(BLASCXXFLAGS) -fopenmp ' \ - LEARNLDFLAGS=' $(BLASLDFLAGS) -fopenmp ' + $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use) @echo "" @echo "Step 4/4. Deleting profile data ..." $(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean From 72164ba59ca4f0143b170e4721ba9aa38c591cc6 Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sun, 13 Sep 2020 02:06:33 +0200 Subject: [PATCH 09/17] Add missing -fopenmp LDFLAG --- src/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile b/src/Makefile index 9b59c5bb4..81e2ff179 100644 --- a/src/Makefile +++ b/src/Makefile @@ -309,6 +309,7 @@ endif ### 3.1 Selecting compiler (default = gcc) CXXFLAGS += -g -Wall -Wcast-qual -fno-exceptions -std=c++17 -fopenmp -I. $(EXTRACXXFLAGS) +LDFLAGS += -fopenmp DEPENDFLAGS += -std=c++17 -I. $(EXTRALDFLAGS) ifeq ($(COMP),) From 4b70f4bf23305ea6cb1e24e7fd9311cd20c6f46e Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sun, 13 Sep 2020 02:07:29 +0200 Subject: [PATCH 10/17] Add extra ld flags to the proper variable. --- src/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 81e2ff179..5477d68e9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -309,8 +309,8 @@ endif ### 3.1 Selecting compiler (default = gcc) CXXFLAGS += -g -Wall -Wcast-qual -fno-exceptions -std=c++17 -fopenmp -I. $(EXTRACXXFLAGS) -LDFLAGS += -fopenmp -DEPENDFLAGS += -std=c++17 -I. $(EXTRALDFLAGS) +LDFLAGS += -fopenmp $(EXTRALDFLAGS) +DEPENDFLAGS += -std=c++17 -I. ifeq ($(COMP),) COMP=gcc From fb877c2c3ec28ca4bd4d8586f3028ebb6f2cd6ad Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sun, 13 Sep 2020 12:14:35 +0200 Subject: [PATCH 11/17] Add some building instructions to readme. --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 6d28a9986..cdcda0d49 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,31 @@ ## Overview Stockfish NNUE is a port of a shogi neural network named NNUE (efficiently updateable neural network backwards) to Stockfish 11. To learn more about the Stockfish chess engine, look [here](stockfish.md) for an overview and [here](https://github.com/official-stockfish/Stockfish) for the official repository. +## Building +To compile: +``` +make -jN ARCH=... build +``` + +To compile with Profile Guided Optimizations. Requires that the computer that is used for compilation supports the selected `ARCH`. +``` +make -jN ARCH=... profile-build +``` + +`N` is the number of threads to use for compilation. + +`ARCH` is one of: +`x86-64-vnni512`, `x86-64-vnni256`, `x86-64-avx512`, `x86-64-bmi2`, `x86-64-avx2`, +`x86-64-sse41-popcnt`, `x86-64-modern`, `x86-64-ssse3`, `x86-64-sse3-popcnt`, +`x86-64`, `x86-32-sse41-popcnt`, `x86-32-sse2`, `x86-32`, `ppc-64`, `ppc-32, +armv7`, `armv7-neon`, `armv8`, `apple-silicon`, `general-64`, `general-32`. + +`ARCH` needs to be chosen based based on the instruction set of the CPU that will run stockfish. `x86-64-modern` will produce a binary that works on most common processors, but other options may increase performance for specific hardware. + +Additional options: + +- `blas=[yes/no]` - whether to use an external BLAS library. Default is `no`. Using an external BLAS library may have a significantly improve learning performance and by default expects openBLAS to be installed. + ## Training Guide ### Generating Training Data To generate training data from the classic eval, use the gensfen command with the setting "Use NNUE" set to "false". The given example is generation in its simplest form. There are more commands. From bd434b80c677966865c2e343658aec98c2966415 Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sun, 13 Sep 2020 13:40:56 +0200 Subject: [PATCH 12/17] debug=yes for last CI test --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 204f2657f..9dad6b1d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -100,4 +100,4 @@ script: # NNUE testing - export CXXFLAGS="-O1 -fno-inline" - make clean && make -j2 ARCH=x86-64-modern debug=no optimize=no build > /dev/null && ../tests/instrumented_learn.sh --valgrind - - make clean && make -j2 ARCH=x86-64-modern sanitize=undefined optimize=no debug=no build > /dev/null && ../tests/instrumented_learn.sh --sanitizer-undefined + - make clean && make -j2 ARCH=x86-64-modern sanitize=undefined optimize=no debug=yes build > /dev/null && ../tests/instrumented_learn.sh --sanitizer-undefined From 9ee8ce67bf6b0fa681ca7c29b5c33e52105f087e Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sun, 13 Sep 2020 13:42:13 +0200 Subject: [PATCH 13/17] Move removal of generate training data file to profileclean. --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 5477d68e9..3e10702f3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -758,7 +758,6 @@ profile-build: net config-sanity objclean profileclean @echo "" @echo "Step 4/4. Deleting profile data ..." $(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean - rm generated_kifu.bin strip: $(STRIP) $(EXE) @@ -805,6 +804,7 @@ profileclean: @rm -rf profdir @rm -f bench.txt *.gcda *.gcno ./syzygy/*.gcda ./nnue/*.gcda ./nnue/features/*.gcda *.s ./learn/*.gcda ./extra/*.gcda ./eval/*.gcda @rm -f stockfish.profdata *.profraw + @rm generated_kifu.bin default: help From e4a4f4001fe91604fed4ad01b1429d4674168aed Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sun, 13 Sep 2020 13:44:19 +0200 Subject: [PATCH 14/17] parametrize the name of the training data file generated during pgo --- src/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 3e10702f3..982df26b7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -39,8 +39,9 @@ PREFIX = /usr/local BINDIR = $(PREFIX)/bin ### Built-in benchmark for pgo-builds +PGO_TRAINING_DATA_FILE = pgo_training_data PGOBENCH = ./$(EXE) bench -PGOGENSFEN = ./$(EXE) gensfen depth 3 loop 1000 +PGOGENSFEN = ./$(EXE) gensfen depth 3 loop 1000 output_file_name $(PGO_TRAINING_DATA_FILE) ### Source and object files SRCS = benchmark.cpp bitbase.cpp bitboard.cpp endgame.cpp evaluate.cpp main.cpp \ @@ -804,7 +805,7 @@ profileclean: @rm -rf profdir @rm -f bench.txt *.gcda *.gcno ./syzygy/*.gcda ./nnue/*.gcda ./nnue/features/*.gcda *.s ./learn/*.gcda ./extra/*.gcda ./eval/*.gcda @rm -f stockfish.profdata *.profraw - @rm generated_kifu.bin + @rm $(PGO_TRAINING_DATA_FILE) default: help From 2e2de7607bbb958e699bb2e76a60ad36b912f5b0 Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sun, 13 Sep 2020 13:47:19 +0200 Subject: [PATCH 15/17] Add extension to the PGO_TRAINING_DATA_FILE so that the generated file name matches the one we try to delete. --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 982df26b7..499e8d78e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -39,7 +39,7 @@ PREFIX = /usr/local BINDIR = $(PREFIX)/bin ### Built-in benchmark for pgo-builds -PGO_TRAINING_DATA_FILE = pgo_training_data +PGO_TRAINING_DATA_FILE = pgo_training_data.bin PGOBENCH = ./$(EXE) bench PGOGENSFEN = ./$(EXE) gensfen depth 3 loop 1000 output_file_name $(PGO_TRAINING_DATA_FILE) From 89f38c938bac12171abe5d778efd4857b478693b Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sun, 13 Sep 2020 13:52:42 +0200 Subject: [PATCH 16/17] Don't prompt when the training data file doesn't exist when trying to delete it --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 499e8d78e..69517c3c9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -805,7 +805,7 @@ profileclean: @rm -rf profdir @rm -f bench.txt *.gcda *.gcno ./syzygy/*.gcda ./nnue/*.gcda ./nnue/features/*.gcda *.s ./learn/*.gcda ./extra/*.gcda ./eval/*.gcda @rm -f stockfish.profdata *.profraw - @rm $(PGO_TRAINING_DATA_FILE) + @rm -f $(PGO_TRAINING_DATA_FILE) default: help From 30a1bc4c64e0cf41269c34868b457ed6b4b5acb5 Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sun, 13 Sep 2020 14:19:30 +0200 Subject: [PATCH 17/17] Change default value of "PruneAtShallowDepthOnPvNode" so that the bench matches master. --- src/search.cpp | 2 +- src/ucioption.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index f8cf3cbc6..7c6f8ace4 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -54,7 +54,7 @@ using std::string; using Eval::evaluate; using namespace Search; -bool Search::prune_at_shallow_depth_on_pv_node = false; +bool Search::prune_at_shallow_depth_on_pv_node = true; namespace { diff --git a/src/ucioption.cpp b/src/ucioption.cpp index e4a260981..06298596a 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -101,7 +101,7 @@ void init(OptionsMap& o) { // Automatically create a folder under this folder like "0/", "1/", ... and save the evaluation function file there. o["EvalSaveDir"] << Option("evalsave"); // Prune at shallow depth on PV nodes. Setting this value to true gains elo in shallow search. - o["PruneAtShallowDepthOnPvNode"] << Option(false, on_prune_at_shallow_depth_on_pv_node); + o["PruneAtShallowDepthOnPvNode"] << Option(true, on_prune_at_shallow_depth_on_pv_node); // Enable transposition table. o["EnableTranspositionTable"] << Option(true, on_enable_transposition_table); }