Squashed from six commits (tag ca2-era-pre-squash) for one merge. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
28 lines
2.1 KiB
Bash
Executable file
28 lines
2.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# The host-side dataset derivation of the harnesses under a non-linear item-to-word layout (era layout,
|
|
# docs/plans/era-layout.md 1.2): proto-cuda/host.cu (and proto-opencl/host.c, the same function) derive dataset words
|
|
# on the host through the pack's own mh_word, which carries the layout. Until 5 October 2026 both derived
|
|
# mh_item(w >> 4)[w & 15] and the "64 random points vs host derivation" check failed on every interleaved pack while
|
|
# the Mac's samples and the vectors passed (the known-failed case, docs/bench-log.md, era layout entry). This script
|
|
# runs the CUDA CPU emulation on an interleaved era pack and a linear one and requires OVERALL: PASS on both; it is
|
|
# the test that fails on the old derivation. Usage: emu/test-layout.sh [pack dir ...]
|
|
set -euo pipefail
|
|
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
CUDA_DIR="$(cd "$HERE/.." && pwd)"
|
|
PACKS=("$@")
|
|
[ ${#PACKS[@]} -gt 0 ] || PACKS=("$CUDA_DIR/packs-ca2-era/era-1" "$CUDA_DIR/packs/igneum-devnet-v4-epoch0")
|
|
CXX="${CXX:-c++}"
|
|
for P in "${PACKS[@]}"; do
|
|
grep -q "mh_addr(" "$P/memhard.h" && kind=interleaved || kind=linear
|
|
BUILD="$HERE/build-layout-$(basename "$P")"
|
|
mkdir -p "$BUILD"
|
|
cp "$CUDA_DIR/host.cu" "$BUILD/host_emu.cpp"
|
|
sed -E 's/([A-Za-z_0-9]+)<<<([^,]+), ([^>]+)>>>\(/emu_launch(\1, \2, \3, /' "$P/kernel.cu" > "$BUILD/kernel_emu.cpp"
|
|
sed -E 's/([A-Za-z_0-9]+)<<<([^,]+), ([^>]+)>>>\(/emu_launch(\1, \2, \3, /' "$P/kernel_bound.cu" > "$BUILD/kernel_bound_emu.cpp"
|
|
"$CXX" -std=c++17 -O2 -w -I "$HERE" -I "$P" -o "$BUILD/igneum-emu" "$BUILD/host_emu.cpp" "$BUILD/kernel_emu.cpp" -DIGNEUM_BOUND "$BUILD/kernel_bound_emu.cpp" "$HERE/shim.cpp" -pthread
|
|
out="$("$BUILD/igneum-emu" --batch-log2 13 --batches 1 2>&1)"
|
|
echo "$out" | grep -E "dataset self-test|OVERALL" | sed "s|^|$(basename "$P") ($kind): |"
|
|
echo "$out" | grep -q "^OVERALL: PASS" || { echo "FAIL: $P ($kind layout) did not pass the emulated harness"; exit 1; }
|
|
echo "$out" | grep -q "64 random points vs host derivation PASS" || { echo "FAIL: $P ($kind layout): the host derivation disagrees with the pack's layout"; exit 1; }
|
|
done
|
|
echo "PASS: the host derivation follows the pack's layout on ${#PACKS[@]} pack(s)"
|