From: mklcst Costola on
Hi everybody, I have a problem compiling CUDA example files.

My pc has:
Vista 64
Matlab r2009b
Microsoft Visual Studio 2008 express

__________________________________________________________
>> mex fft2_cuda.c -IC:\CUDA\include -LC:\CUDA\lib -lcudart -lcufft
Creating library C:\USERS\COMPUT~1\APPDATA\LOCAL\TEMP\MEX_MD~1\templib.x and object C:\USERS\COMPUT~1\APPDATA\LOCAL\TEMP\MEX_MD~1\templib.exp
fft2_cuda.obj : error LNK2019: unresolved external symbol cudaFree referenced in function mexFunction
fft2_cuda.obj : error LNK2019: unresolved external symbol cufftDestroy referenced in function mexFunction
fft2_cuda.obj : error LNK2019: unresolved external symbol cufftExecC2C referenced in function mexFunction
fft2_cuda.obj : error LNK2019: unresolved external symbol cufftPlan2d referenced in function mexFunction
fft2_cuda.obj : error LNK2019: unresolved external symbol cudaMemcpy referenced in function mexFunction
fft2_cuda.obj : error LNK2019: unresolved external symbol cudaMalloc referenced in function mexFunction
fft2_cuda.mexw64 : fatal error LNK1120: 6 unresolved externals

C:\PROGRA~1\MATLAB\R2009B\BIN\MEX.PL: Error: Link of 'fft2_cuda.mexw64' failed.

??? Error using ==> mex at 221
Unable to complete successfully.
From: Oliver Woodford on
"mklcst Costola" <mklcst(a)gmail.com> wrote in message <h9sdd8$5kd$1(a)fred.mathworks.com>...
> Hi everybody, I have a problem compiling CUDA example files.
>
> My pc has:
> Vista 64
> Matlab r2009b
> Microsoft Visual Studio 2008 express
>
> __________________________________________________________
> >> mex fft2_cuda.c -IC:\CUDA\include -LC:\CUDA\lib -lcudart -lcufft
> Creating library C:\USERS\COMPUT~1\APPDATA\LOCAL\TEMP\MEX_MD~1\templib.x and object C:\USERS\COMPUT~1\APPDATA\LOCAL\TEMP\MEX_MD~1\templib.exp
> fft2_cuda.obj : error LNK2019: unresolved external symbol cudaFree referenced in function mexFunction
> fft2_cuda.obj : error LNK2019: unresolved external symbol cufftDestroy referenced in function mexFunction
> fft2_cuda.obj : error LNK2019: unresolved external symbol cufftExecC2C referenced in function mexFunction
> fft2_cuda.obj : error LNK2019: unresolved external symbol cufftPlan2d referenced in function mexFunction
> fft2_cuda.obj : error LNK2019: unresolved external symbol cudaMemcpy referenced in function mexFunction
> fft2_cuda.obj : error LNK2019: unresolved external symbol cudaMalloc referenced in function mexFunction
> fft2_cuda.mexw64 : fatal error LNK1120: 6 unresolved externals
>
> C:\PROGRA~1\MATLAB\R2009B\BIN\MEX.PL: Error: Link of 'fft2_cuda.mexw64' failed.
>
> ??? Error using ==> mex at 221
> Unable to complete successfully.

Does running the following function:
http://www.mathworks.com/matlabcentral/fileexchange/25314
then calling cuda_mex in place of mex work?

Oliver
From: mklcst Costola on
Sorry Oliver, how does it work?
From: mklcst Costola on
"mklcst Costola" <mklcst(a)gmail.com> wrote in message <h9sj79$8gm$1(a)fred.mathworks.com>...
> Sorry Oliver, how does it work?

I get this error:

Note that only Visual Studio compilers are supported.
Creating cudamexopts.bat based on mexopts.bat...
Creating cuda_mex.pl based on mex.pl...
??? Error using ==> fprintf
Invalid file identifier. Use fopen to generate a valid file identifier.

Error in ==> setup_cuda_mex at 73
fprintf(fid_cuda_mex, '%s', line);
From: Oliver Woodford on
"mklcst Costola" wrote:
> > Sorry Oliver, how does it work?
>
> I get this error:
>
> Note that only Visual Studio compilers are supported.
> Creating cudamexopts.bat based on mexopts.bat...
> Creating cuda_mex.pl based on mex.pl...
> ??? Error using ==> fprintf
> Invalid file identifier. Use fopen to generate a valid file identifier.
>
> Error in ==> setup_cuda_mex at 73
> fprintf(fid_cuda_mex, '%s', line);

You'd need to ask the author what's wrong there.

Alternatively you could try the approach I outline here:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/261866
It should work on Windows as well. You'll need to iron out any issues yourself, though.

Oliver