Shutdown CUDA properly. Fixes issue 83.
This commit is contained in:
parent
9ed0f6e143
commit
fc260e2d0c
|
@ -8,6 +8,7 @@ NVIDIA Texture Tools version 2.0.6
|
|||
* Fix nvzoom option typo by Frank Richter. Fixes issue 81.
|
||||
* Do not use CUDA to compress small mipmaps. Fixes issue 76.
|
||||
* Compute mipmaps of semi-transparent images correctly.
|
||||
* Shutdown CUDA properly. Fixes issue 83.
|
||||
|
||||
NVIDIA Texture Tools version 2.0.5
|
||||
* Fix error in single color compressor. Fixes issue 66.
|
||||
|
|
|
@ -228,6 +228,7 @@ Compressor::Compressor() : m(*new Compressor::Private())
|
|||
Compressor::~Compressor()
|
||||
{
|
||||
delete &m;
|
||||
cuda::exit();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
|
||||
#if defined HAVE_CUDA
|
||||
#include <cuda_runtime.h>
|
||||
#include <cuda_runtime_api.h>
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
|
|
@ -84,19 +84,26 @@ static bool isCudaDriverAvailable(int version)
|
|||
|
||||
if (!nvcuda.isValid())
|
||||
{
|
||||
nvDebug("*** CUDA driver not found.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (version >= 2000)
|
||||
{
|
||||
void * address = nvcuda.bindSymbol("cuStreamCreate");
|
||||
if (address == NULL) return false;
|
||||
if (address == NULL) {
|
||||
nvDebug("*** CUDA driver version < 2.0.\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (version >= 2010)
|
||||
{
|
||||
void * address = nvcuda.bindSymbol("cuModuleLoadDataEx");
|
||||
if (address == NULL) return false;
|
||||
if (address == NULL) {
|
||||
nvDebug("*** CUDA driver version < 2.1.\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (version >= 2020)
|
||||
|
@ -104,16 +111,23 @@ static bool isCudaDriverAvailable(int version)
|
|||
typedef CUresult (CUDAAPI * PFCU_DRIVERGETVERSION)(int * version);
|
||||
|
||||
PFCU_DRIVERGETVERSION driverGetVersion = (PFCU_DRIVERGETVERSION)nvcuda.bindSymbol("cuDriverGetVersion");
|
||||
if (driverGetVersion == NULL) return false;
|
||||
if (driverGetVersion == NULL) {
|
||||
nvDebug("*** CUDA driver version < 2.2.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
int driverVersion;
|
||||
if (driverGetVersion(&driverVersion) != CUDA_SUCCESS) return false;
|
||||
CUresult err = driverGetVersion(&driverVersion);
|
||||
if (err != CUDA_SUCCESS) {
|
||||
nvDebug("*** Error querying driver version: '%s'.\n", cudaGetErrorString((cudaError_t)err));
|
||||
return false;
|
||||
}
|
||||
|
||||
return driverVersion >= version;
|
||||
}
|
||||
#endif // HAVE_CUDA
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,10 +135,13 @@ static bool isCudaDriverAvailable(int version)
|
|||
bool nv::cuda::isHardwarePresent()
|
||||
{
|
||||
#if defined HAVE_CUDA
|
||||
#if NV_OS_WIN32
|
||||
//if (isWindowsVista()) return false;
|
||||
//if (isWindowsVista() || !isWow32()) return false;
|
||||
#endif
|
||||
// Make sure that CUDA driver matches CUDA runtime.
|
||||
if (!isCudaDriverAvailable(CUDART_VERSION))
|
||||
{
|
||||
nvDebug("CUDA driver not available for CUDA runtime %d\n", CUDART_VERSION);
|
||||
return false;
|
||||
}
|
||||
|
||||
int count = deviceCount();
|
||||
if (count == 1)
|
||||
{
|
||||
|
@ -137,16 +154,10 @@ bool nv::cuda::isHardwarePresent()
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure that CUDA driver matches CUDA runtime.
|
||||
if (!isCudaDriverAvailable(CUDART_VERSION))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// @@ Make sure that warp size == 32
|
||||
}
|
||||
|
||||
// @@ Make sure that warp size == 32
|
||||
|
||||
return count > 0;
|
||||
#else
|
||||
return false;
|
||||
|
@ -205,8 +216,24 @@ bool nv::cuda::setDevice(int i)
|
|||
nvCheck(i < deviceCount());
|
||||
#if defined HAVE_CUDA
|
||||
cudaError_t result = cudaSetDevice(i);
|
||||
|
||||
if (result != cudaSuccess) {
|
||||
nvDebug("*** CUDA Error: %s\n", cudaGetErrorString(result));
|
||||
}
|
||||
|
||||
return result == cudaSuccess;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void nv::cuda::exit()
|
||||
{
|
||||
#if defined HAVE_CUDA
|
||||
cudaError_t result = cudaThreadExit();
|
||||
|
||||
if (result != cudaSuccess) {
|
||||
nvDebug("*** CUDA Error: %s\n", cudaGetErrorString(result));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace nv
|
|||
int deviceCount();
|
||||
int getFastestDevice();
|
||||
bool setDevice(int i);
|
||||
void exit();
|
||||
};
|
||||
|
||||
} // nv namespace
|
||||
|
|
Loading…
Reference in New Issue
Block a user