]> git.sesse.net Git - stockfish/commitdiff
Assorted small cleanups
authorGiacomo Lorenzetti <g.lorenz9@protonmail.com>
Fri, 1 Apr 2022 16:33:25 +0000 (18:33 +0200)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Sun, 29 May 2022 16:42:48 +0000 (18:42 +0200)
closes https://github.com/official-stockfish/Stockfish/pull/3973

No functional change

README.md
src/Makefile
src/evaluate.cpp
src/nnue/nnue_feature_transformer.h
src/search.cpp
src/search.h
src/syzygy/tbprobe.cpp
src/types.h

index 6e6e762e63e769354762dc7c065bbb93b31397b5..f84b79d109bf59473eae25d82d281338d08db1f7 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,7 +1,6 @@
 ## Overview
 
 [![Build Status](https://github.com/official-stockfish/Stockfish/actions/workflows/stockfish.yml/badge.svg)](https://github.com/official-stockfish/Stockfish/actions)
-[![Build Status](https://ci.appveyor.com/api/projects/status/github/official-stockfish/Stockfish?branch=master&svg=true)](https://ci.appveyor.com/project/mcostalba/stockfish/branch/master)
 
 [Stockfish](https://stockfishchess.org) is a free, powerful UCI chess engine
 derived from Glaurung 2.1. Stockfish is not a complete chess program and requires a
@@ -21,7 +20,7 @@ avx2, neon, or similar).
 
 This distribution of Stockfish consists of the following files:
 
-  * [Readme.md](https://github.com/official-stockfish/Stockfish/blob/master/README.md),
+  * [README.md](https://github.com/official-stockfish/Stockfish/blob/master/README.md),
     the file you are currently reading.
 
   * [Copying.txt](https://github.com/official-stockfish/Stockfish/blob/master/Copying.txt),
index eff8bacae0abec256c9404bec30c8ca12b2839dc..cc9b4201555d4fefb3125c7b6d44ee7855d2d459 100644 (file)
@@ -542,17 +542,17 @@ ifeq ($(optimize),yes)
                endif
        endif
 
-    ifeq ($(KERNEL),Darwin)
-        ifeq ($(comp),$(filter $(comp),clang icc))
-            CXXFLAGS += -mdynamic-no-pic
-        endif
-
-        ifeq ($(comp),gcc)
-            ifneq ($(arch),arm64)
-                CXXFLAGS += -mdynamic-no-pic
-            endif
-        endif
-    endif
+       ifeq ($(KERNEL),Darwin)
+               ifeq ($(comp),$(filter $(comp),clang icc))
+                       CXXFLAGS += -mdynamic-no-pic
+               endif
+
+               ifeq ($(comp),gcc)
+                       ifneq ($(arch),arm64)
+                               CXXFLAGS += -mdynamic-no-pic
+                       endif
+               endif
+       endif
 
        ifeq ($(comp),clang)
                CXXFLAGS += -fexperimental-new-pass-manager
@@ -824,22 +824,22 @@ net:
        $(eval nnuedownloadurl := https://tests.stockfishchess.org/api/nn/$(nnuenet))
        $(eval curl_or_wget := $(shell if hash curl 2>/dev/null; then echo "curl -skL"; elif hash wget 2>/dev/null; then echo "wget -qO-"; fi))
        @if test -f "$(nnuenet)"; then \
-            echo "Already available."; \
-         else \
-            if [ "x$(curl_or_wget)" = "x" ]; then \
-               echo "Automatic download failed: neither curl nor wget is installed. Install one of these tools or download the net manually"; exit 1; \
-            else \
-               echo "Downloading $(nnuedownloadurl)"; $(curl_or_wget) $(nnuedownloadurl) > $(nnuenet);\
-            fi; \
-        fi;
+               echo "Already available."; \
+       else \
+               if [ "x$(curl_or_wget)" = "x" ]; then \
+                       echo "Automatic download failed: neither curl nor wget is installed. Install one of these tools or download the net manually"; exit 1; \
+               else \
+                       echo "Downloading $(nnuedownloadurl)"; $(curl_or_wget) $(nnuedownloadurl) > $(nnuenet);\
+               fi; \
+       fi;
        $(eval shasum_command := $(shell if hash shasum 2>/dev/null; then echo "shasum -a 256 "; elif hash sha256sum 2>/dev/null; then echo "sha256sum "; fi))
        @if [ "x$(shasum_command)" != "x" ]; then \
-           if [ "$(nnuenet)" != "nn-"`$(shasum_command) $(nnuenet) | cut -c1-12`".nnue" ]; then \
-                echo "Failed download or $(nnuenet) corrupted, please delete!"; exit 1; \
-            fi \
-         else \
-            echo "shasum / sha256sum not found, skipping net validation"; \
-        fi
+               if [ "$(nnuenet)" != "nn-"`$(shasum_command) $(nnuenet) | cut -c1-12`".nnue" ]; then \
+                       echo "Failed download or $(nnuenet) corrupted, please delete!"; exit 1; \
+               fi \
+       else \
+               echo "shasum / sha256sum not found, skipping net validation"; \
+       fi
 
 # clean binaries and objects
 objclean:
index 718c7bc035da95f92718e73fe599ee376ff793d7..9061a38421fb75ae22be58f8f77940455a17c781 100644 (file)
@@ -192,7 +192,6 @@ using namespace Trace;
 
 namespace {
 
-
   // Threshold for lazy and space evaluation
   constexpr Value LazyThreshold1    =  Value(3631);
   constexpr Value LazyThreshold2    =  Value(2084);
@@ -1084,13 +1083,14 @@ make_v:
 Value Eval::evaluate(const Position& pos) {
 
   Value v;
-  bool useClassical = false;
+  // Deciding between classical and NNUE eval (~10 Elo): for high PSQ imbalance we use classical,
+  // but we switch to NNUE during long shuffling or with high material on the board.
+  bool useClassical = (pos.this_thread()->depth > 9 || pos.count<ALL_PIECES>() > 7) &&
+          abs(eg_value(pos.psq_score())) * 5 > (856 + pos.non_pawn_material() / 64) * (10 + pos.rule50_count());
 
   // Deciding between classical and NNUE eval (~10 Elo): for high PSQ imbalance we use classical,
   // but we switch to NNUE during long shuffling or with high material on the board.
-  if (  !useNNUE
-      || ((pos.this_thread()->depth > 9 || pos.count<ALL_PIECES>() > 7) &&
-          abs(eg_value(pos.psq_score())) * 5 > (856 + pos.non_pawn_material() / 64) * (10 + pos.rule50_count())))
+  if (!useNNUE || useClassical)
   {
       v = Evaluation<NO_TRACE>(pos).value();          // classical
       useClassical = abs(v) >= 297;
index c969ac6cee8c69eef729c2510fae867197c7ddd0..34d7292c0065eb0b392d3062bfe3118bbc441fca 100644 (file)
@@ -120,12 +120,12 @@ namespace Stockfish::Eval::NNUE {
   #define vec_zero() _mm_setzero_si64()
   #define vec_set_16(a) _mm_set1_pi16(a)
   inline vec_t vec_max_16(vec_t a,vec_t b){
-      vec_t comparison = _mm_cmpgt_pi16(a,b);
-      return _mm_or_si64(_mm_and_si64(comparison, a), _mm_andnot_si64(comparison, b));
+    vec_t comparison = _mm_cmpgt_pi16(a,b);
+    return _mm_or_si64(_mm_and_si64(comparison, a), _mm_andnot_si64(comparison, b));
   }
   inline vec_t vec_min_16(vec_t a,vec_t b){
-      vec_t comparison = _mm_cmpgt_pi16(a,b);
-      return _mm_or_si64(_mm_and_si64(comparison, b), _mm_andnot_si64(comparison, a));
+    vec_t comparison = _mm_cmpgt_pi16(a,b);
+    return _mm_or_si64(_mm_and_si64(comparison, b), _mm_andnot_si64(comparison, a));
   }
   #define vec_msb_pack_16(a,b) _mm_packs_pi16(_mm_srli_pi16(a,7),_mm_srli_pi16(b,7))
   #define vec_load_psqt(a) (*(a))
@@ -150,10 +150,10 @@ namespace Stockfish::Eval::NNUE {
   #define vec_max_16(a,b) vmaxq_s16(a,b)
   #define vec_min_16(a,b) vminq_s16(a,b)
   inline vec_t vec_msb_pack_16(vec_t a, vec_t b){
-        const int8x8_t shifta = vshrn_n_s16(a, 7);
-        const int8x8_t shiftb = vshrn_n_s16(b, 7);
-       const int8x16_t compacted = vcombine_s8(shifta,shiftb);
-       return *reinterpret_cast<const vec_t*> (&compacted);
+    const int8x8_t shifta = vshrn_n_s16(a, 7);
+    const int8x8_t shiftb = vshrn_n_s16(b, 7);
+    const int8x16_t compacted = vcombine_s8(shifta,shiftb);
+    return *reinterpret_cast<const vec_t*> (&compacted);
   }
   #define vec_load_psqt(a) (*(a))
   #define vec_store_psqt(a,b) *(a)=(b)
@@ -290,7 +290,7 @@ namespace Stockfish::Eval::NNUE {
 
 #if defined(VECTOR)
 
-         constexpr IndexType OutputChunkSize = MaxChunkSize;
+          constexpr IndexType OutputChunkSize = MaxChunkSize;
           static_assert((HalfDimensions / 2) % OutputChunkSize == 0);
           constexpr IndexType NumOutputChunks = HalfDimensions / 2 / OutputChunkSize;
 
index d09ced9a670937dc44ffd4a9422950d06d6a426a..ff7b996be5710e05ef0f0a46605e8d6f00fc8ba0 100644 (file)
@@ -608,7 +608,6 @@ namespace {
     (ss+2)->killers[0]   = (ss+2)->killers[1] = MOVE_NONE;
     (ss+2)->cutoffCnt    = 0;
     ss->doubleExtensions = (ss-1)->doubleExtensions;
-    ss->depth            = depth;
     Square prevSq        = to_sq((ss-1)->currentMove);
 
     // Initialize statScore to zero for the grandchildren of the current position.
@@ -869,7 +868,6 @@ namespace {
 
         MovePicker mp(pos, ttMove, probCutBeta - ss->staticEval, depth - 3, &captureHistory);
         bool ttPv = ss->ttPv;
-        bool captureOrPromotion;
         ss->ttPv = false;
 
         while ((move = mp.next_move()) != MOVE_NONE)
@@ -877,11 +875,9 @@ namespace {
             {
                 assert(pos.capture(move) || promotion_type(move) == QUEEN);
 
-                captureOrPromotion = true;
-
                 ss->currentMove = move;
                 ss->continuationHistory = &thisThread->continuationHistory[ss->inCheck]
-                                                                          [captureOrPromotion]
+                                                                          [true]
                                                                           [pos.moved_piece(move)]
                                                                           [to_sq(move)];
 
index 8bb518325869b58c864d48ca29db32f4dfbc233a..4ad5784f8db15d7ddf7e6b2fdfdef8a9d3033b7b 100644 (file)
@@ -47,7 +47,6 @@ struct Stack {
   Move excludedMove;
   Move killers[2];
   Value staticEval;
-  Depth depth;
   int statScore;
   int moveCount;
   bool inCheck;
index a131524429939cde20141e53a624ca0c4c8e07e3..43af89f0ec9f011b986d3b3f9d4bd7d68ab2edca 100644 (file)
@@ -1290,7 +1290,7 @@ void Tablebases::init(const std::string& paths) {
     for (auto s : diagonal)
         MapA1D1D4[s] = code++;
 
-    // MapKK[] encodes all the 461 possible legal positions of two kings where
+    // MapKK[] encodes all the 462 possible legal positions of two kings where
     // the first is in the a1-d1-d4 triangle. If the first king is on the a1-d4
     // diagonal, the other one shall not to be above the a1-h8 diagonal.
     std::vector<std::pair<int, Square>> bothOnDiagonal;
index cf42bc9f8ffb97c86555db55c67e6c9861d2621e..c2087c6c07b9e8fd84be7d3033c19da397f894b7 100644 (file)
@@ -450,7 +450,7 @@ constexpr Square to_sq(Move m) {
 }
 
 constexpr int from_to(Move m) {
- return m & 0xFFF;
 return m & 0xFFF;
 }
 
 constexpr MoveType type_of(Move m) {