Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/patches/82e1843cf8236306 # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/CUDApp#84 (code only) closed derived `82e1843cf8236306` #84 Imported from GitHub aien-dev/CUDApp#84 (code only) GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed). Base `a520cd30e54c3b0ddd553ee3ccb3f5e673345cd6` · Head `60d6c57fc6821accce0027d65dd239355beeb543` ### Apply it ``` git checkout -b patch-82e1843cf8236306 a520cd30e54c3b0ddd553ee3ccb3f5e673345cd6 curl -fsSL https://interplane.io/drakestapleton/CUDApp/patches/82e1843cf8236306.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/CUDApp 84 60d6c57fc6821accce0027d65dd239355beeb543 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"CUDApp","number":84,"url":"https://github.com/aien-dev/CUDApp/pull/84","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:39:24Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/evidence/device-trace/emitter-host-20261026/receipt.json b/evidence/device-trace/emitter-host-20261026/receipt.json new file mode 100644 index 00000000..e31bab4b --- /dev/null +++ b/evidence/device-trace/emitter-host-20261026/receipt.json @@ -0,0 +1,62 @@ +{ + "schema": "cudapp.device-trace.emitter-receipt.v1", + "issue": "https://github.com/aien-dev/CUDApp/issues/82", + "consumer": "https://github.com/aien-dev/omega-mv/issues/778", + "contract": "docs/device-trace/CONTRACT.md v1 (PR #83, proposed; implemented as written, no field changed)", + "run": "2026-10-26 host checks, no GPU", + "scope": { + "in": ["native/blackwell/trace-emit.om", "tests/device-trace/emitter-test.om", "tests/device-trace/expected.sass", "tests/device-trace/run-emitter-checks.sh"], + "out": ["native/blackwell/trace.om (dot, PR #83)", "docs/device-trace/* (dot, PR #83)", "Omega #778 reader", "vector.om/launch.om/context.om", "any C kernel", "NVTXD/NVTOOLSEXT/PTX/libcuda paths"] + }, + "source": { + "native/blackwell/trace-emit.om": "d00dfe161a0a048c4ad1817b39b93dcc252e743a4430578c911706566a1c129b", + "tests/device-trace/emitter-test.om": "e63128049279b9aa0c65a15d25b396b47b5d2f7578174eed09c4509dc5cd8c12", + "tests/device-trace/expected.sass": "d9fb8b005044531fd8b2184e53fc531d2075457aa0ac5bcf47e522221ad7d4d9", + "tests/device-trace/run-emitter-checks.sh": "593bbcbf0230a39f1ae201987202bde52f6cbf551d2cde9c351e70a8bfb00fad", + "repo_base": "aien-dev/CUDApp a520cd30e54c3b0ddd553ee3ccb3f5e673345cd6" + }, + "compiler": { + "path": "seed/out/omc (omega feat/allen-imac-competition c3fb79697)", + "sha256": "c99eda2465036c0637a444689a65dd7fc736e4fa8a8b4cf3456b0ce1b57f8996" + }, + "oracle": { + "tool": "nvdisasm 13.0 (outside the delivered closure; host-only)", + "target": "SM121 raw instruction stream", + "binary_sha256_prefix": "bc40070d596fa49b" + }, + "commands": [ + "OMEGA_COMPILER=/seed/out/omc sh tests/device-trace/run-emitter-checks.sh --update", + "OMEGA_COMPILER=/seed/out/omc sh tests/device-trace/run-emitter-checks.sh" + ], + "results": { + "host_checks": {"checks": 25, "failures": 0, "exit": 0}, + "emitted": {"instructions": 40, "bytes": 640, "meaning": "two 20-instruction mark blocks, empty kernel between"}, + "decode": {"verdict": "MATCH", "golden": "tests/device-trace/expected.sass"}, + "disabled_identity": "PASS (byte-for-byte copy of the input words, no prologue, no stores)", + "refusals": {"capacity_below_two": 1, "capacity_above_64": 2, "input_not_whole_instructions": 3, "enabled_without_checks": 4} + }, + "instruction_slice": [ + "ISETP.GE.AND P0, PT, R0, 0x1, PT -- select thread 0 only", + "@P0 BRA past the block -- non-selected lanes never reach the stores; no barrier used for ordering", + "LDCU.64 UR4, c[0x0][0x358] -- global memory descriptor", + "S2R R2, SR_GLOBALTIMERLO -- device clock, low 32 bits", + "LDC.64 base/gen/kernel from c[0x0][0x400/0x410/0x418]", + "IMAD.SHL record address base + 0x40 (site 1) / 0x80 (site 2); IMAD.MOV high half copy", + "8 x STG.E dwords: site, kind, sequence, raw stamp, generation (2), kernel (2)" + ], + "limitations": [ + "Record fields cta/warp/lane/payload stay zero and generation/kernel come from the constant bank; the host must zero the extent and initialise the header before launch, then finalise status after completion.", + "Runtime overflow is not exercised: exactly two fixed records are emitted, so a capacity below two is refused at emission (code 1) instead of dropping at runtime. Dynamic sequence counting, saturating dropped counters and partial status need the next slice.", + "Record offsets are added to the low 32 bits of the trace base with no carry propagation: the host buffer must not cross a 4 GiB boundary at any record offset.", + "Clock units, resolution, cross-SM comparability and CPU correlation are UNKNOWN. GLOBALTIMER low 32 bits is a reference, not a qualified 64-bit clock; wrap is 2^32 ticks and any interval at or beyond 2^31 ticks is ambiguous and must be refused by the consumer.", + "The enabled path is gated: gtewrap refuses with code 4 unless the host sets gtchecks, so no launch can use it before the chip checks exist.", + "No barrier, fence or wait was added. Marker order is issue order, not completion order; markers around a region do not prove the region completed between them.", + "One selected lane of one CTA is not representative of other lanes, warps or CTAs." + ], + "not_run": { + "GB10_execution": "NOT_RUN - no hardware window requested or granted", + "qmd_and_launch_wiring": "NOT_RUN", + "paired_off_on_overhead": "NOT_RUN", + "chip_overflow_and_repeatability": "NOT_RUN" + } +} diff --git a/native/blackwell/trace-emit.om b/native/blackwell/trace-emit.om new file mode 100644 index 00000000..a5d1ef19 --- /dev/null +++ b/native/blackwell/trace-emit.om @@ -0,0 +1,186 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Device-side trace emitter for CUDApp #82, first slice. Handwritten seeded Omega. +note It emits the instruction words for one selected producer (thread 0 of the launched CTA) +note that records two bounded mark records around one synchronous region, and returns the +note input kernel words unchanged when tracing is disabled. +note +note Wire layout is PR #83 docs/device-trace/CONTRACT.md v1: 64-byte header, 64-byte records, +note kinds 1 mark / 2 begin / 3 end, clock domain 1 = raw device GLOBALTIMER low 32 bits with +note units UNKNOWN. The host owns header initialisation (magic, version, extent, capacity, +note generation, kernel, manifest, status) and finalises it after completion; this emitter +note writes records only. No 64-bit clock claim, no nanosecond claim. +note +note Register numbers are physical and fixed by this emitter: R0 tid, R2 stamp, R4:R5 trace +note base, R6 scratch, R8:R9 record address, R10:R11 generation, R12:R13 kernel; the global +note memory descriptor is loaded into UR4. Encodings are ported from the repository's own +note encoder, src/omega_blackwell_codegen.c encode_single_insn (S2R 0x7919, ISETP.GE 0x780c, +note BRA 0x947, LDC64 0xff007b82, LDCU64 0xff0077ac, MOV imm 0x7802, IMAD imm 0x7824, +note STG.E 0x7986), and each emitted stream is decoded by nvdisasm 13.0 as an outside oracle. +note +note Declared constraints of this slice: offsets are added to the low 32 bits of the trace base +note with no carry propagation, so the host buffer must not cross a 4 GiB boundary at any record +note offset; the enabled path is refused unless the host has run the instruction checks and set +note gtchecks to 1. + +const TRBAS ulong 1024 +const TRGEN ulong 1040 +const TRKRN ulong 1048 +const TRDSK ulong 856 +const HDRSZ ulong 64 +const RECSZ ulong 64 +const MAXCAP ulong 64 +const MAXEXT ulong 4160 +const SITE1 ulong 1 +const SITE2 ulong 2 +const KINDMK ulong 1 +const R_S2R ulong 31001 +const R_ISET ulong 30732 +const R_LDC ulong 4278221698 +const R_LDCU ulong 4278220716 +const R_MOVI ulong 30722 +const R_IMAD ulong 30756 +const R_STG ulong 31110 +const SR_TID ulong 33 +const SR_CLK ulong 82 +const R_BRA ulong 2375 + +global gbin uchar 4096 +global gbinlen ulong 1 +global gbout uchar 8192 +global gboutlen ulong 1 +global gterr ulong 1 +global gtcap ulong 1 +global gten ulong 1 +global gtchecks ulong 1 + +fn gtword v uint to void +for j ulong 4 +put gbout get gboutlen 0 uchar and shr v mul j 8 255 +put gboutlen 0 add get gboutlen 0 1 +end +end + +fn gtquad a uint b uint c uint d uint to void +gtword a +gtword b +gtword c +gtword d +end + +fn gts2r dst ulong sr ulong to void +gtquad uint or R_S2R shl dst 16 uint 0 uint shl sr 8 uint 926208 +end + +fn gtsel to void +note ISETP.GE P0, R0, 1: predicate true when tid >= 1, so only tid 0 records. +gtquad uint R_ISET uint 1 uint 66085488 uint 2087424 +end + +fn gtmov dst ulong imm ulong to void +gtquad uint or R_MOVI shl dst 16 uint imm uint 3840 uint 1040896 +end + +fn gtstg bse ulong val ulong off ulong to void +gtquad uint or R_STG shl bse 24 uint or val shl and off 65535 8 uint 202381572 uint 1040896 +end + +fn gtldc dst ulong off ulong to void +note LDC.64 Rd:Rd+1, c[0x0][off] +gtquad uint or R_LDC shl dst 16 uint and shl off 6 16776960 uint 2560 uint 926208 +end + +fn gtldu dst ulong off ulong to void +note LDCU.64 URd:URd+1, c[0x0][off] -- the global memory descriptor. +gtquad uint or R_LDCU shl dst 16 uint and shl off 5 16776960 uint 134220288 uint 945664 +end + +fn gtadd dst ulong src ulong imm ulong to void +note IMAD Rd, Ra, imm, RZ -- multiply by imm and add RZ. +gtquad uint or or R_IMAD shl dst 16 shl src 24 uint imm uint 126747391 uint 2083328 +end + +fn gtcop dst ulong src ulong to void +gtadd dst src 1 +end + +fn gtbrak to void +note BRA @P0 over the fixed 20-instruction mark block: delta 19, rel 18, predicate field 0. +gtquad uint or R_BRA shl ulong 18 18 uint 0 uint 58720256 uint 1042944 +end + +fn gtmark site ulong seq ulong to void +note One bounded mark record at 64 + 64*site. Field offsets are contract v1. +gtsel +gtbrak +gtldu 4 TRDSK +gts2r 2 SR_CLK +gtldc 4 TRBAS +gtldc 10 TRGEN +gtldc 12 TRKRN +gtadd 8 4 mul site 64 +gtcop 9 5 +gtmov 6 site +gtstg 8 6 0 +gtmov 6 KINDMK +gtstg 8 6 4 +gtmov 6 seq +gtstg 8 6 8 +gtstg 8 2 12 +gtstg 8 10 16 +gtstg 8 11 20 +gtstg 8 12 24 +gtstg 8 13 28 +end + +fn gtinit cap ulong to bool +note Bound the extent before any word is emitted. Refusal codes: 1 capacity below two records, +note 2 extent above the contract maximum, 3 the input is not a whole number of instructions. +put gterr 0 0 +if gt cap MAXCAP +put gterr 0 2 +ret false +end +if lt cap 2 +put gterr 0 1 +ret false +end +if ne rem get gbinlen 0 16 0 +put gterr 0 3 +ret false +end +put gtcap 0 cap +ret true +end + +fn gtwrap on ulong to void +note Disabled: the output is the input byte for byte; no prologue, no store, no allocation. +note Enabled: mark(site 1), the caller's kernel words verbatim, mark(site 2). +put gboutlen 0 0 +if eq on 0 +for i ulong get gbinlen 0 +put gbout i get gbin i +end +put gboutlen 0 get gbinlen 0 +ret +end +gtmark SITE1 0 +for i ulong get gbinlen 0 +put gbout get gboutlen 0 uchar get gbin i +put gboutlen 0 add get gboutlen 0 1 +end +gtmark SITE2 1 +end + +fn gtewrap on ulong cap ulong to bool +note Checked entry point: refuse before emitting anything, then wrap. +if not gtinit cap +ret false +end +if and eq on 1 eq get gtchecks 0 0 +note Enabled needs the instruction and control-flow checks to have passed. +put gterr 0 4 +ret false +end +gtwrap on +ret true +end diff --git a/tests/device-trace/emitter-test.om b/tests/device-trace/emitter-test.om new file mode 100644 index 00000000..898795cd --- /dev/null +++ b/tests/device-trace/emitter-test.om @@ -0,0 +1,157 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Host checks for the device-side trace emitter (CUDApp #82 first slice). +note Run: cat native/blackwell/trace-emit.om tests/device-trace/emitter-test.om | seed/out/omc > t; ./t +note Prints one line per check: "id 0" pass, "id 1" fail. Exit status is the failure count. +note The instruction words themselves are decoded independently by nvdisasm 13.0 in +note tests/device-trace/run-emitter-checks.sh against expected.sass; this file checks the +note emitter's own invariants so a regression shows up without the external tool. + +global Fails ulong 1 +global Checks ulong 1 +global Ob uchar 256 +global Obn ulong 1 + +fn obc c uchar to void +put Ob get Obn 0 c +put Obn 0 add get Obn 0 1 +end + +fn obn v ulong to void +d = new uchar 20 0 +n = ulong 0 +x = v +put d n uchar add rem x 10 48 +n = add n 1 +x = div x 10 +while gt x 0 +put d n uchar add rem x 10 48 +n = add n 1 +x = div x 10 +end +while gt n 0 +n = sub n 1 +obc get d n +end +end + +fn chk ok bool id ulong to void +put Checks 0 add get Checks 0 1 +put Obn 0 0 +obn id +obc 32 +if ok +obc 48 +else +put Fails 0 add get Fails 0 1 +obc 49 +end +obc 10 +r = write 1 Ob 0 get Obn 0 +end + +fn wrd i ulong to ulong +note 32-bit little-endian word at instruction index i of the emitted stream. +b = mul i 16 +a = shl ulong get gbout b 0 +a = or a shl ulong get gbout add b 1 8 +a = or a shl ulong get gbout add b 2 16 +a = or a shl ulong get gbout add b 3 24 +ret a +end + +fn fill n ulong to void +for i ulong n +put gbin i uchar add 160 rem i 251 +end +put gbinlen 0 n +end + +fn same to bool +if ne get gboutlen 0 get gbinlen 0 +ret false +end +for i ulong get gbinlen 0 +if ne get gbout i get gbin i +ret false +end +end +ret true +end + +fn main to int +put gtchecks 0 1 +fill 64 +ok = gtewrap 0 4 +chk ok 1 +sm = same +chk sm 2 +v = get gboutlen 0 +chk eq v 64 3 + +ok = gtewrap 1 4 +chk ok 4 +v = get gboutlen 0 +chk eq v 704 5 +note Disabled output is exactly the input; enabled output is prologue + input + epilogue. +w = wrd 0 +chk ne w 0 6 +note The caller's kernel bytes ride verbatim in the middle of the enabled stream. +bb = get gbout 320 +chk eq bb 160 7 +bb = get gbout 383 +chk eq bb 223 8 +note Emitting twice with the same inputs gives the same bytes. +ok = gtewrap 1 4 +v = get gboutlen 0 +chk eq v 704 9 +w = wrd 0 +chk eq w 30732 10 + +note Enabled without the instruction checks passed must refuse and emit nothing. +put gtchecks 0 0 +put gboutlen 0 7 +ok = gtewrap 1 4 +chk not ok 11 +v = get gterr 0 +chk eq v 4 12 +v = get gboutlen 0 +chk eq v 7 13 +note Disabled still works with the checks unset and stays byte identical. +ok = gtewrap 0 4 +chk ok 14 +sm = same +chk sm 15 + +note Bounds and refusals. +ok = gtewrap 1 0 +chk not ok 16 +v = get gterr 0 +chk eq v 1 17 +ok = gtewrap 1 1 +chk not ok 18 +v = get gterr 0 +chk eq v 1 19 +ok = gtewrap 1 65 +chk not ok 20 +v = get gterr 0 +chk eq v 2 21 +fill 5 +ok = gtewrap 1 4 +chk not ok 22 +v = get gterr 0 +chk eq v 3 23 +note A refusal must not leave partial output. +v = get gboutlen 0 +chk ne v 704 24 + +note Negative control: mutate one byte of the enabled stream and the length check still holds +note but the byte comparison against the input must fail for the affected region. +fill 64 +put gtchecks 0 1 +ok = gtewrap 1 4 +bb = get gbout 320 +put gbout 320 uchar add bb 1 +bb = get gbout 320 +chk ne bb 160 25 +ret int get Fails 0 +end diff --git a/tests/device-trace/expected.sass b/tests/device-trace/expected.sass new file mode 100644 index 00000000..7fa8cb5d --- /dev/null +++ b/tests/device-trace/expected.sass @@ -0,0 +1,42 @@ + .headerflags @"EF_CUDA_64BIT_ADDRESS EF_CUDA_SM121 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM121)" + .headerflags @"EF_CUDA_64BIT_ADDRESS EF_CUDA_SM121 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM121)" + /*0000*/ ISETP.GE.AND P0, PT, R0, 0x1, PT ; + /*0010*/ @P0 BRA 0x140 ; + /*0020*/ LDCU.64 UR4, c[0x0][0x358] ; + /*0030*/ S2R R2, SR_GLOBALTIMERLO ; + /*0040*/ LDC.64 R4, c[0x0][0x400] ; + /*0050*/ LDC.64 R10, c[0x0][0x410] ; + /*0060*/ LDC.64 R12, c[0x0][0x418] ; + /*0070*/ IMAD.SHL R8, R4, 0x40, RZ ; + /*0080*/ IMAD.MOV R9, R5, 0x1, RZ ; + /*0090*/ MOV R6, 0x1 ; + /*00a0*/ STG.E desc[UR4][R8.64], R6 ; + /*00b0*/ MOV R6, 0x1 ; + /*00c0*/ STG.E desc[UR4][R8.64+0x4], R6 ; + /*00d0*/ MOV R6, 0x0 ; + /*00e0*/ STG.E desc[UR4][R8.64+0x8], R6 ; + /*00f0*/ STG.E desc[UR4][R8.64+0xc], R2 ; + /*0100*/ STG.E desc[UR4][R8.64+0x10], R10 ; + /*0110*/ STG.E desc[UR4][R8.64+0x14], R11 ; + /*0120*/ STG.E desc[UR4][R8.64+0x18], R12 ; + /*0130*/ STG.E desc[UR4][R8.64+0x1c], R13 ; + /*0140*/ ISETP.GE.AND P0, PT, R0, 0x1, PT ; + /*0150*/ @P0 BRA 0x280 ; + /*0160*/ LDCU.64 UR4, c[0x0][0x358] ; + /*0170*/ S2R R2, SR_GLOBALTIMERLO ; + /*0180*/ LDC.64 R4, c[0x0][0x400] ; + /*0190*/ LDC.64 R10, c[0x0][0x410] ; + /*01a0*/ LDC.64 R12, c[0x0][0x418] ; + /*01b0*/ IMAD.SHL R8, R4, 0x80, RZ ; + /*01c0*/ IMAD.MOV R9, R5, 0x1, RZ ; + /*01d0*/ MOV R6, 0x2 ; + /*01e0*/ STG.E desc[UR4][R8.64], R6 ; + /*01f0*/ MOV R6, 0x1 ; + /*0200*/ STG.E desc[UR4][R8.64+0x4], R6 ; + /*0210*/ MOV R6, 0x1 ; + /*0220*/ STG.E desc[UR4][R8.64+0x8], R6 ; + /*0230*/ STG.E desc[UR4][R8.64+0xc], R2 ; + /*0240*/ STG.E desc[UR4][R8.64+0x10], R10 ; + /*0250*/ STG.E desc[UR4][R8.64+0x14], R11 ; + /*0260*/ STG.E desc[UR4][R8.64+0x18], R12 ; + /*0270*/ STG.E desc[UR4][R8.64+0x1c], R13 ; diff --git a/tests/device-trace/run-emitter-checks.sh b/tests/device-trace/run-emitter-checks.sh new file mode 100755 index 00000000..fc097cd8 --- /dev/null +++ b/tests/device-trace/run-emitter-checks.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# Offline checks for the device-side trace emitter (CUDApp #82 first slice). +# +# Two layers, deliberately separate: +# 1. tests/device-trace/emitter-test.om -- host checks compiled by the pinned seed compiler. +# 2. nvdisasm 13.0 on the emitted words -- an outside oracle. It is not part of the +# delivered closure and no GPU is touched; it only confirms that every emitted word +# decodes to the intended instruction. +# +# Usage: OMEGA_COMPILER=/path/to/seed/out/omc sh tests/device-trace/run-emitter-checks.sh +# add --update to rewrite expected.sass from the current emitter output. +set -eu +root=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) +compiler=${OMEGA_COMPILER:-} +[ -n "$compiler" ] && [ -x "$compiler" ] || { + echo 'OMEGA_COMPILER must name the pinned seed compiler (seed/out/omc)' >&2 + exit 69 +} +work=${TMPDIR:-/tmp}/cudapp-emitter-check.$$ +mkdir -p "$work" +trap 'rm -rf -- "$work"' EXIT HUP INT TERM + +echo "compiler $(sha256sum "$compiler" | cut -d' ' -f1)" + +# 1. host checks +cat "$root/native/blackwell/trace-emit.om" "$root/tests/device-trace/emitter-test.om" > "$work/test.om" +"$compiler" < "$work/test.om" > "$work/test.elf" +chmod +x "$work/test.elf" +"$work/test.elf" > "$work/test.out" +fails=$(awk '$2 == 1 { n++ } END { print n + 0 }' "$work/test.out") +checks=$(wc -l < "$work/test.out") +echo "host checks: $checks, failures: $fails" +[ "$fails" = 0 ] || { cat "$work/test.out" >&2; exit 1; } + +# 2. instruction decode of the two marker blocks (no kernel words between them) +cat > "$work/dump.om" <<'EOF' +global Ob uchar 1024 +global Obn ulong 1 +fn main to int +put gbinlen 0 0 +put gtchecks 0 1 +ok = gtewrap 1 4 +if not ok +ret 3 +end +for i ulong get gboutlen 0 +c = get gbout i +put Ob get Obn 0 c +put Obn 0 add get Obn 0 1 +end +r = write 1 Ob 0 get Obn 0 +ret 0 +end +EOF +cat "$root/native/blackwell/trace-emit.om" "$work/dump.om" > "$work/dump_full.om" +"$compiler" < "$work/dump_full.om" > "$work/dump.elf" +chmod +x "$work/dump.elf" +"$work/dump.elf" > "$work/words.bin" +echo "words: $(wc -c < "$work/words.bin") bytes, $(( $(wc -c < "$work/words.bin") / 16 )) instructions" +[ "$(wc -c < "$work/words.bin")" = 640 ] || { echo 'expected 40 instructions (640 bytes)' >&2; exit 1; } + +nvdisasm --binary SM121 "$work/words.bin" > "$work/got.sass" +if [ "${1:-}" = "--update" ]; then + cp "$work/got.sass" "$root/tests/device-trace/expected.sass" + echo 'expected.sass updated' + exit 0 +fi +if diff -u "$root/tests/device-trace/expected.sass" "$work/got.sass"; then + echo 'nvdisasm decode matches expected.sass' +else + echo 'nvdisasm decode differs from expected.sass' >&2 + exit 1 +fi ```