]> git.sesse.net Git - stockfish/commitdiff
Merge remote-tracking branch 'upstream/master' into HEAD
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 9 Sep 2021 16:40:19 +0000 (18:40 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 9 Sep 2021 16:40:19 +0000 (18:40 +0200)
1  2 
src/Makefile
src/misc.cpp
src/ucioption.cpp

diff --combined src/Makefile
index e85cba59bac421663c14efe33bde4b60f5b70807,d92854bca193e71f83c1d457a832391f7addfcd5..cf4f4ecf15c1c4c9e03f9cf1732d5e45cde36c1d
@@@ -41,12 -41,9 +41,12 @@@ endi
  SRCS = benchmark.cpp bitbase.cpp bitboard.cpp endgame.cpp evaluate.cpp main.cpp \
        material.cpp misc.cpp movegen.cpp movepick.cpp pawns.cpp position.cpp psqt.cpp \
        search.cpp thread.cpp timeman.cpp tt.cpp uci.cpp ucioption.cpp tune.cpp syzygy/tbprobe.cpp \
-       nnue/evaluate_nnue.cpp nnue/features/half_ka_v2.cpp \
 -      nnue/evaluate_nnue.cpp nnue/features/half_ka_v2_hm.cpp
++      nnue/evaluate_nnue.cpp nnue/features/half_ka_v2_hm.cpp \
 +      hashprobe.grpc.pb.cc hashprobe.pb.cc
 +CLISRCS = client.cpp hashprobe.grpc.pb.cc hashprobe.pb.cc uci.cpp
  
  OBJS = $(notdir $(SRCS:.cpp=.o))
 +CLIOBJS = $(notdir $(CLISRCS:.cpp=.o))
  
  VPATH = syzygy:nnue:nnue/features
  
@@@ -329,7 -326,7 +329,7 @@@ endi
  ifeq ($(COMP),gcc)
        comp=gcc
        CXX=g++
 -      CXXFLAGS += -pedantic -Wextra -Wshadow
 +      CXXFLAGS += -pedantic -Wextra
  
        ifeq ($(arch),$(filter $(arch),armv7 armv8))
                ifeq ($(OS),Android)
@@@ -371,7 -368,7 +371,7 @@@ ifeq ($(COMP),mingw
                CXX=g++
        endif
  
-       CXXFLAGS += -Wextra -Wshadow
+       CXXFLAGS += -pedantic -Wextra -Wshadow
        LDFLAGS += -static
  endif
  
@@@ -408,8 -405,12 +408,12 @@@ ifeq ($(COMP),clang
  endif
  
  ifeq ($(KERNEL),Darwin)
-       CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.14
-       LDFLAGS += -arch $(arch) -mmacosx-version-min=10.14
+       CXXFLAGS += -mmacosx-version-min=10.14
+       LDFLAGS += -mmacosx-version-min=10.14
+       ifneq ($(arch),any)
+               CXXFLAGS += -arch $(arch)
+               LDFLAGS += -arch $(arch)
+       endif
        XCRUN = xcrun
  endif
  
@@@ -492,7 -493,7 +496,7 @@@ endi
  ### 3.3 Optimization
  ifeq ($(optimize),yes)
  
 -      CXXFLAGS += -O3
 +      CXXFLAGS += -O3 -g
  
        ifeq ($(comp),gcc)
                ifeq ($(OS), Android)
@@@ -815,7 -816,7 +819,7 @@@ default
  ### Section 5. Private Targets
  ### ==========================================================================
  
 -all: $(EXE) .depend
 +all: $(EXE) client .depend
  
  config-sanity: net
        @echo ""
@@@ -911,33 -912,7 +915,33 @@@ icc-profile-use
        EXTRACXXFLAGS='-prof_use -prof_dir ./profdir' \
        all
  
- .depend:
 +### GRPC
 +
 +PROTOS_PATH = .
 +PROTOC = protoc
 +GRPC_CPP_PLUGIN = grpc_cpp_plugin
 +GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`
 +
 +%.grpc.pb.h %.grpc.pb.cc: %.proto
 +      $(PROTOC) -I $(PROTOS_PATH) --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $<
 +
 +# oh my
 +%.cpp: %.cc
 +      cp $< $@
 +
 +%.pb.h %.pb.cc: %.proto
 +      $(PROTOC) -I $(PROTOS_PATH) --cpp_out=. $<
 +
 +#LDFLAGS += -Wl,-Bstatic -Wl,-\( -lprotobuf -lgrpc++_unsecure -lgrpc_unsecure -lgrpc -lz -Wl,-\) -Wl,-Bdynamic -ldl
 +LDFLAGS += /usr/lib/x86_64-linux-gnu/libprotobuf.a /usr/lib/x86_64-linux-gnu/libgrpc++_unsecure.a /usr/lib/x86_64-linux-gnu/libgrpc_unsecure.a /usr/lib/x86_64-linux-gnu/libgrpc.a /usr/lib/x86_64-linux-gnu/libcares.a /usr/lib/x86_64-linux-gnu/libgpr.a /usr/lib/x86_64-linux-gnu/libabsl_str_format_internal.a /usr/lib/x86_64-linux-gnu/libabsl_strings.a /usr/lib/x86_64-linux-gnu/libabsl_flags_marshalling.a /usr/lib/x86_64-linux-gnu/libabsl_throw_delegate.a /usr/lib/x86_64-linux-gnu/libabsl_raw_logging_internal.a /usr/lib/x86_64-linux-gnu/libabsl_base.a /usr/lib/x86_64-linux-gnu/libabsl_int128.a /usr/lib/x86_64-linux-gnu/libabsl_bad_optional_access.a -ldl -lz
 +#LDFLAGS += /usr/lib/x86_64-linux-gnu/libprotobuf.a /usr/lib/libgrpc++_unsecure.a /usr/lib/libgrpc_unsecure.a /usr/lib/libgrpc.a /usr/lib/x86_64-linux-gnu/libcares.a -ldl -lz
 +
 +client: $(CLIOBJS)
 +      $(CXX) -o $@ $(CLIOBJS) $(LDFLAGS)
 +
 +# Other stuff
 +
+ .depend: $(SRCS)
        -@$(CXX) $(DEPENDFLAGS) -MM $(SRCS) > $@ 2> /dev/null
  
  -include .depend
diff --combined src/misc.cpp
index feaf9b1a5f3f732f2f0fce1f0baf258b43e191eb,f9c123374f25162dc23e1af70dc7a1fe4076a5af..4cac7e980cce9e9694bd25d0b116542b1b77324d
@@@ -110,7 -110,14 +110,14 @@@ public
  
      static Logger l;
  
-     if (!fname.empty() && !l.file.is_open())
+     if (l.file.is_open())
+     {
+         cout.rdbuf(l.out.buf);
+         cin.rdbuf(l.in.buf);
+         l.file.close();
+     }
+     if (!fname.empty())
      {
          l.file.open(fname, ifstream::out);
  
          cin.rdbuf(&l.in);
          cout.rdbuf(&l.out);
      }
-     else if (fname.empty() && l.file.is_open())
-     {
-         cout.rdbuf(l.out.buf);
-         cin.rdbuf(l.in.buf);
-         l.file.close();
-     }
    }
  };
  
@@@ -152,7 -153,6 +153,7 @@@ string engine_info(bool to_uci) 
    {
        date >> month >> day >> year;
        ss << setw(2) << day << setw(2) << (1 + months.find(month) / 4) << year.substr(2);
 +      ss << "-asn";
    }
  
    ss << (to_uci  ? "\nid author ": " by ")
@@@ -379,6 -379,7 +380,7 @@@ void std_aligned_free(void* ptr) 
  static void* aligned_large_pages_alloc_windows(size_t allocSize) {
  
    #if !defined(_WIN64)
+     (void)allocSize; // suppress unused-parameter compiler warning
      return nullptr;
    #else
  
diff --combined src/ucioption.cpp
index a63db9e4cb772c04e33bae3856f7ee06e8196b46,0cafd3e92d03010eb32f3f77db69758617cb40c2..029137b7de083f44e53ed9f9277b8f546f95ba31
@@@ -27,7 -27,6 +27,7 @@@
  #include "thread.h"
  #include "tt.h"
  #include "uci.h"
 +#include "hashprobe.h"
  #include "syzygy/tbprobe.h"
  
  using std::string;
@@@ -35,7 -34,6 +35,7 @@@
  namespace Stockfish {
  
  UCI::OptionsMap Options; // Global object
 +std::unique_ptr<HashProbeThread> hash_probe_thread;
  
  namespace UCI {
  
@@@ -47,13 -45,6 +47,13 @@@ void on_threads(const Option& o) { Thre
  void on_tb_path(const Option& o) { Tablebases::init(o); }
  void on_use_NNUE(const Option& ) { Eval::NNUE::init(); }
  void on_eval_file(const Option& ) { Eval::NNUE::init(); }
 +void on_rpc_server_address(const Option& o) {
 +      if (hash_probe_thread) {
 +              hash_probe_thread->Shutdown();
 +      }
 +      std::string addr = o;
 +      hash_probe_thread.reset(new HashProbeThread(addr));
 +}
  
  /// Our case insensitive less() function as required by UCI protocol
  bool CaseInsensitiveLess::operator() (const string& s1, const string& s2) const {
@@@ -90,7 -81,6 +90,7 @@@ void init(OptionsMap& o) 
    o["SyzygyProbeLimit"]      << Option(7, 0, 7);
    o["Use NNUE"]              << Option(true, on_use_NNUE);
    o["EvalFile"]              << Option(EvalFileDefaultName, on_eval_file);
 +  o["RPCServerAddress"]      << Option("<empty>", on_rpc_server_address);
  }
  
  
@@@ -174,7 -164,7 +174,7 @@@ Option& Option::operator=(const string
  
    assert(!type.empty());
  
-   if (   (type != "button" && v.empty())
+   if (   (type != "button" && type != "string" && v.empty())
        || (type == "check" && v != "true" && v != "false")
        || (type == "spin" && (stof(v) < min || stof(v) > max)))
        return *this;