omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / seed / kflow / check-driver-abi.py
| 1 | """Check 121-tk by-value parameter widths with the seeded packer, on the host.""" |
| 2 | import struct |
| 3 | import subprocess |
| 4 | import sys |
| 5 | import tempfile |
| 6 | from pathlib import Path |
| 7 | |
| 8 | with tempfile.TemporaryDirectory() as directory: |
| 9 | cubin = Path(directory) / "probe.cubin" |
| 10 | subprocess.run([sys.argv[1], "121-tk", "probe", "seed/sm121/vecadd.bin", |
| 11 | cubin, "16", "0", "1", "2", "4", "8", "p8"], check=True) |
| 12 | data = cubin.read_bytes() |
| 13 | header = struct.unpack_from("<Q", data, 40)[0] |
| 14 | count = struct.unpack_from("<H", data, 60)[0] |
| 15 | sections = [struct.unpack_from("<IIQQQQIIQQ", data, header + 64*i) for i in range(count)] |
| 16 | def payload(section): |
| 17 | return data[section[4]:section[4]+section[5]] |
| 18 | names = payload(sections[1]) |
| 19 | info = payload(next(s for s in sections if names[s[0]:].split(b"\x00",1)[0] == b".nv.info.probe")) |
| 20 | found = {} |
| 21 | i = 0 |
| 22 | while i < len(info): |
| 23 | fmt, attr, size = struct.unpack_from("<BBH", info, i) |
| 24 | i += 4 |
| 25 | if fmt == 4: |
| 26 | if attr == 0x17: |
| 27 | _, ordinal, offset, flags = struct.unpack_from("<IHHI", info, i) |
| 28 | found[ordinal] = (offset, flags) |
| 29 | i += size |
| 30 | expected = dict(enumerate([(0,0x5f000), (2,0x9f000), (4,0x11f000), |
| 31 | (8,0x21f000), (16,0x21f500)])) |
| 32 | if found != expected: |
| 33 | sys.exit(f"KPARAM_INFO mismatch: {found!r}") |
| 34 | print("PASS 121-tk scalar and pointer parameter offsets and widths") |