Driver: now ignore CUDA_ERROR_DEINITIALIZED in the destructor of CUDA C++ object.

This should be harmless. ISAAC deinitializes CUDA at the very end, but external libraries may deinitialize it beforehands.
This commit is contained in:
Philippe Tillet
2015-11-27 02:09:15 -05:00
parent c0b9bbee43
commit dfbe52c20a
6 changed files with 16 additions and 13 deletions

View File

@@ -118,6 +118,7 @@ namespace cuda
}
void check(CUresult);
void check_destruction(CUresult);
}

View File

@@ -47,7 +47,6 @@ private:
int cuGetInfo() const;
public:
// Device(int ordinal);
explicit Device(CUdevice const & device, bool take_ownership = true);
explicit Device(cl_device_id const & device, bool take_ownership = true);

View File

@@ -97,6 +97,13 @@ void check(CUresult err)
default : throw unknown();
}
}
void check_destruction(CUresult result)
{
if(result!=CUDA_ERROR_DEINITIALIZED)
cuda::check(result);
}
}
namespace ocl

View File

@@ -21,11 +21,6 @@ int Device::cuGetInfo() const
return res;
}
//Device::Device(int ordinal): backend_(CUDA), h_(backend_, true)
//{
// cuda::check(dispatch::cuDeviceGet(&h_.cu(), ordinal));
//}
Device::Device(CUdevice const & device, bool take_ownership): backend_(CUDA), h_(backend_, take_ownership)
{
h_.cu() = device;

View File

@@ -9,27 +9,29 @@ namespace isaac
namespace driver
{
//CUDA
template<class CLType, class CUType>
void Handle<CLType, CUType>::_delete(CUcontext x) { cuda::check(dispatch::cuCtxDestroy(x)); }
void Handle<CLType, CUType>::_delete(CUcontext x) { cuda::check_destruction(dispatch::cuCtxDestroy(x)); }
template<class CLType, class CUType>
void Handle<CLType, CUType>::_delete(CUdeviceptr x) { cuda::check(dispatch::dispatch::cuMemFree(x)); }
void Handle<CLType, CUType>::_delete(CUdeviceptr x) { cuda::check_destruction(dispatch::dispatch::cuMemFree(x)); }
template<class CLType, class CUType>
void Handle<CLType, CUType>::_delete(CUstream x) { cuda::check(dispatch::cuStreamDestroy(x)); }
void Handle<CLType, CUType>::_delete(CUstream x) { cuda::check_destruction(dispatch::cuStreamDestroy(x)); }
template<class CLType, class CUType>
void Handle<CLType, CUType>::_delete(CUdevice) { }
template<class CLType, class CUType>
void Handle<CLType, CUType>::_delete(CUevent x) { cuda::check(dispatch::dispatch::cuEventDestroy(x)); }
void Handle<CLType, CUType>::_delete(CUevent x) { cuda::check_destruction(dispatch::dispatch::cuEventDestroy(x)); }
template<class CLType, class CUType>
void Handle<CLType, CUType>::_delete(CUfunction) { }
template<class CLType, class CUType>
void Handle<CLType, CUType>::_delete(CUmodule x) { cuda::check(dispatch::dispatch::cuModuleUnload(x)); }
void Handle<CLType, CUType>::_delete(CUmodule x) { cuda::check_destruction(dispatch::dispatch::cuModuleUnload(x)); }
template<class CLType, class CUType>
void Handle<CLType, CUType>::_delete(cu_event_t x) { _delete(x.first); _delete(x.second); }

View File

@@ -30,8 +30,7 @@ extern "C"
cublasStatus_t cublasDestroy_v2 (cublasHandle_t handle)
{
delete handle;
cublasShutdown();
return CUBLAS_STATUS_SUCCESS;
return cublasShutdown();
}
cublasStatus cublasInit()