mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-25 03:26:24 +08:00
Merge remote-tracking branch 'remotes/nodchip/master' into trainer
This commit is contained in:
@@ -107,3 +107,10 @@ script:
|
||||
#
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make clean && make -j2 ARCH=x86-64-modern sanitize=undefined optimize=no debug=yes build > /dev/null && ../tests/instrumented.sh --sanitizer-undefined; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make clean && make -j2 ARCH=x86-64-modern sanitize=thread optimize=no debug=yes build > /dev/null && ../tests/instrumented.sh --sanitizer-thread; fi
|
||||
|
||||
#
|
||||
# NNUE testing / TODO should work with debug=yes as well
|
||||
#
|
||||
- export CXXFLAGS="-O1 -fno-inline"
|
||||
- if [ -x "$(command -v valgrind )" ]; then make clean && LDFLAGS="-lstdc++fs" make -j2 ARCH=x86-64-modern debug=no optimize=no learn > /dev/null && ../tests/instrumented_learn.sh --valgrind; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make clean && LDFLAGS="-lstdc++fs" make -j2 ARCH=x86-64-modern sanitize=undefined optimize=no debug=no learn > /dev/null && ../tests/instrumented_learn.sh --sanitizer-undefined; fi
|
||||
|
||||
@@ -1606,9 +1606,9 @@ namespace Learner
|
||||
namespace sys = std::filesystem;
|
||||
sys::path kif_base_dir(Path::Combine(base_dir, target_dir)); // Origin of enumeration
|
||||
std::for_each(sys::directory_iterator(kif_base_dir), sys::directory_iterator(),
|
||||
[&](const sys::path& p) {
|
||||
if (sys::is_regular_file(p))
|
||||
filenames.push_back(Path::Combine(target_dir, p.filename().generic_string()));
|
||||
[&](const sys::path& path) {
|
||||
if (sys::is_regular_file(path))
|
||||
filenames.push_back(Path::Combine(target_dir, path.filename().generic_string()));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
126
tests/instrumented_learn.sh
Executable file
126
tests/instrumented_learn.sh
Executable file
@@ -0,0 +1,126 @@
|
||||
#!/bin/bash
|
||||
# check for errors under valgrind or sanitizers.
|
||||
|
||||
error()
|
||||
{
|
||||
echo "instrumented testing failed on line $1"
|
||||
exit 1
|
||||
}
|
||||
trap 'error ${LINENO}' ERR
|
||||
|
||||
# define suitable post and prefixes for testing options
|
||||
case $1 in
|
||||
--valgrind)
|
||||
echo "valgrind testing started"
|
||||
prefix=''
|
||||
exeprefix='valgrind --error-exitcode=42'
|
||||
postfix='1>/dev/null'
|
||||
threads="1"
|
||||
;;
|
||||
--valgrind-thread)
|
||||
echo "valgrind-thread testing started"
|
||||
prefix=''
|
||||
exeprefix='valgrind --error-exitcode=42'
|
||||
postfix='1>/dev/null'
|
||||
threads="2"
|
||||
;;
|
||||
--sanitizer-undefined)
|
||||
echo "sanitizer-undefined testing started"
|
||||
prefix='!'
|
||||
exeprefix=''
|
||||
postfix='2>&1 | grep -A50 "runtime error:"'
|
||||
threads="1"
|
||||
;;
|
||||
--sanitizer-thread)
|
||||
echo "sanitizer-thread testing started"
|
||||
prefix='!'
|
||||
exeprefix=''
|
||||
postfix='2>&1 | grep -A50 "WARNING: ThreadSanitizer:"'
|
||||
threads="2"
|
||||
|
||||
cat << EOF > tsan.supp
|
||||
race:TTEntry::move
|
||||
race:TTEntry::depth
|
||||
race:TTEntry::bound
|
||||
race:TTEntry::save
|
||||
race:TTEntry::value
|
||||
race:TTEntry::eval
|
||||
race:TTEntry::is_pv
|
||||
|
||||
race:TranspositionTable::probe
|
||||
race:TranspositionTable::hashfull
|
||||
|
||||
EOF
|
||||
|
||||
export TSAN_OPTIONS="suppressions=./tsan.supp"
|
||||
|
||||
;;
|
||||
*)
|
||||
echo "unknown testing started"
|
||||
prefix=''
|
||||
exeprefix=''
|
||||
postfix=''
|
||||
threads="1"
|
||||
;;
|
||||
esac
|
||||
|
||||
mkdir -p training_data_01
|
||||
mkdir -p training_data_02
|
||||
|
||||
# gensfen testing 01
|
||||
cat << EOF > gensfen01.exp
|
||||
set timeout 240
|
||||
spawn $exeprefix ./stockfish
|
||||
|
||||
send "uci\n"
|
||||
expect "uciok"
|
||||
|
||||
send "setoption name Threads value $threads\n"
|
||||
send "setoption name Use NNUE value false\n"
|
||||
send "isready\n"
|
||||
send "gensfen depth 3 loop 100 use_draw_in_training_data_generation 1 eval_limit 32000 output_file_name training_data_01/training_data.bin use_raw_nnue_eval 0\n"
|
||||
expect "gensfen finished."
|
||||
|
||||
send "quit\n"
|
||||
expect eof
|
||||
|
||||
# return error code of the spawned program, useful for valgrind
|
||||
lassign [wait] pid spawnid os_error_flag value
|
||||
exit \$value
|
||||
EOF
|
||||
|
||||
# gensfen testing 02
|
||||
cat << EOF > gensfen02.exp
|
||||
set timeout 240
|
||||
spawn $exeprefix ./stockfish
|
||||
|
||||
send "uci\n"
|
||||
expect "uciok"
|
||||
|
||||
send "setoption name Threads value $threads\n"
|
||||
send "setoption name Use NNUE value true\n"
|
||||
send "isready\n"
|
||||
send "gensfen depth 3 loop 100 use_draw_in_training_data_generation 1 eval_limit 32000 output_file_name training_data_02/training_data.bin use_raw_nnue_eval 0\n"
|
||||
expect "gensfen finished."
|
||||
|
||||
send "quit\n"
|
||||
expect eof
|
||||
|
||||
# return error code of the spawned program, useful for valgrind
|
||||
lassign [wait] pid spawnid os_error_flag value
|
||||
exit \$value
|
||||
EOF
|
||||
|
||||
for exp in gensfen01.exp gensfen02.exp
|
||||
do
|
||||
|
||||
echo "$prefix expect $exp $postfix"
|
||||
eval "$prefix expect $exp $postfix"
|
||||
|
||||
rm $exp
|
||||
|
||||
done
|
||||
|
||||
rm -f tsan.supp
|
||||
|
||||
echo "instrumented learn testing OK"
|
||||
Reference in New Issue
Block a user