[英]argument of type “unsigned int *” is incompatible with parameter of type “size_t *”
I have this code in cuda with c++: 我用c ++在cuda中有这个代码:
// Variables
float *query_dev;
float *ref_dev;
float *dist_dev;
int *ind_dev;
cudaArray *ref_array;
cudaError_t result;
size_t query_pitch;
size_t query_pitch_in_bytes;
size_t ref_pitch;
size_t ref_pitch_in_bytes;
size_t ind_pitch;
size_t ind_pitch_in_bytes;
size_t max_nb_query_traited;
size_t actual_nb_query_width;
unsigned int memory_total;
unsigned int memory_free;
// Check if we can use texture memory for reference points
unsigned int use_texture = ( ref_width*size_of_float<=MAX_TEXTURE_WIDTH_IN_BYTES && height*size_of_float<=MAX_TEXTURE_HEIGHT_IN_BYTES );
// CUDA Initialisation
cuInit(0);
// Check free memory using driver API ; only (MAX_PART_OF_FREE_MEMORY_USED*100)% of memory will be used
CUcontext cuContext;
CUdevice cuDevice=0;
cuCtxCreate(&cuContext, 0, cuDevice);
cuMemGetInfo(&memory_free, &memory_total);
I got an error for compiling at the line: cuMemGetInfo(&memory_free, &memory_total); 编译时遇到错误:cuMemGetInfo(&memory_free,&memory_total);
The errors are: 错误是:
app.cu(311): error: argument of type "unsigned int *" is incompatible with parameter of type "size_t *"
app.cu(311): error: argument of type "unsigned int *" is incompatible with parameter of type "size_t
311 is the line of: cuMemGetInfo(&memory_free, &memory_total);
311是以下行:
cuMemGetInfo(&memory_free, &memory_total);
I have no clue what is this error, do you have any idea about this? 我不知道这个错误是什么,你对此有什么想法吗?
The error says that size_t
and unsigned int
are different types so you can't pass a pointer to one to a function that expects the other. 该错误表明
size_t
和unsigned int
是不同的类型,因此您无法将指针传递给期望另一个的函数。
Either change the types of memory_free
and memory_total
to size_t
or use temporary size_t
variables and then copy the value into memory_free
and memory_total
将
memory_free
和memory_total
的类型更改为size_t
或使用临时size_t
变量,然后将值复制到memory_free
和memory_total
PS You posted way too much source code, please try to minimize your examples. PS你发布了太多的源代码,请尽量减少你的例子。
Can't you define both 你不能两者都定义
unsigned int memory_total;
unsigned int memory_free;
as 如
size_t memory_total;
size_t memory_free;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.