提交 bb9adf82 authored 作者: wuaalb's avatar wuaalb

Changed printf with %zd specifier to %llu for portability (MSVC2013)

上级 662ea98e
...@@ -142,8 +142,8 @@ void * device_malloc(size_t size, int verbose) ...@@ -142,8 +142,8 @@ void * device_malloc(size_t size, int verbose)
status = cnmemMalloc(&rval, size, NULL); status = cnmemMalloc(&rval, size, NULL);
if(status != CNMEM_STATUS_SUCCESS) { if(status != CNMEM_STATUS_SUCCESS) {
PyErr_Format(PyExc_MemoryError, PyErr_Format(PyExc_MemoryError,
"Error allocating %zd bytes of device memory (%s).", "Error allocating %llu bytes of device memory (%s).",
size, cnmemGetErrorString(status)); (unsigned long long)size, cnmemGetErrorString(status));
return NULL; return NULL;
} }
} }
...@@ -168,21 +168,21 @@ void * device_malloc(size_t size, int verbose) ...@@ -168,21 +168,21 @@ void * device_malloc(size_t size, int verbose)
} }
#if COMPUTE_GPU_MEM_USED #if COMPUTE_GPU_MEM_USED
fprintf(stderr, fprintf(stderr,
"Error allocating %zd bytes of device memory (%s)." "Error allocating %llu bytes of device memory (%s)."
" new total bytes allocated: %d." " new total bytes allocated: %llu."
" Driver report %zd bytes free and %zd bytes total \n", " Driver report %llu bytes free and %llu bytes total \n",
size, cudaGetErrorString(err), _allocated_size, (unsigned long long)size, cudaGetErrorString(err), (unsigned long long)_allocated_size,
free, total); (unsigned long long)free, (unsigned long long)total);
#else #else
fprintf(stderr, fprintf(stderr,
"Error allocating %zd bytes of device memory (%s)." "Error allocating %llu bytes of device memory (%s)."
" Driver report %zd bytes free and %zd bytes total \n", " Driver report %llu bytes free and %llu bytes total \n",
size, cudaGetErrorString(err), free, total); (unsigned long long)size, cudaGetErrorString(err), (unsigned long long)free, (unsigned long long)total);
#endif #endif
} }
PyErr_Format(PyExc_MemoryError, PyErr_Format(PyExc_MemoryError,
"Error allocating %zd bytes of device memory (%s).", "Error allocating %llu bytes of device memory (%s).",
size, cudaGetErrorString(err)); (unsigned long long)size, cudaGetErrorString(err));
return NULL; return NULL;
} }
} }
...@@ -310,17 +310,17 @@ int device_free(void *ptr) ...@@ -310,17 +310,17 @@ int device_free(void *ptr)
} }
assert(i<TABLE_SIZE); assert(i<TABLE_SIZE);
fprintf(stderr, fprintf(stderr,
"Error freeing device pointer %p (%s) of size %d. %zd byte already allocated." "Error freeing device pointer %p (%s) of size %llu. %llu byte already allocated."
" Driver report %zd bytes free and %zd bytes total \n", " Driver report %llu bytes free and %llu bytes total \n",
ptr, cudaGetErrorString(err), ptr, cudaGetErrorString(err),
_alloc_size_table[i].size, _allocated_size, free, total); (unsigned long long)_alloc_size_table[i].size, (unsigned long long)_allocated_size, (unsigned long long)free, (unsigned long long)total);
} }
#else #else
fprintf(stderr, fprintf(stderr,
"Error freeing device pointer %p (%s)." "Error freeing device pointer %p (%s)."
" Driver report %zd bytes free and %zd bytes total \n", " Driver report %llu bytes free and %llu bytes total \n",
ptr, ptr,
cudaGetErrorString(err), free, total); cudaGetErrorString(err), (unsigned long long)free, (unsigned long long)total);
#endif #endif
if (NULL != PyErr_Occurred()){ if (NULL != PyErr_Occurred()){
fprintf(stderr, fprintf(stderr,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论