summaryrefslogtreecommitdiffstats
path: root/tools/test/cuda_drv_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/test/cuda_drv_test.c')
-rw-r--r--tools/test/cuda_drv_test.c14
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;