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