提交 d3f706cc authored 作者: Frederic's avatar Frederic

Add theano.sandbox.cuda.synchronize() to allow to force the sync.

上级 6a6e7fc3
...@@ -2451,6 +2451,16 @@ GetDeviceMemInfo(PyObject* _unused, PyObject* dummy) ...@@ -2451,6 +2451,16 @@ GetDeviceMemInfo(PyObject* _unused, PyObject* dummy)
return PyTuple_Pack(2, PyLong_FromLong(free), PyLong_FromLong(total)); return PyTuple_Pack(2, PyLong_FromLong(free), PyLong_FromLong(total));
} }
/*
* Returns in *free and *total respectively, the free and total amount of memory available for allocation by the device in bytes.
*/
PyObject *
CudaNdarray_synchronize(PyObject* _unused, PyObject* dummy)
{
cudaThreadSynchronize();
Py_INCREF(Py_None);
return Py_None;
}
#if COMPUTE_GPU_MEM_USED #if COMPUTE_GPU_MEM_USED
/* /*
* Return the size in bytes that Theano currently have allocated on the gpu. * Return the size in bytes that Theano currently have allocated on the gpu.
...@@ -2958,6 +2968,7 @@ static PyMethodDef module_methods[] = { ...@@ -2958,6 +2968,7 @@ static PyMethodDef module_methods[] = {
{"filter", filter, METH_VARARGS, "filter(obj, broadcastable, strict, storage) returns a CudaNdarray initialized to obj if it matches the constraints of broadcastable. strict=True prevents any numeric casting. If storage is a CudaNdarray it may be overwritten and used as the return value."}, {"filter", filter, METH_VARARGS, "filter(obj, broadcastable, strict, storage) returns a CudaNdarray initialized to obj if it matches the constraints of broadcastable. strict=True prevents any numeric casting. If storage is a CudaNdarray it may be overwritten and used as the return value."},
{"outstanding_mallocs", outstanding_mallocs, METH_VARARGS, "how many more mallocs have been called than free's"}, {"outstanding_mallocs", outstanding_mallocs, METH_VARARGS, "how many more mallocs have been called than free's"},
{"from_gpu_pointer", CudaNdarray_from_gpu_pointer, METH_VARARGS, "Used to create a CudaNdarray from already allocated memory on the gpu.(example by pycuda)"}, {"from_gpu_pointer", CudaNdarray_from_gpu_pointer, METH_VARARGS, "Used to create a CudaNdarray from already allocated memory on the gpu.(example by pycuda)"},
{"synchronize", CudaNdarray_synchronize, METH_NOARGS, "Used to synchronize the device"},
{NULL, NULL, NULL, NULL} /* Sentinel */ {NULL, NULL, NULL, NULL} /* Sentinel */
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论