我用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);
Run Code Online (Sandbox Code Playgroud)
编译时遇到错误:cuMemGetInfo(&memory_free,&memory_total);
错误是:
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
Run Code Online (Sandbox Code Playgroud)
311是以下行: cuMemGetInfo(&memory_free, &memory_total);
我不知道这个错误是什么,你对此有什么想法吗?
更改以下行:
unsigned int memory_total;
unsigned int memory_free;
Run Code Online (Sandbox Code Playgroud)
至:
size_t memory_total;
size_t memory_free;
Run Code Online (Sandbox Code Playgroud)
您可能正在尝试在CUDA 3.0之前最初构建的旧代码.
错误说明size_t
并且unsigned int
是不同的类型,因此您不能将指针传递给期望另一个的函数.
要么改变的类型memory_free
,并memory_total
以size_t
或使用临时size_t
变量,然后将值复制到memory_free
和memory_total
PS你发布了太多的源代码,请尽量减少你的例子.