Skip to content

Commit a4be1e4

Browse files
authored
enable gcc pgo build profile (#300)
bench: 1217611
1 parent 5ee05ef commit a4be1e4

File tree

5 files changed

+58
-5
lines changed

5 files changed

+58
-5
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Igel Linux Build PGO
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
branches:
9+
- '**'
10+
workflow_dispatch: # Allow manual triggering of the workflow
11+
12+
jobs:
13+
build:
14+
runs-on: ${{ matrix.os }}
15+
16+
strategy:
17+
matrix:
18+
os: [ ubuntu-latest ]
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v2
23+
24+
- name: Install GCC versions
25+
run: |
26+
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
27+
sudo apt-get update
28+
sudo apt-get install -y gcc-12 g++-12 gcc-13 g++-13
29+
30+
- name: Set GCC version
31+
run: |
32+
# Set GCC 14 as the default version
33+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60
34+
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 60
35+
36+
- name: Build the PGO build
37+
run: cd src&&make pgo
38+
39+
- name: Run the bench
40+
run: cd src&&./igel bench

src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ int main(int argc, const char* argv[])
4646

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

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

src/makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,15 @@ endif
3131

3232
CFLAGS = $(WARN) $(LIBS) $(OPTIM) $(NNFLAGS)
3333

34+
pgo: download-network
35+
$(CC) $(CFLAGS) $(SRC) $(DEFS) -fprofile-generate=pgo -o $(EXE)
36+
./$(EXE) bench 13 > pgo.out 2>&1
37+
$(CC) $(CFLAGS) $(SRC) $(DEFS) -fprofile-use=pgo -o $(EXE)
38+
@rm -rf pgo pgo.out weights
39+
3440
basic:
3541
$(CC) $(CFLAGS) $(SRC) $(DEFS) -o $(EXE)
42+
43+
download-network:
44+
mkdir weights; \
45+
echo "Downloading latest Igel network with wget"; wget -P weights https://github.com/vshcherbyna/igel/releases/download/3.5.0/c049c117;

src/uci.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,13 @@ static const char* benchmarkPositions[] = {
212212
""
213213
};
214214

215-
int Uci::onBench()
215+
int Uci::onBench(const char * depth)
216216
{
217217
std::cout << "Running benchmark" << std::endl;
218218

219+
if (!depth)
220+
depth = "10";
221+
219222
auto & time = Time::instance();
220223

221224
if (!TTable::instance().setHashSize(16, 1)) {
@@ -229,7 +232,7 @@ int Uci::onBench()
229232

230233
uint64_t sumNodes = 0;
231234
auto start = GetProcTime();
232-
commandParams p = { "go", "depth", "10" };
235+
commandParams p = { "go", "depth", depth };
233236

234237
for (auto i = 0; strcmp(benchmarkPositions[i], ""); i++) {
235238
if (!m_searcher.m_position.SetFEN(benchmarkPositions[i]))

src/uci.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Uci
5454

5555
public:
5656
int handleCommands();
57-
int onBench();
57+
int onBench(const char* depth);
5858
static commandParams split(const std::string & s, const std::string & sep = " ");
5959

6060
private:

0 commit comments

Comments
 (0)