interplane.Get Omega
Read in your language

omega-gpu-driver

aien-dev/omega-gpu-driver

Brought by drakestapleton

branch main Branches Tags History

omega-gpu-driver / tests / complete_diff.sh

54 lines · 2464 bytes Raw Blame History
1#!/bin/sh
2# tests/complete_diff.sh: builds the .om completion trace (chan/dma.om + chan/gmmu.om + chan/mem.om +
3# chan/chan.om + chan/sim.om + chan/complete.om + tests/complete_trace.om) and the C reference trace
4# tests/complete_ref.c (compiled fresh into a temp dir against NVIDIA open-gpu-kernel-modules 580.173.02
5# clc96f.h headers) and requires byte-identical stdout. Host only.
6set -u
7here=$(cd "$(dirname "$0")/.." && pwd)
8OMC=${OMC:-$here/build/omc}
9COMPLETE_OM=${COMPLETE_OM:-$here/chan/complete.om}
10OGKM_SRC=${OGKM_SRC:-/home/drakestapleton/workspace/_ext/open-gpu-kernel-modules-580.173.02/src}
11COMPLETE_REF=${COMPLETE_REF:-}
12OMC_SHA=$(sed -n 's/^OMC_SHA256=//p' "$here/tools/omc.pin")
13run() { nice -n 19 taskset -c "${AIEN_TEST_CPUS:-0-9,15-19}" "$@"; }
14
15got=$(sha256sum "$OMC" | cut -d' ' -f1)
16if [ "$got" != "$OMC_SHA" ]; then
17 echo "complete_diff: FAIL omc sha256 $got, pinned $OMC_SHA"; exit 2
18fi
19
20t=$(mktemp -d /tmp/complete_diff.XXXXXX) || exit 2
21trap 'rm -rf "$t"' EXIT
22
23if [ -n "$COMPLETE_REF" ]; then
24 [ -s "$COMPLETE_REF" ] || { echo "complete_diff: FAIL COMPLETE_REF $COMPLETE_REF missing or empty"; exit 2; }
25 cp "$COMPLETE_REF" "$t/c.txt" || exit 2
26else
27 S=$OGKM_SRC
28 if ! run cc -std=c11 -O1 -Wall -Werror \
29 -I"$S/common/sdk/nvidia/inc" -I"$S/nvidia/arch/nvalloc/common/inc" -I"$S/common/uproc/os/common/include" \
30 -I"$S/nvidia/inc/kernel" -I"$S/nvidia/inc" -I"$S/nvidia/generated" -I"$S/common/shared/msgq/inc" \
31 -I"$S/nvidia/interface" -I"$S/common/inc" -o "$t/cref" "$here/tests/complete_ref.c"; then
32 echo "complete_diff: FAIL C reference build"; exit 2
33 fi
34 run "$t/cref" > "$t/c.txt" || { echo "complete_diff: FAIL C reference run"; exit 2; }
35fi
36
37if ! cat "$here/chan/dma.om" "$here/chan/gmmu.om" "$here/chan/mem.om" "$here/chan/chan.om" "$here/chan/sim.om" "$COMPLETE_OM" "$here/tests/complete_trace.om" | run "$OMC" > "$t/omtrace"; then
38 echo "complete_diff: FAIL omc build"; exit 3
39fi
40chmod +x "$t/omtrace"
41run "$t/omtrace" > "$t/om.txt"
42rc=$?
43if [ "$rc" -ne 0 ]; then
44 echo "complete_diff: FAIL om trace exit $rc"; exit 1
45fi
46n=$(wc -l < "$t/c.txt")
47if [ "$n" -eq 0 ]; then
48 echo "complete_diff: FAIL empty C trace"; exit 2
49fi
50if ! cmp -s "$t/c.txt" "$t/om.txt"; then
51 echo "complete_diff: FAIL traces differ ($(diff "$t/c.txt" "$t/om.txt" | grep -c '^[<>]') differing lines; C $n lines, om $(wc -l < "$t/om.txt"))"
52 exit 1
53fi
54echo "complete_diff: PASS ($n lines identical, .om vs C reference)"