]> git.sesse.net Git - stockfish/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 29 Dec 2021 13:33:22 +0000 (14:33 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 29 Dec 2021 13:33:22 +0000 (14:33 +0100)
1  2 
src/Makefile
src/misc.cpp

diff --combined src/Makefile
index 505fb2cf57bad4a41538b3a15688d48a73dc3503,f00df79fa410bbff21e693ebf31f7d4ac550c4fc..3971ea78fda15c111bfa1aebbb2dd55582cddd8b
@@@ -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_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
  
@@@ -81,6 -78,7 +81,7 @@@ endi
  # ssse3 = yes/no      --- -mssse3          --- Use Intel Supplemental Streaming SIMD Extensions 3
  # sse41 = yes/no      --- -msse4.1         --- Use Intel Streaming SIMD Extensions 4.1
  # avx2 = yes/no       --- -mavx2           --- Use Intel Advanced Vector Extensions 2
+ # avxvnni = yes/no    --- -mavxvnni        --- Use Intel Vector Neural Network Instructions AVX
  # avx512 = yes/no     --- -mavx512bw       --- Use Intel Advanced Vector Extensions 512
  # vnni256 = yes/no    --- -mavx512vnni     --- Use Intel Vector Neural Network Instructions 256
  # vnni512 = yes/no    --- -mavx512vnni     --- Use Intel Vector Neural Network Instructions 512
@@@ -103,8 -101,8 +104,8 @@@ endi
  # explicitly check for the list of supported architectures (as listed with make help),
  # the user can override with `make ARCH=x86-32-vnni256 SUPPORTED_ARCH=true`
  ifeq ($(ARCH), $(filter $(ARCH), \
-                  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-vnni512 x86-64-vnni256 x86-64-avx512 x86-64-avxvnni 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 e2k \
                   armv7 armv7-neon armv8 apple-silicon general-64 general-32))
     SUPPORTED_ARCH=true
@@@ -125,10 -123,12 +126,12 @@@ sse2 = n
  ssse3 = no
  sse41 = no
  avx2 = no
+ avxvnni = no
  avx512 = no
  vnni256 = no
  vnni512 = no
  neon = no
+ arm_version = 0
  STRIP = strip
  
  ### 2.2 Architecture specific
@@@ -195,6 -195,17 +198,17 @@@ ifeq ($(findstring -avx2,$(ARCH)),-avx2
        avx2 = yes
  endif
  
+ ifeq ($(findstring -avxvnni,$(ARCH)),-avxvnni)
+       popcnt = yes
+       sse = yes
+       sse2 = yes
+       ssse3 = yes
+       sse41 = yes
+       avx2 = yes
+       avxvnni = yes
+       pext = yes
+ endif
  ifeq ($(findstring -bmi2,$(ARCH)),-bmi2)
        popcnt = yes
        sse = yes
@@@ -265,6 -276,7 +279,7 @@@ ifeq ($(ARCH),armv7
        arch = armv7
        prefetch = yes
        bits = 32
+       arm_version = 7
  endif
  
  ifeq ($(ARCH),armv7-neon)
        popcnt = yes
        neon = yes
        bits = 32
+       arm_version = 7
  endif
  
  ifeq ($(ARCH),armv8)
        prefetch = yes
        popcnt = yes
        neon = yes
+       arm_version = 8
  endif
  
  ifeq ($(ARCH),apple-silicon)
        prefetch = yes
        popcnt = yes
        neon = yes
+       arm_version = 8
  endif
  
  ifeq ($(ARCH),ppc-32)
@@@ -329,7 -344,7 +347,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)
@@@ -444,6 -459,9 +462,9 @@@ else ifeq ($(comp),clang
  else
        profile_make = gcc-profile-make
        profile_use = gcc-profile-use
+       ifeq ($(KERNEL),Darwin)
+               EXTRAPROFILEFLAGS = -fvisibility=hidden
+       endif
  endif
  
  ### Travis CI script uses COMPILER to overwrite CXX
@@@ -496,7 -514,7 +517,7 @@@ endi
  ### 3.3 Optimization
  ifeq ($(optimize),yes)
  
 -      CXXFLAGS += -O3
 +      CXXFLAGS += -O3 -g
  
        ifeq ($(comp),gcc)
                ifeq ($(OS), Android)
                endif
        endif
  
-       ifeq ($(comp),$(filter $(comp),gcc clang icc))
-               ifeq ($(KERNEL),Darwin)
-                       CXXFLAGS += -mdynamic-no-pic
-               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
@@@ -547,6 -571,13 +574,13 @@@ ifeq ($(avx2),yes
        endif
  endif
  
+ ifeq ($(avxvnni),yes)
+       CXXFLAGS += -DUSE_VNNI -DUSE_AVXVNNI
+       ifeq ($(comp),$(filter $(comp),gcc clang mingw))
+               CXXFLAGS += -mavxvnni
+       endif
+ endif
  ifeq ($(avx512),yes)
        CXXFLAGS += -DUSE_AVX512
        ifeq ($(comp),$(filter $(comp),gcc clang mingw))
@@@ -597,7 -628,7 +631,7 @@@ ifeq ($(mmx),yes
  endif
  
  ifeq ($(neon),yes)
-       CXXFLAGS += -DUSE_NEON
+       CXXFLAGS += -DUSE_NEON=$(arm_version)
        ifeq ($(KERNEL),Linux)
        ifneq ($(COMP),ndk)
        ifneq ($(arch),armv8)
@@@ -692,6 -723,7 +726,7 @@@ help
        @echo "x86-64-vnni512          > x86 64-bit with vnni support 512bit wide"
        @echo "x86-64-vnni256          > x86 64-bit with vnni support 256bit wide"
        @echo "x86-64-avx512           > x86 64-bit with avx512 support"
+       @echo "x86-64-avxvnni          > x86 64-bit with avxvnni support"
        @echo "x86-64-bmi2             > x86 64-bit with bmi2 support"
        @echo "x86-64-avx2             > x86 64-bit with avx2 support"
        @echo "x86-64-sse41-popcnt     > x86 64-bit with sse41 and popcnt support"
@@@ -819,7 -851,7 +854,7 @@@ default
  ### Section 5. Private Targets
  ### ==========================================================================
  
 -all: $(EXE) .depend
 +all: $(EXE) client .depend
  
  config-sanity: net
        @echo ""
        @echo "ssse3: '$(ssse3)'"
        @echo "sse41: '$(sse41)'"
        @echo "avx2: '$(avx2)'"
+       @echo "avxvnni: '$(avxvnni)'"
        @echo "avx512: '$(avx512)'"
        @echo "vnni256: '$(vnni256)'"
        @echo "vnni512: '$(vnni512)'"
        @echo "neon: '$(neon)'"
+       @echo "arm_version: '$(arm_version)'"
        @echo ""
        @echo "Flags:"
        @echo "CXX: $(CXX)"
@@@ -895,12 -929,14 +932,14 @@@ gcc-profile-make
        @mkdir -p profdir
        $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
        EXTRACXXFLAGS='-fprofile-generate=profdir' \
+       EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
        EXTRALDFLAGS='-lgcov' \
        all
  
  gcc-profile-use:
        $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
        EXTRACXXFLAGS='-fprofile-use=profdir -fno-peel-loops -fno-tracer' \
+       EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
        EXTRALDFLAGS='-lgcov' \
        all
  
@@@ -915,32 -951,6 +954,32 @@@ icc-profile-use
        EXTRACXXFLAGS='-prof_use -prof_dir ./profdir' \
        all
  
 +### 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
  
diff --combined src/misc.cpp
index 769761d9b39510c4f12e97d6590bf8a877a98966,b46786dff08e0e98badfbbe1373a08d3979c8432..87b20eb5725958143d578ef993ddac02262a8041
@@@ -155,7 -155,6 +155,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 ")
@@@ -516,7 -515,7 +516,7 @@@ int best_node(size_t idx) 
    if (!fun1)
        return -1;
  
-   // First call to GetLogicalProcessorInformationEx() to get returnLength. 
+   // First call to GetLogicalProcessorInformationEx() to get returnLength.
    // We expect the call to fail due to null buffer.
    if (fun1(RelationAll, nullptr, &returnLength))
        return -1;
@@@ -590,13 -589,13 +590,13 @@@ void bindThisThread(size_t idx) 
    if (!fun2 || !fun3)
        return;
  
-   if (!fun4 || !fun5) 
+   if (!fun4 || !fun5)
    {
        GROUP_AFFINITY affinity;
        if (fun2(node, &affinity))                                                 // GetNumaNodeProcessorMaskEx
            fun3(GetCurrentThread(), &affinity, nullptr);                          // SetThreadGroupAffinity
-   } 
-   else 
+   }
+   else
    {
        // If a numa node has more than one processor group, we assume they are
        // sized equal and we spread threads evenly across the groups.