// Clear the error flag, cudaMalloc doesn't do it.
// Currently this returns the same thing as err, but if in future
// it returns something else I still don't see why we should ignore
// it. All we want to do here is reset the flag.
cudaGetLastError();
#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
...
@@ -86,6 +91,11 @@ int device_free(void *ptr)
...
@@ -86,6 +91,11 @@ int device_free(void *ptr)
cudaError_terr=cudaFree(ptr);
cudaError_terr=cudaFree(ptr);
if(cudaSuccess!=err)
if(cudaSuccess!=err)
{
{
// Clear the error flag, cudaFree doesn't do it.
// Currently this returns the same thing as err, but if in future
// it returns something else I still don't see why we should ignore