Prevent missmatches between incompatible versions of the CUDA runtime and the CUDA driver.

This commit is contained in:
castano
2008-10-16 22:21:21 +00:00
parent aa37e7a868
commit cf18077eda

View File

@ -22,6 +22,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#include <nvcore/Debug.h>
#include <nvcore/Library.h>
#include "CudaUtils.h"
#if defined HAVE_CUDA
@ -68,27 +69,36 @@ static bool isWow32()
#endif
static bool isCudaDriverAvailable(uint version)
{
#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;
}
Library nvcuda("nvcuda.dll");
#else
Library nvcuda(NV_LIBRARY_NAME("cuda"));
#endif
if (!nvcuda.isValid())
{
return false;
}
if (version > 2000)
{
void * address = nvcuda.bindSymbol("cuStreamCreate");
if (address == NULL) return false;
}
if (version > 2010)
{
void * address = nvcuda.bindSymbol("cuLoadDataEx");
if (address == NULL) return false;
}
return true;
}
/// Determine if CUDA is available.
bool nv::cuda::isHardwarePresent()
{
@ -111,12 +121,10 @@ bool nv::cuda::isHardwarePresent()
}
// Make sure that CUDA driver matches CUDA runtime.
#if NV_OS_WIN32 && CUDART_VERSION >= 2000
if (!isCuda20DriverAvailable())
if (!isCudaDriverAvailable(CUDART_VERSION))
{
return false;
}
#endif
// @@ Make sure that warp size == 32
}