提交 f9ae7270 authored 作者: Frederic Bastien's avatar Frederic Bastien

added a disabled macro in cuda_ndarray that allow to memset all new allocated memory on the gpu.

上级 5e010a37
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
//If true, when there is a gpu malloc or free error, we print the size of allocated memory on the device. //If true, when there is a gpu malloc or free error, we print the size of allocated memory on the device.
#define COMPUTE_GPU_MEM_USED 0 #define COMPUTE_GPU_MEM_USED 0
//If true, we fill with NAN allocated device memory.
#define ALLOC_MEMSET 0
///////////////////////// /////////////////////////
// Alloc and Free // Alloc and Free
///////////////////////// /////////////////////////
...@@ -55,7 +58,13 @@ void * device_malloc(size_t size) ...@@ -55,7 +58,13 @@ void * device_malloc(size_t size)
} }
_allocated_size += size; _allocated_size += size;
#endif #endif
return rval; //fprintf(stderr, "allocated %li bytes of device memory (%s). %d already allocated, ptr: %p\n", (long)size, cudaGetErrorString(err),_allocated_size,rval);
if(ALLOC_MEMSET){
//We init them to nan to make sure we catch more debug case.
cudaMemset(rval, 0xFF, size);
//printf("MEMSET\n");
} return rval;
} }
int device_free(void *ptr) int device_free(void *ptr)
{ {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论