提交 bbb199e0 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Remove the error handling code from the shutdown() path since it's

mostly useless.
上级 672eb0ad
...@@ -3033,7 +3033,7 @@ CudaNdarray_ptr_int_size(PyObject* _unused, PyObject* args) ...@@ -3033,7 +3033,7 @@ CudaNdarray_ptr_int_size(PyObject* _unused, PyObject* args)
} }
static int cublas_init(); static int cublas_init();
static int cublas_shutdown(); static void cublas_shutdown();
// Initialize the gpu. // Initialize the gpu.
// Takes one optional parameter, the device number. // Takes one optional parameter, the device number.
// If provided, it sets that device to be the active device. // If provided, it sets that device to be the active device.
...@@ -3091,10 +3091,6 @@ CudaNdarray_gpu_init(PyObject* _unused, PyObject* args) ...@@ -3091,10 +3091,6 @@ CudaNdarray_gpu_init(PyObject* _unused, PyObject* args)
} }
if(card_number_provided) { if(card_number_provided) {
if (handle != NULL)
if (cublas_shutdown() == -1)
return NULL;
err = cudaSetDevice(card_nb); err = cudaSetDevice(card_nb);
if(cudaSuccess != err) { if(cudaSuccess != err) {
return PyErr_Format(PyExc_EnvironmentError, return PyErr_Format(PyExc_EnvironmentError,
...@@ -3135,7 +3131,6 @@ PyObject * ...@@ -3135,7 +3131,6 @@ PyObject *
CudaNdarray_gpu_shutdown(PyObject* _unused, PyObject* _unused_args) { CudaNdarray_gpu_shutdown(PyObject* _unused, PyObject* _unused_args) {
// Don't handle errors here // Don't handle errors here
cublas_shutdown(); cublas_shutdown();
handle = NULL;
cudaThreadExit(); cudaThreadExit();
g_gpu_context_active = 0; // context has now been closed down g_gpu_context_active = 0; // context has now been closed down
Py_INCREF(Py_None); Py_INCREF(Py_None);
...@@ -3584,20 +3579,13 @@ cublas_init() ...@@ -3584,20 +3579,13 @@ cublas_init()
return 0; return 0;
} }
static int static void
cublas_shutdown() cublas_shutdown()
{ {
cublasStatus_t err; if (handle != NULL)
err = cublasDestroy(handle); cublasDestroy(handle);
if (CUBLAS_STATUS_SUCCESS != err) // No point in handling any errors here
{
PyErr_SetString(PyExc_RuntimeError,
"cublas_init tried to destroy the old cublas"
" context, cublasDestroy() returned an error.");
return -1;
}
handle = NULL; handle = NULL;
return 0;
} }
int int
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论