// 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 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,"Error allocating %li bytes of device memory (%s).",(long)size,cudaGetErrorString(err));
PyErr_Format(PyExc_MemoryError,
"Error allocating %li bytes of device memory (%s).",(long)size,cudaGetErrorString(err));
returnNULL;
returnNULL;
}
}
_outstanding_mallocs[0]+=(rval!=NULL);
_outstanding_mallocs[0]+=(rval!=NULL);
#if COMPUTE_GPU_MEM_USED
#if COMPUTE_GPU_MEM_USED
for(inti=0;i<TABLE_SIZE;i++){
for(inti=0;i<TABLE_SIZE;i++){
if(NULL==_alloc_size_table[i].ptr){
if(NULL==_alloc_size_table[i].ptr){
_alloc_size_table[i].ptr=rval;
_alloc_size_table[i].ptr=rval;
_alloc_size_table[i].size=size;
_alloc_size_table[i].size=size;
break;
break;
}
}
}
}
_allocated_size+=size;
_allocated_size+=size;
#endif
#endif
//fprintf(stderr,
//fprintf(stderr, "allocated %li bytes of device memory (%s). new total bytes allocated: %d. ptr: %p\n", (long)size, cudaGetErrorString(err),_allocated_size,rval);
//"allocated %li bytes of device memory (%s). new total bytes allocated: %d. ptr: %p\n",