[英]argument of type “unsigned int *” is incompatible with parameter of type “size_t *”
我用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);
編譯時遇到錯誤: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
311是以下行: cuMemGetInfo(&memory_free, &memory_total);
我不知道這個錯誤是什么,你對此有什么想法嗎?
更改以下行:
unsigned int memory_total;
unsigned int memory_free;
至:
size_t memory_total;
size_t memory_free;
您可能正在嘗試在CUDA 3.0之前最初構建的舊代碼。
該錯誤表明size_t
和unsigned int
是不同的類型,因此您無法將指針傳遞給期望另一個的函數。
將memory_free
和memory_total
的類型更改為size_t
或使用臨時size_t
變量,然后將值復制到memory_free
和memory_total
PS你發布了太多的源代碼,請盡量減少你的例子。
你不能兩者都定義
unsigned int memory_total;
unsigned int memory_free;
如
size_t memory_total;
size_t memory_free;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.