From a84e3ac287fa2c2db5ee58faabdb31943acc78d0 Mon Sep 17 00:00:00 2001 From: Niklas Fiekas Date: Wed, 24 Jun 2020 23:03:00 +0200 Subject: [PATCH 1/5] Simplify use_time_management() and allow composing like other `go` commands wtime/btime can now be composed. `go depth 10 wtime 100` will let the engine use standard time management but stop if depth 10 is reached. fixes https://github.com/official-stockfish/Stockfish/issues/2767 closes https://github.com/official-stockfish/Stockfish/pull/2768 No functional change --- src/search.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/search.h b/src/search.h index 1653ce92..3e855c8b 100644 --- a/src/search.h +++ b/src/search.h @@ -91,7 +91,7 @@ struct LimitsType { } bool use_time_management() const { - return !(mate | movetime | depth | nodes | perft | infinite); + return time[WHITE] || time[BLACK]; } std::vector searchmoves; From aecfca2dc2d760df257e18cd6b29d266a3c3e68a Mon Sep 17 00:00:00 2001 From: Niklas Fiekas Date: Thu, 25 Jun 2020 12:42:25 +0200 Subject: [PATCH 2/5] support popcnt on armv8 * Supports popcnt (thanks @daylen) * bits = 64 is now the default Tested with g++ (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0 on ThunderX CN8890, yields about 9% speedup. Also tested with clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final). closes https://github.com/official-stockfish/Stockfish/pull/2770 No functional change. --- src/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 81731e66..492403d3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -134,8 +134,8 @@ endif ifeq ($(ARCH),armv8) arch = armv8-a - bits = 64 prefetch = yes + popcnt = yes endif ifeq ($(ARCH),ppc-32) @@ -322,7 +322,7 @@ endif ### 3.6 popcnt ifeq ($(popcnt),yes) - ifeq ($(arch),ppc64) + ifeq ($(arch),$(filter $(arch),ppc64 armv8-a)) CXXFLAGS += -DUSE_POPCNT else ifeq ($(comp),icc) CXXFLAGS += -msse3 -DUSE_POPCNT From ca41ee6632368676a2fb98fd2970ac9b183f0aa9 Mon Sep 17 00:00:00 2001 From: Joost VandeVondele Date: Sat, 27 Jun 2020 08:23:46 +0200 Subject: [PATCH 3/5] Revert LTO for mingw on windows. LTO with static linking is still only working with the latest versions of gcc, causing problems for some devs. on a modern mingw toolchain LTO optimizations can still be enabled as: ``` CXXFLAGS='-flto' make -j ARCH=x86-64-modern COMP=mingw profile-build ``` fixes https://github.com/official-stockfish/Stockfish/issues/2769 closes https://github.com/official-stockfish/Stockfish/pull/2774 No functional change. --- src/Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 492403d3..c3660a20 100644 --- a/src/Makefile +++ b/src/Makefile @@ -344,10 +344,20 @@ endif ### needs access to the optimization flags. ifeq ($(optimize),yes) ifeq ($(debug), no) - ifeq ($(comp),$(filter $(comp),gcc clang mingw)) + ifeq ($(comp),$(filter $(comp),gcc clang)) CXXFLAGS += -flto LDFLAGS += $(CXXFLAGS) endif + +# To use LTO and static linking on windows, the tool chain requires a recent gcc: +# gcc version 10.1 in msys2 or TDM-GCC version 9.2 are know to work, older might not. +# So, only enable it for a cross from Linux by default. + ifeq ($(comp),mingw) + ifeq ($(KERNEL),Linux) + CXXFLAGS += -flto + LDFLAGS += $(CXXFLAGS) + endif + endif endif endif From 96f2541191ae2ed93f7cefeab9ccdead931cc2d4 Mon Sep 17 00:00:00 2001 From: joergoster Date: Sat, 27 Jun 2020 19:41:13 +0200 Subject: [PATCH 4/5] Fix compilation under Linux with -DUSE_SSE41. --- src/eval/nnue/nnue_common.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/eval/nnue/nnue_common.h b/src/eval/nnue/nnue_common.h index 8ef8fee4..b82bc2c2 100644 --- a/src/eval/nnue/nnue_common.h +++ b/src/eval/nnue/nnue_common.h @@ -7,6 +7,8 @@ #if defined(USE_AVX2) #include +#elif defined(USE_SSE41) +#include #elif defined(USE_SSE2) #include #endif From 87c8b324f815d8eaaf09088b54fe2188d3879cef Mon Sep 17 00:00:00 2001 From: nodchip Date: Sun, 28 Jun 2020 11:37:15 +0900 Subject: [PATCH 5/5] Simplified source code to estimate the winning ratio from an eval value. We need to adjust the eta again after this commit is pushed. --- src/learn/learner.cpp | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/learn/learner.cpp b/src/learn/learner.cpp index f105296f..7189b5a3 100644 --- a/src/learn/learner.cpp +++ b/src/learn/learner.cpp @@ -1028,24 +1028,10 @@ double sigmoid(double x) // 評価値を勝率[0,1]に変換する関数 double winning_percentage(double value) { - // In Maxima, - // load("C:/maxima-5.44.0/cform.lisp"); - // PawnValueEg = 206; - // cform(1.0 / (1.0 + 10.0 ^ (-value / PawnValueEg / 4.0))); - constexpr double PawnValue = PawnValueEg; - return 1.0 * pow(pow(10.0, -0.25 * pow(PawnValue, -1) * value) + 1.0, -1); -} - -double delta_winning_percentage(double value) -{ - // In Maxima, - // load("C:/maxima-5.44.0/cform.lisp"); - // PawnValueEg = 206; - // cform(diff(1.0/(1.0+10.0^(-value/PawnValue/4.0)),value)); - constexpr double PawnValue = PawnValueEg; - return - 0.5756462732485115 * pow(PawnValue, -1) * pow(10.0, -0.25 * pow(PawnValue, -1) * value) * - pow(pow(10.0, -0.25 * pow(PawnValue, -1) * value) + 1.0, -2); + // 1/(1+10^(-Eval/4)) + // = 1/(1+e^(-Eval/4*ln(10)) + // = sigmoid(Eval/4*ln(10)) + return sigmoid(value / PawnValueEg / 4.0 * log(10.0)); } // 普通のシグモイド関数の導関数。 @@ -1145,7 +1131,6 @@ double calc_grad(Value deep, Value shallow , const PackedSfenValue& psv) const double q = winning_percentage(shallow); const double p = winning_percentage(deep); - const double dq = delta_winning_percentage(shallow); // 期待勝率を勝っていれば1、負けていれば 0、引き分けなら0.5として補正項として用いる。 // game_result = 1,0,-1なので1足して2で割る。 @@ -1156,9 +1141,7 @@ double calc_grad(Value deep, Value shallow , const PackedSfenValue& psv) // 実際の勝率を補正項として使っている。 // これがelmo(WCSC27)のアイデアで、現代のオーパーツ。 - const double pp = (q - p) * dq / q / (1.0 - q); - const double tt = (q - t) * dq / q / (1.0 - q); - const double grad = lambda * pp + (1.0 - lambda) * tt; + const double grad = lambda * (q - p) + (1.0 - lambda) * (q - t); return grad; }