Error compiling CUDA code in Matlab R2010b

Hi all,

I’ve been trying to run in Matlab a program written in CUDA. I managed to solve some problems but ended up with the following errors:

nvmex -f nvmexopts.bat knn_cublas_without_indexes.cu -IC:\CUDA\include -LC:\CUDA\lib\x64 -lcufft -lcudart -lcuda -lcublas -D_CRT_SECURE_NO_DEPRECATE
abdelali target arch: win64
knn_cublas_without_indexes.cu
C:/Program Files/MATLAB/R2010b/bin/knn_cublas_without_indexes.cu(244): error: argument of type “unsigned int *” is incompatible with parameter of type “size_t *”

C:/Program Files/MATLAB/R2010b/bin/knn_cublas_without_indexes.cu(244): error: argument of type “unsigned int *” is incompatible with parameter of type “size_t *”

C:/Program Files/MATLAB/R2010b/bin/knn_cublas_without_indexes.cu(249): error: more than one instance of overloaded function “min” matches the argument list:
function “min(int, int)”
function “min(int, unsigned int)”
function “min(unsigned long long, unsigned long long)”
function “min(long long, unsigned long long)”
argument types are: (int, unsigned long long)

C:/Program Files/MATLAB/R2010b/bin/knn_cublas_without_indexes.cu(284): error: more than one instance of overloaded function “min” matches the argument list:
function “min(int, int)”
function “min(unsigned int, int)”
function “min(unsigned long long, unsigned long long)”
function “min(unsigned long long, long long)”
argument types are: (size_t, int)

4 errors detected in the compilation of “C:/Users/JOOPED~1/AppData/Local/Temp/tmpxft_00001364_00000000-6_knn_cublas_without_indexes.cpp1.ii”.

C:\PROGRA~1\MATLAB\R2010B\BIN\NVMEX.PL: Error: Compile of ‘knn_cublas_without_indexes.cu’ failed.

??? Error using ==> nvmex at 206
Unable to complete successfully.

My system is Windows 7 Professional x64, Matlab R2010b x64.
I can’t figure out the problem as I am not very experienced with CUDA, does anyone know how to solve this? I’ll appreciate the help.

Hi,

the main reason why you don’t get help is that you don’t provide anything to work with. The errors you get show that you have problems with your variable types. To determine whether you should cast them to some other type or if its smarter to change the actual types of your inputs it is necessary to inspect your code.

What I see is:

line 244: here you are giving a pointer of type unsigned int as argument where a pointer to size_t is expected. Depending on your system it might be possible to simply cast your pointer to a size_t pointer. Maybe you can also just make your unsigned int * a size_t , if you don’t run into problems elsewhere in this case. Or you might add another variable of type size_t and use this one as intermediate value to have the corret types everywhere without casting.

line 249 and line 284: you are calling some function min() with arguments (int, unsigned long long) or (size_t, int). The compiler tries to map it to one of the existing min functions. Problem is that none of the functions arguments list matches the given arguments. As the Compiler cannot decide which one to use, it gives an error instead. Solutions are either manually casting your arguments to one of the accepted input formats or writing your own min() function for your argument list. You might even be able to solve this by using a macro instead of a function call.

#ifndef max

 #define max(a,b) (((a) > (b)) ? (a) : (b))

#endif

#ifndef min

 #define min(a,b) (((a) < (b)) ? (a) : (b))

#endif