summaryrefslogtreecommitdiffstats
path: root/tools/cuda-bridge/embed_ptx.py
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-10-03 14:05:38 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-10-03 14:05:38 -0400
commit32b551d43781dc7b8ac4587ca2ba1554b0cbd5e5 (patch)
treed1cab6bcc35e461610cd5dfcf3f51ba679a576fc /tools/cuda-bridge/embed_ptx.py
parentfa71f1b53b524e5f6c6c1fbff1088d610b9f3236 (diff)
downloadopen-iov-32b551d43781dc7b8ac4587ca2ba1554b0cbd5e5.tar.gz
open-iov-32b551d43781dc7b8ac4587ca2ba1554b0cbd5e5.zip
vgsp: host CUDA bridge + sema release recovery; greeneye simulator wave
- kernel: gsp_cuda_bridge (QMD launch capture, debugfs job/out/done, param+output resolution cached from inline writes), sema drain fixes (never hold/starve a channel), GR ring autopin + counter autoreg, per-page push reads, counter-derive gate; module builds clean - tools/cuda-bridge: CUDA driver-API daemon executing mail/vadd kernels on the physical GPU, CUBB2/CBD2 v2 protocol, layout check + self-tests - tools/guest-diag + tools/cuda-ab: scanner/pin fixes, victory push-only mode - debug/risc-v-gsp-rm-vm: Phase S simulator wave (GSP device model, boot ladder, triage/re-demo harnesses, docs 30-41), GPGPU-sim scaffolding - STATE-CURRENT/docs updates
Diffstat (limited to 'tools/cuda-bridge/embed_ptx.py')
-rw-r--r--tools/cuda-bridge/embed_ptx.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tools/cuda-bridge/embed_ptx.py b/tools/cuda-bridge/embed_ptx.py
new file mode 100644
index 0000000..71b0e5f
--- /dev/null
+++ b/tools/cuda-bridge/embed_ptx.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# embed_ptx.py - turn a PTX text file into a NUL-terminated C byte array.
+# Used by the Makefile so cuda_bridge carries its kernels without any runtime
+# dependency on files or on a CUDA toolkit.
+
+import sys
+
+
+def main() -> int:
+ if len(sys.argv) != 3:
+ print("usage: embed_ptx.py <in.ptx> <out.h>", file=sys.stderr)
+ return 2
+ data = open(sys.argv[1], "rb").read()
+ if b"\x00" in data:
+ print("embed_ptx: input contains NUL", file=sys.stderr)
+ return 1
+ rows = []
+ for off in range(0, len(data), 12):
+ chunk = data[off:off + 12]
+ rows.append("\t" + " ".join(f"0x{b:02x}," for b in chunk))
+ body = "\n".join(rows)
+ text = (
+ "/* SPDX-License-Identifier: BSD-3-Clause */\n"
+ "/* generated by embed_ptx.py from %s - do not edit */\n"
+ "static const unsigned char kernels_ptx[] = {\n"
+ "%s\n"
+ "\t0x00\n"
+ "};\n"
+ "static const unsigned int kernels_ptx_len = %d;\n"
+ ) % (sys.argv[1], body, len(data))
+ with open(sys.argv[2], "w") as fh:
+ fh.write(text)
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())