From d01a5c16615b2d89c064abee304754f1a465dd72 Mon Sep 17 00:00:00 2001 From: castano Date: Thu, 16 Oct 2008 08:39:58 +0000 Subject: [PATCH] Workaround bug in CUDA runtime. When using CUDA 2.0, it's required to use a driver that supports CUDA 2.0. --- src/nvtt/cuda/CudaUtils.cpp | 46 +++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/nvtt/cuda/CudaUtils.cpp b/src/nvtt/cuda/CudaUtils.cpp index cd84cf1..5788bd5 100644 --- a/src/nvtt/cuda/CudaUtils.cpp +++ b/src/nvtt/cuda/CudaUtils.cpp @@ -52,22 +52,42 @@ static bool isWow32() { LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process"); - BOOL bIsWow64 = FALSE; + BOOL bIsWow64 = FALSE; - if (NULL != fnIsWow64Process) - { - if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) - { + if (NULL != fnIsWow64Process) + { + if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) + { // Assume 32 bits. - return true; - } - } + return true; + } + } - return !bIsWow64; + return !bIsWow64; } #endif +#if NV_OS_WIN32 + +static bool isCuda20DriverAvailable() +{ + bool result = false; + + HINSTANCE nvcuda = LoadLibraryExA( "nvcuda.dll", NULL, 0 ); + if (nvcuda != NULL) + { + FARPROC lcuStreamCreate = GetProcAddress( nvcuda, "cuStreamCreate" ); + + result = lcuStreamCreate != NULL; + + FreeLibrary( nvcuda ); + } + + return result; +} + +#endif /// Determine if CUDA is available. bool nv::cuda::isHardwarePresent() @@ -90,6 +110,14 @@ bool nv::cuda::isHardwarePresent() return false; } + // Make sure that CUDA driver matches CUDA runtime. +#if NV_OS_WIN32 && CUDART_VERSION >= 2000 + if (!isCuda20DriverAvailable()) + { + return false; + } +#endif + // @@ Make sure that warp size == 32 }