Skip to content

Commit c2c6bf9

Browse files
authored
enable clang pgo build profile (#301)
bench: 1217611
1 parent a4be1e4 commit c2c6bf9

File tree

4 files changed

+15
-48
lines changed

4 files changed

+15
-48
lines changed

.github/workflows/build-linux-pgo.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int main(int argc, const char* argv[])
4646

4747
Uci handler(*searcher.get());
4848

49-
if (!strcmp(argv[1], "bench"))
49+
if ((argc > 1) && !strcmp(argv[1], "bench"))
5050
return handler.onBench(argv[2]);
5151
else
5252
return handler.handleCommands();

src/makefile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#
2-
# This makefile is solely designed to compile Igel for OpenBench
3-
# Official build method for Igel still requires cmake
2+
# This makefile is used to compile Igel for OpenBench and TCEC
43
#
54

6-
CC = g++
5+
CC = clang
76
EXE = igel
87
SRC = *.cpp fathom/tbprobe.cpp
98

@@ -12,7 +11,7 @@ GCCDEFINES = $(shell echo | $(CC) -m64 -march=native -E -dM -)
1211
EVALFILE = weights/c049c117
1312
NNFLAGS = -DEVALFILE=\"$(EVALFILE)\"
1413

15-
LIBS = -std=c++17 -mpopcnt -pthread
14+
LIBS = -std=c++20 -mpopcnt -pthread -lstdc++ -lm
1615
WARN = -Wall
1716
OPTIM = -O3 -march=native -flto=auto
1817
DEFS = -DNDEBUG -D_BTYPE=0 -DSYZYGY_SUPPORT=TRUE
@@ -32,10 +31,18 @@ endif
3231
CFLAGS = $(WARN) $(LIBS) $(OPTIM) $(NNFLAGS)
3332

3433
pgo: download-network
34+
ifeq ($(findstring g++, $(CC)), g++)
3535
$(CC) $(CFLAGS) $(SRC) $(DEFS) -fprofile-generate=pgo -o $(EXE)
36-
./$(EXE) bench 13 > pgo.out 2>&1
36+
./$(EXE) bench 14 > pgo.out 2>&1
3737
$(CC) $(CFLAGS) $(SRC) $(DEFS) -fprofile-use=pgo -o $(EXE)
38-
@rm -rf pgo pgo.out weights
38+
@rm -rf pgo pgo.out
39+
else ifeq ($(findstring clang, $(CC)), clang)
40+
$(CC) $(CFLAGS) $(SRC) $(DEFS) -fprofile-instr-generate -o $(EXE)
41+
./$(EXE) bench 14 > pgo.out 2>&1
42+
llvm-profdata merge -output=igel.profdata *.profraw
43+
$(CC) $(CFLAGS) $(SRC) $(DEFS) -fprofile-instr-use=igel.profdata -o $(EXE)
44+
@rm -rf pgo pgo.out igel.profdata *.profraw
45+
endif
3946

4047
basic:
4148
$(CC) $(CFLAGS) $(SRC) $(DEFS) -o $(EXE)

src/uci.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,4 +401,4 @@ void Uci::onGenerate(commandParams params)
401401
{
402402
std::unique_ptr<Generator> generator(new Generator(std::stoi(params[1]), std::stoi(params[2])));
403403
generator->onGenerate();
404-
}
404+
}

0 commit comments

Comments
 (0)