diff options
| author | Arthur Hanson Rasmusson <arthur@vgpu.io> | 2026-09-23 07:05:45 -0400 |
|---|---|---|
| committer | Arthur Hanson Rasmusson <arthur@vgpu.io> | 2026-09-23 07:05:45 -0400 |
| commit | 54ca82d81bacb56197a607d0039ca6a015f5ac44 (patch) | |
| tree | 355be543e9da05468c5c0003ff7ddb60944221ec /tools/test | |
| parent | 893318f45eff1a2b5f4d554297d08a9e987c2a52 (diff) | |
| download | open-iov-54ca82d81bacb56197a607d0039ca6a015f5ac44.tar.gz open-iov-54ca82d81bacb56197a607d0039ca6a015f5ac44.zip | |
userspace/cuda: libcuda analysis tree (debug-focused), guest ioctl tracer
Analysis tooling for debugging CUDA execution in Open-IOV guests:
- userspace/cuda/570.144/: fetch a library from a running guest (nc),
objdump helpers, crash ip -> file vaddr + symbol mapping, and Ghidra
headless import/analysis/decompile scripts (project kept so single
functions decompile in seconds). The purpose is debugging correctness
and performance of CUDA in Open-IOV VMs (not a reimplementation);
extracted binaries and decompiled output are gitignored.
- tools/guest-diag/ioctl_trace.c: ptrace tracker for the NVIDIA driver
ioctls of a child (libcuda issues raw syscalls, so LD_PRELOAD sees
nothing). Decodes RM_ALLOC (class) and RM_CONTROL (cmd) arguments;
this is how the cuCtxCreate crash sequence was captured.
- tools/test/cuda_drv_test.c: unbuffered + per-call markers so a crash
identifies the CUDA call it happened in.
Diffstat (limited to 'tools/test')
| -rw-r--r-- | tools/test/cuda_drv_test.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/test/cuda_drv_test.c b/tools/test/cuda_drv_test.c index 6868a2e..20ad88a 100644 --- a/tools/test/cuda_drv_test.c +++ b/tools/test/cuda_drv_test.c @@ -30,8 +30,13 @@ typedef uint64_t CUdeviceptr; printf("%-24s OK\n", #expr); \ } while (0) +/* Print before entering libcuda so a crash identifies the call. */ +#define MARK(name) do { printf("-> %s\n", name); } while (0) + int main(void) { + setvbuf(stdout, NULL, _IONBF, 0); + void *h = dlopen("libcuda.so.1", RTLD_NOW); if (!h) { printf("dlopen libcuda.so.1 failed: %s\n", dlerror()); return 1; } @@ -59,28 +64,37 @@ int main(void) unsigned int back[64]; size_t i; + MARK("cuInit"); CHECK(cuInit(0)); + MARK("cuDeviceGetCount"); CHECK(cuDeviceGetCount(&count)); printf("device count = %d\n", count); if (count < 1) return 1; + MARK("cuDeviceGet"); CHECK(cuDeviceGet(&dev, 0)); printf("device 0 = %d\n", dev); + MARK("cuCtxCreate"); CHECK(cuCtxCreate(&ctx, 0, dev)); printf("context = %p\n", ctx); + MARK("cuMemAlloc"); CHECK(cuMemAlloc(&dptr, sizeof(buf))); printf("device ptr = 0x%llx (%zu bytes)\n", (unsigned long long)dptr, sizeof(buf)); for (i = 0; i < 64; i++) buf[i] = (unsigned int)(i * 3 + 1); + MARK("cuMemcpyHtoD"); CHECK(cuMemcpyHtoD(dptr, buf, sizeof(buf))); memset(back, 0, sizeof(back)); + MARK("cuMemcpyDtoH"); CHECK(cuMemcpyDtoH(back, dptr, sizeof(buf))); printf("roundtrip %s (back[7]=%u expected 22)\n", memcmp(buf, back, sizeof(buf)) ? "MISMATCH" : "match", back[7]); + MARK("cuMemFree"); CHECK(cuMemFree(dptr)); + MARK("cuCtxDestroy"); CHECK(cuCtxDestroy(ctx)); printf("ALL OK\n"); return 0; |
