From 91e94ad3a68f4743696a0dfa7e4f379c4130eacb Mon Sep 17 00:00:00 2001 From: Ruobing Han Date: Thu, 15 Sep 2022 11:10:44 -0400 Subject: [PATCH] fix bug for segfault if without cudaSetDevice --- runtime/threadPool/src/x86/api.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/runtime/threadPool/src/x86/api.cpp b/runtime/threadPool/src/x86/api.cpp index 0095b37..ad34b36 100644 --- a/runtime/threadPool/src/x86/api.cpp +++ b/runtime/threadPool/src/x86/api.cpp @@ -8,11 +8,6 @@ #include #include -/* - - -*/ - /* Initialize the device */ @@ -112,6 +107,9 @@ int schedulerEnqueueKernel(cu_kernel *k) { Kernel Launch with numBlocks and numThreadsPerBlock */ int cuLaunchKernel(cu_kernel **k) { + if (!device_initilized) { + init_device(); + } // Calculate Block Size N/numBlocks cu_kernel *ker = *k; int status = C_RUN; @@ -239,7 +237,7 @@ void cuSynchronizeBarrier() { init_device(); } while (1) { - // (TODO): currently, we assume each kernel launch will have a + // (TODO): currently, we assume each kernel launch has a // following sync if (scheduler->kernelQueue->size_approx() == 0) { int completeBlock = 0;