I have this code in cuda with c++:
// 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);
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);
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.
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.
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
PS You posted way too much source code, please try to minimize your examples.
Can't you define both
unsigned int memory_total;
unsigned int memory_free;
as
size_t memory_total;
size_t memory_free;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.