summaryrefslogtreecommitdiff
path: root/src/eval_tune/run_ecm.sh
blob: a6c12849abeb84e8bbbb836c4aeb56888f9543eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
# Run the ECM tactical suite at a fixed search depth (not fixed time --
# see CLAUDE.md: st introduces machine-load noise that sd avoids) and
# print just the "correct solutions" tally so callers can parse it.
#
# Usage: run_ecm.sh <label> [depth]
# Writes eval_tune/ecm_logs/<label>.log (full Trace() output) and
# appends one line to eval_tune/ecm_history.log.

set -e
cd "$(dirname "$0")/.."   # repo src/ root

label="$1"
depth="${2:-11}"
if [ -z "$label" ]; then
    echo "Usage: $0 <label> [depth]" >&2
    exit 1
fi

mkdir -p eval_tune/ecm_logs
logfile="eval_tune/ecm_logs/${label}.log"

opts='--cpus 1 --hash 256m --egtbpath /zscratch/egtb'
# --batch exits non-zero on normal EOF ("Exhausted input in batch
# mode") -- that's expected, not a failure, so don't let set -e treat
# it as one; the real success/failure check is the grep below.
./typhoon ${opts} --logfile "$logfile" --batch \
    --command "sd ${depth}; script ../tests/ecm.ep_" || true

correct=$(grep -o 'correct solutions   : [0-9]*' "$logfile" | tail -1 | grep -o '[0-9]*$')
total=$(grep -o 'total problems      : [0-9]*' "$logfile" | tail -1 | grep -o '[0-9]*$')

if [ -z "$correct" ] || [ -z "$total" ]; then
    echo "ERROR: couldn't parse solved count from $logfile" >&2
    exit 1
fi

echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) label=$label depth=$depth solved=${correct}/${total}" \
    >> eval_tune/ecm_history.log

echo "${correct} ${total}"