igneum/proto-cuda/nvrtc/fetch-redist.sh
igneum-labs f535abb59d One-click CUDA worker: driver API + NVRTC loaded at run time, pack read at run time, Mac emulation check
proto-cuda/nvrtc/worker.cpp serves igneum-miner's worker protocol with nothing installed but the NVIDIA driver:
nvcuda.dll and the redistributable nvrtc64_120_0.dll are opened with LoadLibrary (cuda_api.h), the pack's kernel.cu
and kernel_bound.cu are handed to NVRTC byte for byte up to the host launch wrappers with program.h and memhard.h as
named headers, every pack is self-tested against its vectors.h (cache head, last line, FNV-1a 64, dataset head, last
word, 64 samples, 96 vector lanes) before it serves a job, prepare runs on a thread for the hourly swap, and a job on
seeds without a pair makes the worker find the miner's pack by seeds.txt and build it. packfile.h (C99) reads a pack
directory. fetch-redist.sh verifies and stages the NVIDIA 12.8.93 redistributables and the Khronos headers
(THIRD-PARTY.md records URLs, hashes and the EULA clause); build-windows.sh cross-compiles with mingw (static,
KERNEL32 + Universal CRT only). emu/: the two libraries as host functions, the pack kernels on host threads, the NVRTC
source compared with the pack files; test.sh PASS on the Mac (two real packs, swap, self-heal, 17 sampled hashes equal
igneum-pow hash-bound). Not run here: the real NVRTC compile and driver load (RTX 5090 PC).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-04 09:55:05 +00:00

52 lines
3.2 KiB
Bash
Executable file

#!/usr/bin/env bash
# Fetches the third-party pieces the one-click workers are built and packaged with, verifies them, and stages them
# under proto-cuda/nvrtc/redist/ (gitignored). Nothing third-party is committed. THIRD-PARTY.md records every file.
# NVIDIA cuda_nvrtc 12.8.93 (Windows x86_64): nvrtc64_120_0.dll and nvrtc-builtins64_128.dll (shipped), nvrtc.h (build), LICENSE
# NVIDIA cuda_cudart 12.8.90 (Windows x86_64): cuda.h (build only, the driver API header; not shipped)
# Khronos OpenCL-Headers v2026.05.29: CL/cl.h, cl_platform.h, cl_version.h, cl_ext.h (build only), LICENSE (Apache 2.0)
# The archives are cached in ~/.cache/igneum/ (the nvrtc archive is 305 MB). Usage: fetch-redist.sh
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
OUT="$HERE/redist"
CACHE="${IGNEUM_REDIST_CACHE:-$HOME/.cache/igneum}"
BASE="https://developer.download.nvidia.com/compute/cuda/redist"
NVRTC_REL="cuda_nvrtc/windows-x86_64/cuda_nvrtc-windows-x86_64-12.8.93-archive.zip"
NVRTC_SHA="a63302a077f0248a743a1a7caa7dbd80d0fac56c6cfa9c41fa05fac9b7e5eda5"
CUDART_REL="cuda_cudart/windows-x86_64/cuda_cudart-windows-x86_64-12.8.90-archive.zip"
CUDART_SHA="4a39058fd8519444a81cfc7ae055d136f48d1a31ffa41ae255b35b2edd61e13b"
KHR_TAG="v2026.05.29"
KHR_BASE="https://raw.githubusercontent.com/KhronosGroup/OpenCL-Headers/$KHR_TAG"
# sha256 of the Khronos files at that tag, recorded 4 October 2026 (file sha256, one per line; bash 3 has no maps)
KHR_FILES="CL/cl.h 16d09614cd7eef73b4094089cc4ce2af777181d3ffe9613473fb6d552234a4d1
CL/cl_platform.h b125cece6fe41f2e6690d88b24652c151cb6654da13b42180d69d5bd9ed526d7
CL/cl_version.h 1e571dd68566330dd066cf778e07909a3cabeb2b969c5578c60f14baba7df1af
CL/cl_ext.h fe8916fd98b739cbc47ecab387bee2d258fa939c1bd2e10415c6f8f8b7055968
LICENSE cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30"
sha() { shasum -a 256 "$1" | cut -d' ' -f1; }
fetch() { # url dest sha
if [ ! -f "$2" ] || [ "$(sha "$2")" != "$3" ]; then
echo "downloading $(basename "$2")"
curl -sS -L -m 3600 -o "$2.part" "$1" && mv "$2.part" "$2"
fi
[ "$(sha "$2")" = "$3" ] || { echo "sha256 mismatch for $2" >&2; exit 1; }
}
mkdir -p "$CACHE/cuda-redist" "$CACHE/opencl-headers/CL" "$OUT/include/CL" "$OUT/bin"
fetch "$BASE/$NVRTC_REL" "$CACHE/cuda-redist/$(basename "$NVRTC_REL")" "$NVRTC_SHA"
fetch "$BASE/$CUDART_REL" "$CACHE/cuda-redist/$(basename "$CUDART_REL")" "$CUDART_SHA"
echo "$KHR_FILES" | while read -r f h; do fetch "$KHR_BASE/$f" "$CACHE/opencl-headers/$f" "$h"; done
X="$(mktemp -d)"
unzip -q "$CACHE/cuda-redist/$(basename "$NVRTC_REL")" -d "$X"
unzip -q "$CACHE/cuda-redist/$(basename "$CUDART_REL")" -d "$X"
N="$X/cuda_nvrtc-windows-x86_64-12.8.93-archive"
C="$X/cuda_cudart-windows-x86_64-12.8.90-archive"
cp "$N/bin/nvrtc64_120_0.dll" "$N/bin/nvrtc-builtins64_128.dll" "$OUT/bin/"
cp "$N/include/nvrtc.h" "$C/include/cuda.h" "$OUT/include/"
cp "$N/LICENSE" "$OUT/LICENSE-NVIDIA-CUDA-EULA.txt"
cp "$CACHE"/opencl-headers/CL/*.h "$OUT/include/CL/"
cp "$CACHE/opencl-headers/LICENSE" "$OUT/LICENSE-Khronos-OpenCL-Headers.txt"
rm -rf "$X"
echo "staged in $OUT:"
(cd "$OUT" && find . -type f | sort | while read -r f; do printf ' %10d %s %s\n' "$(stat -f %z "$f")" "$(sha "$f" | cut -c1-16)" "$f"; done)