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