Skip to content

Commit bcb43da

Browse files
committed
Allow to specify different neural net with stockfish
Closes #55
1 parent 39028da commit bcb43da

File tree

4 files changed

+96
-28
lines changed

4 files changed

+96
-28
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ A typical result (Rock 5B with Ubuntu Focal) will look like this:
121121

122122
Stockfish (open source chess engine) also makes heavy use of SIMD extensions but is heavy on memory access too putting even more load on devices than cpuminer which doesn't access RAM that much or at all since working set fits inside CPU caches.
123123

124-
As with cpuminer this test is optional (`sbc-bench -s` or `MODE=extensive` needed) since not representing any broader use case but being more of a stressor / load generator exposing thermal and stability issues. Consumption figures are higher compared to cpuminer since stockfish also stresses the DRAM interface and at least it's sufficient to expose a reliability issue with Rock 5B (most probably RK3588 in general) since running this benchmark [reliably freezes Rock 5B at 2112 MHz DRAM clock](https://github.com/ThomasKaiser/sbc-bench/issues/55).
124+
As with cpuminer this test is optional (`sbc-bench -s` or `MODE=extensive` needed) since not representing any broader use case but being more of a stressor / load generator exposing thermal and stability issues. Consumption figures are higher compared to cpuminer since stockfish also stresses the DRAM interface and at least it's sufficient to expose a reliability issue with Rock 5B (most probably today RK3588 in general) since running this benchmark [reliably freezes Rock 5B at 2112 MHz DRAM clock](https://github.com/ThomasKaiser/sbc-bench/issues/55).
125125

126126
### [7-zip](https://www.7-cpu.com)
127127

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
opp-table:
2+
100 MHz 731.0 mV
3+
250 MHz 731.0 mV
4+
500 MHz 731.0 mV
5+
667 MHz 731.0 mV
6+
1000 MHz 731.0 mV
7+
1200 MHz 731.0 mV
8+
1398 MHz 761.0 mV
9+
1512 MHz 791.0 mV
10+
1608 MHz 831.0 mV
11+
1704 MHz 861.0 mV
12+
1800 MHz 981.0 mV
13+
14+
opp-table-gpu:
15+
125 MHz 800.0 mV
16+
250 MHz 800.0 mV
17+
286 MHz 800.0 mV
18+
400 MHz 800.0 mV
19+
500 MHz 800.0 mV
20+
667 MHz 800.0 mV
21+
800 MHz 800.0 mV
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
opp-table0:
2-
408 MHz 825.0 mV
3-
600 MHz 825.0 mV
4-
816 MHz 850.0 mV
5-
1008 MHz 925.0 mV
6-
1200 MHz 1000.0 mV
7-
1416 MHz 1125.0 mV
2+
408 MHz 825.0 mV
3+
600 MHz 825.0 mV
4+
816 MHz 850.0 mV
5+
1008 MHz 925.0 mV
6+
1200 MHz 1000.0 mV
7+
1416 MHz 1125.0 mV
88

99
opp-table1:
10-
408 MHz 825.0 mV
11-
600 MHz 825.0 mV
12-
816 MHz 825.0 mV
13-
1008 MHz 875.0 mV
14-
1200 MHz 950.0 mV
15-
1416 MHz 1025.0 mV
16-
1608 MHz 1100.0 mV
17-
1800 MHz 1200.0 mV
10+
408 MHz 825.0 mV
11+
600 MHz 825.0 mV
12+
816 MHz 825.0 mV
13+
1008 MHz 875.0 mV
14+
1200 MHz 950.0 mV
15+
1416 MHz 1025.0 mV
16+
1608 MHz 1100.0 mV
17+
1800 MHz 1200.0 mV
1818

1919
opp-table2:
20-
200 MHz 825.0 mV
21-
297 MHz 825.0 mV
22-
400 MHz 825.0 mV
23-
500 MHz 875.0 mV
24-
600 MHz 925.0 mV
25-
800 MHz 1100.0 mV
20+
200 MHz 825.0 mV
21+
297 MHz 825.0 mV
22+
400 MHz 825.0 mV
23+
500 MHz 875.0 mV
24+
600 MHz 925.0 mV
25+
800 MHz 1100.0 mV

sbc-bench.sh

+54-7
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Main() {
5353
;;
5454
s)
5555
# Run Stockfish test (NEON/SSE/AVX/RAM)
56+
NeuralNetwork=$2
5657
ExecuteStockfish=yes
5758
;;
5859
h)
@@ -2082,7 +2083,7 @@ InstallPrerequisits() {
20822083

20832084
# if called with -s or with MODE=extensive we also use stockfish
20842085
if [ "${ExecuteStockfish}" = "yes" -o "X${MODE}" = "Xextensive" ]; then
2085-
InstallStockfish
2086+
InstallStockfish && DownloadNeuralNet
20862087
fi
20872088

20882089
# if called with -c or as 'sbc-bench neon' or with MODE=extensive we also use cpuminer
@@ -2123,7 +2124,6 @@ InstallStockfish() {
21232124
wget -q -O "${InstallLocation}/sf_15.tar.gz" https://github.com/official-stockfish/Stockfish/archive/refs/tags/sf_15.tar.gz 2>/dev/null
21242125
[ -f "${InstallLocation}/sf_15.tar.gz" ] && tar xf sf_15.tar.gz
21252126
[ -d "${InstallLocation}/Stockfish-sf_15/src" ] && cd "${InstallLocation}/Stockfish-sf_15/src" || return
2126-
wget -q -O nn-6877cd24400e.nnue https://tests.stockfishchess.org/api/nn/nn-6877cd24400e.nnue 2>/dev/null
21272127

21282128
case ${CPUArchitecture} in
21292129
x86_64)
@@ -2171,12 +2171,59 @@ InstallStockfish() {
21712171

21722172
if [ ! -x "${InstallLocation}/Stockfish-sf_15/src/stockfish" ]; then
21732173
echo -e "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08 (can't build stockfish) \c"
2174+
return 1
2175+
else
2176+
[ -f "${InstallLocation}/sf_15.tar.gz" ] && rm "${InstallLocation}/sf_15.tar.gz"
21742177
fi
2175-
2176-
[ -f "${InstallLocation}/sf_15.tar.gz" ] && rm "${InstallLocation}/sf_15.tar.gz"
21772178
fi
21782179
} # InstallStockfish
21792180

2181+
DownloadNeuralNet() {
2182+
if [ -d "${InstallLocation}/Stockfish-sf_15/src" ]; then
2183+
cd "${InstallLocation}/Stockfish-sf_15/src" || return 1
2184+
case ${NeuralNetwork} in
2185+
????????????)
2186+
# prefix with nn- and suffix with .nnue
2187+
NeuralNetwork="nn-${NeuralNetwork}.nnue"
2188+
;;
2189+
????????????.nnue)
2190+
# prefix with nn-
2191+
NeuralNetwork="nn-${NeuralNetwork}"
2192+
;;
2193+
nn-????????????)
2194+
# suffix with .nnue
2195+
NeuralNetwork="${NeuralNetwork}.nnue"
2196+
;;
2197+
nn-????????????.nnue)
2198+
# name fits already
2199+
:
2200+
;;
2201+
*)
2202+
# use default net
2203+
FallbackNotification=" (fallback default net)"
2204+
NeuralNetwork="nn-6877cd24400e.nnue"
2205+
;;
2206+
esac
2207+
2208+
# download neural network if missing
2209+
if [ ! -f "${NeuralNetwork}" ]; then
2210+
echo -e "\x08\x08\x08, stockfish NN...\c"
2211+
wget -q -O "${NeuralNetwork}" "https://tests.stockfishchess.org/api/nn/${NeuralNetwork}" 2>/dev/null
2212+
fi
2213+
2214+
# check neural network
2215+
if [ -f "${NeuralNetwork}" ]; then
2216+
NetHeader="$(od <"${NeuralNetwork}" | head -n1 | cut -c9-28)"
2217+
if [ "X${NetHeader}" != "X027440 075363 027362" ]; then
2218+
echo -e "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08 (can't use ${NeuralNetwork}${FallbackNotification}) \c"
2219+
return
2220+
fi
2221+
else
2222+
echo -e "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08 (can't download ${NeuralNetwork}${FallbackNotification}) \c"
2223+
fi
2224+
fi
2225+
} # DownloadNeuralNet
2226+
21802227
InitialMonitoring() {
21812228
# record start time
21822229
BenchmarkStartTime=$(date +"%s")
@@ -2884,14 +2931,14 @@ RunStockfishBenchmark() {
28842931
cd "${InstallLocation}/Stockfish-sf_15/src"
28852932
echo "" >${TempLog}
28862933
for ((i=1;i<=RunHowManyTimes;i++)); do
2887-
./stockfish bench 128 ${CPUCores} 24 default depth >/dev/null 2>>${TempLog}
2934+
echo -e "setoption name EvalFile value ${NeuralNetwork} \n bench 128 8 24 default depth" | ./stockfish 2>>${TempLog} >/dev/null
28882935
done
28892936
kill ${MonitoringPID}
28902937
echo -e "\n##########################################################################\n" >>${ResultLog}
2891-
echo -e "Executing Stockfish 15 using nn-6877cd24400e.nnue ${RunHowManyTimes} times in a row:\n" >>${ResultLog}
2938+
echo -e "Executing Stockfish 15 using ${NeuralNetwork} ${RunHowManyTimes} times in a row:\n" >>${ResultLog}
28922939
sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" <${TempLog} | sed -e '/^$/d' -e '/^============/i \ ' -e '/second/a \ ' >>${ResultLog}
28932940
StockfishScores="$(awk -F": " '/^Nodes\/second/ {print $2}' <${TempLog} | tr '\n' ', ' | sed 's/,$//')"
2894-
echo -e "Total Scores: ${StockfishScores}" >>${ResultLog}
2941+
echo -e "Total Scores (${NeuralNetwork}): ${StockfishScores}" >>${ResultLog}
28952942
} # RunStockfishBenchmark
28962943

28972944
RunPTS() {

0 commit comments

Comments
 (0)