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 / rmchan_diff.sh

57 lines · 2630 bytes Raw Blame History
1#!/bin/sh
2# tests/rmchan_diff.sh: builds the .om RM channel trace (gsp/rpc.om + gsp/sysinfo.om + chan/params.om +
3# gsp/boot.om + chan/dma.om + chan/gmmu.om + chan/mem.om + chan/chan.om + chan/sim.om + chan/complete.om +
4# chan/rmchan.om + tests/rmchan_trace.om) and the C reference trace tests/rmchan_ref.c (compiled fresh
5# against NVIDIA open-gpu-kernel-modules 580.173.02 headers) and requires byte-identical stdout. Host only.
6set -u
7here=$(cd "$(dirname "$0")/.." && pwd)
8OMC=${OMC:-$here/build/omc}
9RMCHAN_OM=${RMCHAN_OM:-$here/chan/rmchan.om}
10OGKM_SRC=${OGKM_SRC:-/home/drakestapleton/workspace/_ext/open-gpu-kernel-modules-580.173.02/src}
11RMCHAN_REF=${RMCHAN_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 "rmchan_diff: FAIL omc sha256 $got, pinned $OMC_SHA"; exit 2
18fi
19
20t=$(mktemp -d /tmp/rmchan_diff.XXXXXX) || exit 2
21trap 'rm -rf "$t"' EXIT
22
23if [ -n "$RMCHAN_REF" ]; then
24 [ -s "$RMCHAN_REF" ] || { echo "rmchan_diff: FAIL RMCHAN_REF $RMCHAN_REF missing or empty"; exit 2; }
25 cp "$RMCHAN_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/rmchan_ref.c"; then
32 echo "rmchan_diff: FAIL C reference build"; exit 2
33 fi
34 run "$t/cref" > "$t/c.txt" || { echo "rmchan_diff: FAIL C reference run"; exit 2; }
35fi
36
37if ! cat "$here/gsp/rpc.om" "$here/gsp/replay.om" "$here/gsp/sysinfo.om" "$here/chan/params.om" "$here/gsp/boot.om" \
38 "$here/chan/dma.om" "$here/chan/gmmu.om" "$here/chan/mem.om" "$here/chan/chan.om" \
39 "$here/chan/sim.om" "$here/chan/complete.om" "$RMCHAN_OM" "$here/tests/rmchan_trace.om" \
40 | run "$OMC" > "$t/omtrace"; then
41 echo "rmchan_diff: FAIL omc build"; exit 3
42fi
43chmod +x "$t/omtrace"
44run "$t/omtrace" > "$t/om.txt"
45rc=$?
46if [ "$rc" -ne 0 ]; then
47 echo "rmchan_diff: FAIL om trace exit $rc"; exit 1
48fi
49n=$(wc -l < "$t/c.txt")
50if [ "$n" -eq 0 ]; then
51 echo "rmchan_diff: FAIL empty C trace"; exit 2
52fi
53if ! cmp -s "$t/c.txt" "$t/om.txt"; then
54 echo "rmchan_diff: FAIL traces differ ($(diff "$t/c.txt" "$t/om.txt" | grep -c '^[<>]') differing lines; C $n lines, om $(wc -l < "$t/om.txt"))"
55 exit 1
56fi
57echo "rmchan_diff: PASS ($n lines identical, .om vs C reference)"