diff --git a/src/Makefile b/src/Makefile index cb86b5c6..33fc2c00 100644 --- a/src/Makefile +++ b/src/Makefile @@ -96,6 +96,7 @@ bits = 32 prefetch = no popcnt = no sse = no +avx2 = no pext = no ### 2.2 Architecture specific @@ -134,12 +135,22 @@ ifeq ($(ARCH),x86-64-modern) sse = yes endif +ifeq ($(ARCH),x86-64-avx2) + arch = x86_64 + bits = 64 + prefetch = yes + popcnt = yes + sse = yes + avx2 = yes +endif + ifeq ($(ARCH),x86-64-bmi2) arch = x86_64 bits = 64 prefetch = yes popcnt = yes sse = yes + avx2 = yes pext = yes endif @@ -336,11 +347,18 @@ endif ### 3.6 popcnt ifeq ($(popcnt),yes) ifeq ($(arch),ppc64) - CXXFLAGS += -DUSE_POPCNT + CXXFLAGS += -DUSE_POPCNT -DUSE_SSE2 else ifeq ($(comp),icc) - CXXFLAGS += -msse3 -DUSE_POPCNT + CXXFLAGS += -msse3 -DUSE_POPCNT -DUSE_SSE2 else - CXXFLAGS += -msse3 -mpopcnt -DUSE_POPCNT + CXXFLAGS += -msse3 -mpopcnt -DUSE_POPCNT -DUSE_SSE2 + endif +endif + +ifeq ($(avx2),yes) + CXXFLAGS += -DUSE_AVX2 + ifeq ($(comp),$(filter $(comp),gcc clang mingw)) + CXXFLAGS += -mavx2 endif endif @@ -348,7 +366,7 @@ endif ifeq ($(pext),yes) CXXFLAGS += -DUSE_PEXT ifeq ($(comp),$(filter $(comp),gcc clang mingw)) - CXXFLAGS += -mbmi2 -mavx2 + CXXFLAGS += -mbmi2 endif endif @@ -400,6 +418,7 @@ help: @echo "Supported archs:" @echo "" @echo "x86-64-bmi2 > x86 64-bit with pext support (also enables SSE4)" + @echo "x86-64-avx2 > x86 64-bit with avx2 support (also enables SSE4)" @echo "x86-64-modern > x86 64-bit with popcnt support (also enables SSE3)" @echo "x86-64 > x86 64-bit generic" @echo "x86-32 > x86 32-bit (also enables SSE)" @@ -495,6 +514,7 @@ config-sanity: @echo "prefetch: '$(prefetch)'" @echo "popcnt: '$(popcnt)'" @echo "sse: '$(sse)'" + @echo "avx2: '$(avx2)'" @echo "pext: '$(pext)'" @echo "" @echo "Flags:" @@ -556,16 +576,16 @@ icc-profile-use: all nnue: config-sanity - $(MAKE) CXXFLAGS='$(CXXFLAGS) -DEVAL_NNUE -DUSE_EVAL_HASH -DUSE_AVX2 -DUSE_SSE2 -DENABLE_TEST_CMD -fopenmp' LDFLAGS='$(LDFLAGS) -fopenmp' build + $(MAKE) CXXFLAGS='$(CXXFLAGS) -DEVAL_NNUE -DUSE_EVAL_HASH -DENABLE_TEST_CMD -fopenmp' LDFLAGS='$(LDFLAGS) -fopenmp' build nnue-gen-sfen-from-original-eval: config-sanity - $(MAKE) CXXFLAGS='$(CXXFLAGS) -DEVAL_LEARN -DUSE_EVAL_HASH -DUSE_AVX2 -DUSE_SSE2 -DENABLE_TEST_CMD -fopenmp' LDFLAGS='$(LDFLAGS) -fopenmp' build + $(MAKE) CXXFLAGS='$(CXXFLAGS) -DEVAL_LEARN -DUSE_EVAL_HASH -DENABLE_TEST_CMD -fopenmp' LDFLAGS='$(LDFLAGS) -fopenmp' build nnue-learn: config-sanity - $(MAKE) CXXFLAGS='$(CXXFLAGS) -DEVAL_LEARN -DEVAL_NNUE -DUSE_EVAL_HASH -DUSE_AVX2 -DUSE_SSE2 -DENABLE_TEST_CMD -fopenmp' LDFLAGS='$(LDFLAGS) -fopenmp' build + $(MAKE) CXXFLAGS='$(CXXFLAGS) -DEVAL_LEARN -DEVAL_NNUE -DUSE_EVAL_HASH -DENABLE_TEST_CMD -fopenmp' LDFLAGS='$(LDFLAGS) -fopenmp' build nnue-learn-use-blas: config-sanity - $(MAKE) CXXFLAGS='$(CXXFLAGS) -DEVAL_LEARN -DEVAL_NNUE -DUSE_EVAL_HASH -DUSE_AVX2 -DUSE_SSE2 -DENABLE_TEST_CMD -DUSE_BLAS -I/mingw64/include/OpenBLAS -fopenmp' LDFLAGS='$(LDFLAGS) -lopenblas -fopenmp' build + $(MAKE) CXXFLAGS='$(CXXFLAGS) -DEVAL_LEARN -DEVAL_NNUE -DUSE_EVAL_HASH -DENABLE_TEST_CMD -DUSE_BLAS -I/mingw64/include/OpenBLAS -fopenmp' LDFLAGS='$(LDFLAGS) -lopenblas -fopenmp' build .depend: -@$(CXX) $(DEPENDFLAGS) -MM $(OBJS:.o=.cpp) > $@ 2> /dev/null diff --git a/src/eval/nnue/nnue_common.h b/src/eval/nnue/nnue_common.h index ac114b75..8ef8fee4 100644 --- a/src/eval/nnue/nnue_common.h +++ b/src/eval/nnue/nnue_common.h @@ -5,6 +5,12 @@ #if defined(EVAL_NNUE) +#if defined(USE_AVX2) +#include +#elif defined(USE_SSE2) +#include +#endif + namespace Eval { namespace NNUE {