igneum/tools/intel-arc/make-trace-kit.sh
igneum-labs 31827c3586 The register-trace bisect for the Arc B580: igneum_hash_trace by make-trace-pack.py, host.c --trace, igneum-pow trace-regs (interpret_warp_trace), the kit and the PC 1 diff job
Every instruction family of the live hash is bit-exact on Intel's compiler (the family probe, runs a and b) and the hash
is wrong on every lane in both exchange modes: the trace of lane 0's registers after every instruction, GPU against
the CPU interpreter, names the first diverging instruction.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-07 11:12:49 +00:00

36 lines
2.6 KiB
Bash

#!/usr/bin/env bash
# The register-trace kit for tools/intel-arc/pc1-arc-trace.ps1 (7 October 2026, the Arc B580 bisect, docs/plans/intel-arc.md
# section 7): the OpenCL worker from THIS tree's proto-opencl/host.c (with --trace; cross-compiled with mingw exactly as
# tools/ca3-pc1-amd/make-kit.sh does, OpenCL.dll at run time), the trace pack made from proto-cuda/packs-ca3-v4/v4-devnet-epoch0
# by make-trace-pack.py (igneum_hash_trace appended, trace_steps.txt beside), the CPU trace of the same pack from
# igneum-pow's `trace-regs` (made on the build box; passed in as the first argument), the sources and SHA256SUMS.
# tools/intel-arc/make-trace-kit.sh <cpu-trace.txt> [out.zip] default $TMPDIR/igneum-ia-trace-kit.zip
# Needs x86_64-w64-mingw32-gcc and the Khronos OpenCL headers at $IGNEUM_REDIST/include (the ca2-mixer worktree holds a
# copy: IGNEUM_REDIST=/Users/joshm/Projects/igneum-wt-ca2-mixer/proto-cuda/nvrtc/redist).
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(cd "$HERE/../.." && pwd)"
CPU="${1:?cpu-trace.txt from igneum-pow trace-regs}"
OUT="${2:-${TMPDIR:-/tmp}/igneum-ia-trace-kit.zip}"
RED="${IGNEUM_REDIST:-$ROOT/proto-cuda/nvrtc/redist}"
[ -f "$RED/include/CL/cl.h" ] || { echo "no OpenCL headers at $RED/include/CL/cl.h (set IGNEUM_REDIST)" >&2; exit 1; }
[ -s "$CPU" ] || { echo "no CPU trace at $CPU" >&2; exit 1; }
CC=x86_64-w64-mingw32-gcc; STRIP=x86_64-w64-mingw32-strip
command -v "$CC" >/dev/null || { echo "$CC not found (brew install mingw-w64)" >&2; exit 1; }
PLACEHOLDER="$ROOT/proto-cuda/packs/igneum-devnet-v4-epoch0"
STAGE="$(mktemp -d)"
mkdir -p "$STAGE/bin" "$STAGE/src" "$STAGE/packs"
echo "== igneum-worker-opencl.exe (kit build of proto-opencl/host.c with --trace)"
"$CC" -std=c99 -O2 -Wall -Wextra -Wno-stringop-truncation -Wno-format-truncation -static -DIGNEUM_CL_DYNAMIC -DCL_TARGET_OPENCL_VERSION=120 \
-I "$RED/include" -I "$PLACEHOLDER" -DIGNEUM_KERNEL_PATH='"kernel_bound.cl"' -o "$STAGE/bin/igneum-worker-opencl.exe" "$ROOT/proto-opencl/host.c"
"$STRIP" "$STAGE/bin/igneum-worker-opencl.exe"
echo "== the trace pack"
python3 "$HERE/make-trace-pack.py" "$ROOT/proto-cuda/packs-ca3-v4/v4-devnet-epoch0" "$STAGE/packs/v4-trace"
cp "$CPU" "$STAGE/cpu-trace.txt"
cp "$ROOT/proto-opencl/host.c" "$ROOT/proto-opencl/cl_dynamic.h" "$HERE/make-trace-pack.py" "$STAGE/src/"
( cd "$STAGE" && find . -type f ! -name SHA256SUMS | sort | xargs shasum -a 256 > SHA256SUMS )
rm -f "$OUT"
( cd "$STAGE" && zip -X -q -r "$OUT" . )
rm -rf "$STAGE"
echo "kit $OUT"
echo "sha256 $(shasum -a 256 "$OUT" | cut -c1-64) bytes $(wc -c < "$OUT" | tr -d ' ')"