简体   繁体   English

“unsigned int *”类型的参数与“size_t *”类型的参数不兼容

[英]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? 我不知道这个错误是什么,你对此有什么想法吗?

Change the following lines: 更改以下行:

unsigned int memory_total;
unsigned int memory_free;

to: 至:

size_t memory_total;
size_t memory_free;

You're probably trying an old code that was initially built before CUDA 3.0. 您可能正在尝试在CUDA 3.0之前最初构建的旧代码。

Source 资源

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_tunsigned 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_freememory_total的类型更改为size_t或使用临时size_t变量,然后将值复制到memory_freememory_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.

相关问题 推导非类型模板参数Unsigned Int / size_t - Deducing Non-Type Template Argument Unsigned Int / size_t “int”类型的参数与“int*”类型的参数不兼容 - argument of type “int” incompatible with parameter of type “int*” 变量t被分配为负值时,类型为size_t的变量t的实际值是多少?(可以是unsigned int而不是size_t) - what is actual value of variable t of type size_t when it is assigned negative value?(can be unsigned int instead of size_t) 类型为“ int”的参数与类型为“ int *”的参数不兼容 - Argument of type “int” is incompatible with parameter of type “int *” 类型“ int”的参数与参数类型“ int **”不兼容 - argument of type “int” is incompatible with parameter type “int **” 类型“int”的参数与类型“int”的参数不兼容 - argument of type “int” incompatible with parameter of type “int” int(*)[] 类型的参数与“int**”类型的参数不兼容 - Argument of type int(*)[] is incompatible with parameter of type “int**” “ int”类型的参数与“ char”类型的参数不兼容 - Argument of type 'int' is incompatible with parameter of type 'char' 错误:参数类型int与参数类型不兼容 - ERROR: argument type int incompatible for parameter type “int”类型的参数与“HTREEITEM”类型的参数不兼容 - argument of type “int” is incompatible with parameter of type “HTREEITEM”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM