igneum/tools/ca3-pc1-amd/make-kit.sh

43 lines
3.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# Builds the PC 1 AMD kit for the Counter ASIC 3.0 jobs in this folder (6 October 2026): the OpenCL worker from
# THIS tree's proto-opencl/host.c (the installed worker's source plus the `build <ms> clBuildProgram` line), the
# OpenCL family probe (proto-opencl/family-probe.c), both cross-compiled with mingw exactly as
# proto-cuda/nvrtc/build-windows.sh builds the shipped worker (static, IGNEUM_CL_DYNAMIC, OpenCL.dll at run time;
# no icon or version block: this is a bench kit, not a shipped exe), the eight packs the four jobs read, the two
# sources for the sha256 record, and SHA256SUMS. Prints the zip's sha256 and size: the README's publish line takes it.
# tools/ca3-pc1-amd/make-kit.sh [out.zip] default $TMPDIR/igneum-ca3-pc1-amd-kit.zip
# Needs x86_64-w64-mingw32-gcc (brew install mingw-w64) and the Khronos OpenCL headers at $IGNEUM_REDIST/include
# (default proto-cuda/nvrtc/redist, written by proto-cuda/nvrtc/fetch-redist.sh; the ca2-mixer worktree holds a copy:
# IGNEUM_REDIST=/Users/joshm/Projects/igneum-wt-ca2-mixer/proto-cuda/nvrtc/redist). Nothing third-party is committed.
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(cd "$HERE/../.." && pwd)"
OUT="${1:-${TMPDIR:-/tmp}/igneum-ca3-pc1-amd-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 (run proto-cuda/nvrtc/fetch-redist.sh or set IGNEUM_REDIST)" >&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" # the memory-hard placeholder build-windows.sh uses; --bench-pack reads the real pack at run time
STAGE="$(mktemp -d)"
mkdir -p "$STAGE/bin" "$STAGE/src" "$STAGE/packs"
echo "== igneum-worker-opencl.exe (kit build of proto-opencl/host.c)"
"$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 "== family-probe-cl.exe (proto-opencl/family-probe.c)"
"$CC" -std=c99 -O2 -Wall -Wextra -static -DIGNEUM_CL_DYNAMIC -DCL_TARGET_OPENCL_VERSION=120 -I "$RED/include" -o "$STAGE/bin/family-probe-cl.exe" "$ROOT/proto-opencl/family-probe.c"
"$STRIP" "$STAGE/bin/family-probe-cl.exe"
cp "$ROOT/proto-opencl/host.c" "$ROOT/proto-opencl/family-probe.c" "$ROOT/proto-opencl/cl_dynamic.h" "$STAGE/src/"
for p in packs-ca2-mixer/mx8-devnet-epoch0 packs-ca3-shadow/sh256x13 packs-ca3-shadow/sh256x27 packs-ca3-shadow/sh256x53 packs-ca3-shadow/sh256x88 packs-ca3-shadow/sh64x52 packs-ca3-derive/dr736-genesis packs-ca3-derive/dr736-devnet-epoch0; do
name="$(basename "$p")"
[ -f "$ROOT/proto-cuda/$p/kernel_bound.cl" ] || { echo "pack $p has no kernel_bound.cl" >&2; exit 1; }
mkdir -p "$STAGE/packs/$name"
cp "$ROOT/proto-cuda/$p"/* "$STAGE/packs/$name/"
done
( 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 ' ')"
unzip -l "$OUT" | tail -1