Skip to content

Commit cf4337c

Browse files
committed
Merge with latest Stockfish development branch (last revision: 9988)
1 parent bed1eb5 commit cf4337c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+7111
-7022
lines changed

src/Makefile

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
### ==========================================================================
2121

2222
### Establish the operating system name
23-
KERNEL = $(shell uname -s)
23+
KERNEL := $(shell uname -s)
2424
ifeq ($(KERNEL),Linux)
25-
OS = $(shell uname -o)
25+
OS := $(shell uname -o)
2626
endif
2727

2828
### Target Windows OS
@@ -33,7 +33,7 @@ ifeq ($(OS),Windows_NT)
3333
else ifeq ($(COMP),mingw)
3434
target_windows = yes
3535
ifeq ($(WINE_PATH),)
36-
WINE_PATH = $(shell which wine)
36+
WINE_PATH := $(shell which wine)
3737
endif
3838
endif
3939

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

65+
#HEADERS = benchmark.h bitboard.h evaluate.h misc.h movegen.h movepick.h \
66+
# nnue/evaluate_nnue.h nnue/features/half_ka_v2_hm.h nnue/layers/affine_transform.h \
67+
# nnue/layers/affine_transform_sparse_input.h nnue/layers/clipped_relu.h nnue/layers/simd.h \
68+
# nnue/layers/sqr_clipped_relu.h nnue/nnue_accumulator.h nnue/nnue_architecture.h \
69+
# nnue/nnue_common.h nnue/nnue_feature_transformer.h position.h \
70+
# search.h syzygy/tbprobe.h thread.h thread_win32_osx.h timeman.h \
71+
# tt.h tune.h types.h uci.h
72+
6573
OBJS = $(notdir $(SRCS:.cpp=.o))
6674

6775
VPATH = syzygy:nnue:nnue/features:book:book/polyglot:book/ctg
@@ -113,7 +121,7 @@ VPATH = syzygy:nnue:nnue/features:book:book/polyglot:book/ctg
113121
#endif
114122

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

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

161+
ifneq ($(shell which clang-format-17 2> /dev/null),)
162+
CLANG-FORMAT = clang-format-17
163+
else
164+
CLANG-FORMAT = clang-format
165+
endif
166+
153167
### 2.2 Architecture specific
154168

155169
ifeq ($(findstring x86,$(ARCH)),x86)
@@ -533,8 +547,8 @@ endif
533547

534548
### Sometimes gcc is really clang
535549
ifeq ($(COMP),gcc)
536-
gccversion = $(shell $(CXX) --version 2>/dev/null)
537-
gccisclang = $(findstring clang,$(gccversion))
550+
gccversion := $(shell $(CXX) --version 2>/dev/null)
551+
gccisclang := $(findstring clang,$(gccversion))
538552
ifneq ($(gccisclang),)
539553
profile_make = clang-profile-make
540554
profile_use = clang-profile-use
@@ -592,7 +606,7 @@ ifeq ($(optimize),yes)
592606
endif
593607

594608
ifeq ($(comp),clang)
595-
clangmajorversion = $(shell $(CXX) -dumpversion 2>/dev/null | cut -f1 -d.)
609+
clangmajorversion := $(shell $(CXX) -dumpversion 2>/dev/null | cut -f1 -d.)
596610
ifeq ($(shell expr $(clangmajorversion) \< 16),1)
597611
CXXFLAGS += -fexperimental-new-pass-manager
598612
endif
@@ -708,13 +722,13 @@ ifeq ($(pext),yes)
708722
endif
709723

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

716730
### 3.8.2 Try to include git commit date for versioning
717-
GIT_DATE = $(shell git show -s --date=format:'%Y%m%d' --format=%cd HEAD 2>/dev/null)
731+
GIT_DATE := $(shell git show -s --date=format:'%Y%m%d' --format=%cd HEAD 2>/dev/null)
718732
ifneq ($(GIT_DATE), )
719733
CXXFLAGS += -DGIT_DATE=$(GIT_DATE)
720734
endif
@@ -845,7 +859,8 @@ endif
845859
objclean profileclean config-sanity \
846860
icx-profile-use icx-profile-make \
847861
gcc-profile-use gcc-profile-make \
848-
clang-profile-use clang-profile-make FORCE
862+
clang-profile-use clang-profile-make FORCE \
863+
format analyze
849864

850865
analyze: net config-sanity objclean
851866
$(MAKE) -k ARCH=$(ARCH) COMP=$(COMP) $(OBJS)
@@ -940,6 +955,9 @@ net: netvariables
940955
fi; \
941956
fi; \
942957

958+
format:
959+
$(CLANG-FORMAT) -i $(SRCS) $(HEADERS) -style=file
960+
943961
# default target
944962
default:
945963
help

src/benchmark.cpp

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
namespace {
2929

30+
// clang-format off
3031
const std::vector<std::string> Defaults = {
3132
"setoption name UCI_Chess960 value false",
3233
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
@@ -90,12 +91,13 @@ const std::vector<std::string> Defaults = {
9091
"nqbnrkrb/pppppppp/8/8/8/8/PPPPPPPP/NQBNRKRB w KQkq - 0 1",
9192
"setoption name UCI_Chess960 value false"
9293
};
94+
// clang-format on
9395

94-
} // namespace
96+
} // namespace
9597

9698
namespace Polyfish {
9799

98-
// setup_bench() builds a list of UCI commands to be run by bench. There
100+
// Builds a list of UCI commands to be run by bench. There
99101
// are five parameters: TT size in MB, number of search threads that
100102
// should be used, the limit value spent for each position, a file name
101103
// where to look for positions in FEN format, and the type of the limit:
@@ -106,59 +108,58 @@ namespace Polyfish {
106108
// bench 64 1 100000 default nodes : search default positions for 100K nodes each
107109
// bench 64 4 5000 current movetime : search current position with 4 threads for 5 sec
108110
// bench 16 1 5 blah perft : run a perft 5 on positions in file "blah"
109-
110111
std::vector<std::string> setup_bench(const Position& current, std::istream& is) {
111112

112-
std::vector<std::string> fens, list;
113-
std::string go, token;
113+
std::vector<std::string> fens, list;
114+
std::string go, token;
114115

115-
// Assign default values to missing arguments
116-
std::string ttSize = (is >> token) ? token : "16";
117-
std::string threads = (is >> token) ? token : "1";
118-
std::string limit = (is >> token) ? token : "13";
119-
std::string fenFile = (is >> token) ? token : "default";
120-
std::string limitType = (is >> token) ? token : "depth";
116+
// Assign default values to missing arguments
117+
std::string ttSize = (is >> token) ? token : "16";
118+
std::string threads = (is >> token) ? token : "1";
119+
std::string limit = (is >> token) ? token : "13";
120+
std::string fenFile = (is >> token) ? token : "default";
121+
std::string limitType = (is >> token) ? token : "depth";
121122

122-
go = limitType == "eval" ? "eval" : "go " + limitType + " " + limit;
123+
go = limitType == "eval" ? "eval" : "go " + limitType + " " + limit;
123124

124-
if (fenFile == "default")
125-
fens = Defaults;
125+
if (fenFile == "default")
126+
fens = Defaults;
126127

127-
else if (fenFile == "current")
128-
fens.push_back(current.fen());
128+
else if (fenFile == "current")
129+
fens.push_back(current.fen());
129130

130-
else
131-
{
132-
std::string fen;
133-
std::ifstream file(fenFile);
131+
else
132+
{
133+
std::string fen;
134+
std::ifstream file(fenFile);
134135

135-
if (!file.is_open())
136-
{
137-
std::cerr << "Unable to open file " << fenFile << std::endl;
138-
exit(EXIT_FAILURE);
139-
}
136+
if (!file.is_open())
137+
{
138+
std::cerr << "Unable to open file " << fenFile << std::endl;
139+
exit(EXIT_FAILURE);
140+
}
140141

141-
while (getline(file, fen))
142-
if (!fen.empty())
143-
fens.push_back(fen);
142+
while (getline(file, fen))
143+
if (!fen.empty())
144+
fens.push_back(fen);
144145

145-
file.close();
146-
}
146+
file.close();
147+
}
147148

148-
list.emplace_back("setoption name Threads value " + threads);
149-
list.emplace_back("setoption name Hash value " + ttSize);
150-
list.emplace_back("ucinewgame");
149+
list.emplace_back("setoption name Threads value " + threads);
150+
list.emplace_back("setoption name Hash value " + ttSize);
151+
list.emplace_back("ucinewgame");
151152

152-
for (const std::string& fen : fens)
153-
if (fen.find("setoption") != std::string::npos)
154-
list.emplace_back(fen);
155-
else
156-
{
157-
list.emplace_back("position fen " + fen);
158-
list.emplace_back(go);
159-
}
153+
for (const std::string& fen : fens)
154+
if (fen.find("setoption") != std::string::npos)
155+
list.emplace_back(fen);
156+
else
157+
{
158+
list.emplace_back("position fen " + fen);
159+
list.emplace_back(go);
160+
}
160161

161-
return list;
162+
return list;
162163
}
163164

164-
} // namespace Polyfish
165+
} // namespace Polyfish

src/benchmark.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ class Position;
2929

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

32-
} // namespace Polyfish
32+
} // namespace Polyfish
3333

34-
#endif // #ifndef BENCHMARK_H_INCLUDED
34+
#endif // #ifndef BENCHMARK_H_INCLUDED

0 commit comments

Comments
 (0)