// it returns something else I still don't see why we should ignore
// it returns something else I still don't see why we should ignore
// it. All we want to do here is reset the flag.
// it. All we want to do here is reset the flag.
cudaGetLastError();
cudaGetLastError();
if(verbose)
{
#if COMPUTE_GPU_MEM_USED
#if COMPUTE_GPU_MEM_USED
fprintf(stderr,"Error allocating %li bytes of device memory (%s). new total bytes allocated: %d\n",(long)size,cudaGetErrorString(err),_allocated_size);
fprintf(stderr,"Error allocating %li bytes of device memory (%s). new total bytes allocated: %d\n",(long)size,cudaGetErrorString(err),_allocated_size);
#else
#else
fprintf(stderr,"Error allocating %li bytes of device memory (%s).\n",(long)size,cudaGetErrorString(err));
fprintf(stderr,"Error allocating %li bytes of device memory (%s).\n",(long)size,cudaGetErrorString(err));
#endif
#endif
}
PyErr_Format(PyExc_MemoryError,
PyErr_Format(PyExc_MemoryError,
"Error allocating %li bytes of device memory (%s).",(long)size,cudaGetErrorString(err));
"Error allocating %li bytes of device memory (%s).",(long)size,cudaGetErrorString(err));
PyErr_Format(PyExc_RuntimeError, "Some CudaNdarray has rank %%i, it was supposed to have rank %(nd)s", %(name)s->nd);
PyErr_Format(PyExc_RuntimeError,
"c_extract: Some CudaNdarray has rank %%i, it was supposed to have rank %(nd)s",
%(name)s->nd);
%(name)s = NULL;
%(name)s = NULL;
%(fail)s;
%(fail)s;
}
}
...
@@ -299,7 +301,9 @@ class CudaNdarrayType(Type):
...
@@ -299,7 +301,9 @@ class CudaNdarrayType(Type):
print>>sio,"""
print>>sio,"""
if (CudaNdarray_HOST_DIMS(%(name)s)[%(i)s] != 1)
if (CudaNdarray_HOST_DIMS(%(name)s)[%(i)s] != 1)
{
{
PyErr_Format(PyExc_RuntimeError, "Some CudaNdarray has dim %%i on broadcastable dimension %%i", CudaNdarray_HOST_DIMS(%(name)s)[%(i)s], %(i)s);
PyErr_Format(PyExc_RuntimeError,
"c_extract: Some CudaNdarray has dim %%i on broadcastable dimension %%i",
CudaNdarray_HOST_DIMS(%(name)s)[%(i)s], %(i)s);
%(name)s = NULL;
%(name)s = NULL;
%(fail)s;
%(fail)s;
}
}
...
@@ -309,7 +313,9 @@ class CudaNdarrayType(Type):
...
@@ -309,7 +313,9 @@ class CudaNdarrayType(Type):
if (CudaNdarray_HOST_STRIDES(%(name)s)[%(i)s])
if (CudaNdarray_HOST_STRIDES(%(name)s)[%(i)s])
{
{
//std::cerr << "c_extract bad stride detected...\\n";
//std::cerr << "c_extract bad stride detected...\\n";
PyErr_Format(PyExc_RuntimeError, "Some CudaNdarray has a nonzero stride %%i on a broadcastable dimension %%i", CudaNdarray_HOST_STRIDES(%(name)s)[%(i)s], %(i)s);
PyErr_Format(PyExc_RuntimeError,
"c_extract: Some CudaNdarray has a nonzero stride %%i on a broadcastable dimension %%i",