Skip to content

Commit

Permalink
Merge with latest Stockfish development branch (last revision: 9988)
Browse files Browse the repository at this point in the history
  • Loading branch information
khalid-a-omar committed Nov 4, 2023
1 parent bed1eb5 commit cf4337c
Show file tree
Hide file tree
Showing 46 changed files with 7,111 additions and 7,022 deletions.
38 changes: 28 additions & 10 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
### ==========================================================================

### Establish the operating system name
KERNEL = $(shell uname -s)
KERNEL := $(shell uname -s)
ifeq ($(KERNEL),Linux)
OS = $(shell uname -o)
OS := $(shell uname -o)
endif

### Target Windows OS
Expand All @@ -33,7 +33,7 @@ ifeq ($(OS),Windows_NT)
else ifeq ($(COMP),mingw)
target_windows = yes
ifeq ($(WINE_PATH),)
WINE_PATH = $(shell which wine)
WINE_PATH := $(shell which wine)
endif
endif

Expand Down Expand Up @@ -62,6 +62,14 @@ SRCS = benchmark.cpp bitboard.cpp evaluate.cpp main.cpp \
nnue/evaluate_nnue.cpp nnue/features/half_ka_v2_hm.cpp \
book/book.cpp book/polyglot/polyglot.cpp book/ctg/ctg.cpp

#HEADERS = benchmark.h bitboard.h evaluate.h misc.h movegen.h movepick.h \
# nnue/evaluate_nnue.h nnue/features/half_ka_v2_hm.h nnue/layers/affine_transform.h \
# nnue/layers/affine_transform_sparse_input.h nnue/layers/clipped_relu.h nnue/layers/simd.h \
# nnue/layers/sqr_clipped_relu.h nnue/nnue_accumulator.h nnue/nnue_architecture.h \
# nnue/nnue_common.h nnue/nnue_feature_transformer.h position.h \
# search.h syzygy/tbprobe.h thread.h thread_win32_osx.h timeman.h \
# tt.h tune.h types.h uci.h

OBJS = $(notdir $(SRCS:.cpp=.o))

VPATH = syzygy:nnue:nnue/features:book:book/polyglot:book/ctg
Expand Down Expand Up @@ -113,7 +121,7 @@ VPATH = syzygy:nnue:nnue/features:book:book/polyglot:book/ctg
#endif

#ifeq ($(ARCH), native)
# override ARCH = $(shell $(SHELL) ../scripts/get_native_properties.sh | cut -d " " -f 1)
# override ARCH := $(shell $(SHELL) ../scripts/get_native_properties.sh | cut -d " " -f 1)
#endif

# explicitly check for the list of supported architectures (as listed with make help),
Expand Down Expand Up @@ -150,6 +158,12 @@ dotprod = no
arm_version = 0
STRIP = strip

ifneq ($(shell which clang-format-17 2> /dev/null),)
CLANG-FORMAT = clang-format-17
else
CLANG-FORMAT = clang-format
endif

### 2.2 Architecture specific

ifeq ($(findstring x86,$(ARCH)),x86)
Expand Down Expand Up @@ -533,8 +547,8 @@ endif

### Sometimes gcc is really clang
ifeq ($(COMP),gcc)
gccversion = $(shell $(CXX) --version 2>/dev/null)
gccisclang = $(findstring clang,$(gccversion))
gccversion := $(shell $(CXX) --version 2>/dev/null)
gccisclang := $(findstring clang,$(gccversion))
ifneq ($(gccisclang),)
profile_make = clang-profile-make
profile_use = clang-profile-use
Expand Down Expand Up @@ -592,7 +606,7 @@ ifeq ($(optimize),yes)
endif

ifeq ($(comp),clang)
clangmajorversion = $(shell $(CXX) -dumpversion 2>/dev/null | cut -f1 -d.)
clangmajorversion := $(shell $(CXX) -dumpversion 2>/dev/null | cut -f1 -d.)
ifeq ($(shell expr $(clangmajorversion) \< 16),1)
CXXFLAGS += -fexperimental-new-pass-manager
endif
Expand Down Expand Up @@ -708,13 +722,13 @@ ifeq ($(pext),yes)
endif

### 3.8.1 Try to include git commit sha for versioning
GIT_SHA = $(shell git rev-parse HEAD 2>/dev/null | cut -c 1-8)
GIT_SHA := $(shell git rev-parse HEAD 2>/dev/null | cut -c 1-8)
ifneq ($(GIT_SHA), )
CXXFLAGS += -DGIT_SHA=$(GIT_SHA)
endif

### 3.8.2 Try to include git commit date for versioning
GIT_DATE = $(shell git show -s --date=format:'%Y%m%d' --format=%cd HEAD 2>/dev/null)
GIT_DATE := $(shell git show -s --date=format:'%Y%m%d' --format=%cd HEAD 2>/dev/null)
ifneq ($(GIT_DATE), )
CXXFLAGS += -DGIT_DATE=$(GIT_DATE)
endif
Expand Down Expand Up @@ -845,7 +859,8 @@ endif
objclean profileclean config-sanity \
icx-profile-use icx-profile-make \
gcc-profile-use gcc-profile-make \
clang-profile-use clang-profile-make FORCE
clang-profile-use clang-profile-make FORCE \
format analyze

analyze: net config-sanity objclean
$(MAKE) -k ARCH=$(ARCH) COMP=$(COMP) $(OBJS)
Expand Down Expand Up @@ -940,6 +955,9 @@ net: netvariables
fi; \
fi; \

format:
$(CLANG-FORMAT) -i $(SRCS) $(HEADERS) -style=file

# default target
default:
help
Expand Down
87 changes: 44 additions & 43 deletions src/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

namespace {

// clang-format off
const std::vector<std::string> Defaults = {
"setoption name UCI_Chess960 value false",
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
Expand Down Expand Up @@ -90,12 +91,13 @@ const std::vector<std::string> Defaults = {
"nqbnrkrb/pppppppp/8/8/8/8/PPPPPPPP/NQBNRKRB w KQkq - 0 1",
"setoption name UCI_Chess960 value false"
};
// clang-format on

} // namespace
} // namespace

namespace Polyfish {

// setup_bench() builds a list of UCI commands to be run by bench. There
// Builds a list of UCI commands to be run by bench. There
// are five parameters: TT size in MB, number of search threads that
// should be used, the limit value spent for each position, a file name
// where to look for positions in FEN format, and the type of the limit:
Expand All @@ -106,59 +108,58 @@ namespace Polyfish {
// bench 64 1 100000 default nodes : search default positions for 100K nodes each
// bench 64 4 5000 current movetime : search current position with 4 threads for 5 sec
// bench 16 1 5 blah perft : run a perft 5 on positions in file "blah"

std::vector<std::string> setup_bench(const Position& current, std::istream& is) {

std::vector<std::string> fens, list;
std::string go, token;
std::vector<std::string> fens, list;
std::string go, token;

// Assign default values to missing arguments
std::string ttSize = (is >> token) ? token : "16";
std::string threads = (is >> token) ? token : "1";
std::string limit = (is >> token) ? token : "13";
std::string fenFile = (is >> token) ? token : "default";
std::string limitType = (is >> token) ? token : "depth";
// Assign default values to missing arguments
std::string ttSize = (is >> token) ? token : "16";
std::string threads = (is >> token) ? token : "1";
std::string limit = (is >> token) ? token : "13";
std::string fenFile = (is >> token) ? token : "default";
std::string limitType = (is >> token) ? token : "depth";

go = limitType == "eval" ? "eval" : "go " + limitType + " " + limit;
go = limitType == "eval" ? "eval" : "go " + limitType + " " + limit;

if (fenFile == "default")
fens = Defaults;
if (fenFile == "default")
fens = Defaults;

else if (fenFile == "current")
fens.push_back(current.fen());
else if (fenFile == "current")
fens.push_back(current.fen());

else
{
std::string fen;
std::ifstream file(fenFile);
else
{
std::string fen;
std::ifstream file(fenFile);

if (!file.is_open())
{
std::cerr << "Unable to open file " << fenFile << std::endl;
exit(EXIT_FAILURE);
}
if (!file.is_open())
{
std::cerr << "Unable to open file " << fenFile << std::endl;
exit(EXIT_FAILURE);
}

while (getline(file, fen))
if (!fen.empty())
fens.push_back(fen);
while (getline(file, fen))
if (!fen.empty())
fens.push_back(fen);

file.close();
}
file.close();
}

list.emplace_back("setoption name Threads value " + threads);
list.emplace_back("setoption name Hash value " + ttSize);
list.emplace_back("ucinewgame");
list.emplace_back("setoption name Threads value " + threads);
list.emplace_back("setoption name Hash value " + ttSize);
list.emplace_back("ucinewgame");

for (const std::string& fen : fens)
if (fen.find("setoption") != std::string::npos)
list.emplace_back(fen);
else
{
list.emplace_back("position fen " + fen);
list.emplace_back(go);
}
for (const std::string& fen : fens)
if (fen.find("setoption") != std::string::npos)
list.emplace_back(fen);
else
{
list.emplace_back("position fen " + fen);
list.emplace_back(go);
}

return list;
return list;
}

} // namespace Polyfish
} // namespace Polyfish
4 changes: 2 additions & 2 deletions src/benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ class Position;

std::vector<std::string> setup_bench(const Position&, std::istream&);

} // namespace Polyfish
} // namespace Polyfish

#endif // #ifndef BENCHMARK_H_INCLUDED
#endif // #ifndef BENCHMARK_H_INCLUDED
Loading

0 comments on commit cf4337c

Please sign in to comment.