Integrating cuda and matlab mex under OS X (and/or linux)

Hi,
I have installed cuda 4.1 on my MacBook pro. Does anybody have an idea on how to integrate matlab’s mex files and cuda?

To be more precise, I want to know how to compile a mex file containing a cuda kernel under OS X (and/or linux).

I’ve googled a bit and found two approaches.
The approach found here converts a .cu file to a .cpp file using nvcc and subsequently uses the mex compiler
to compile the .cpp file. Unfortunately this method didn’t work for me and produced a whole bunch of errors while compiling the generated .cpp file.

Another method which uses “nvmex”(a modified version of mex which supports .cu files) can be found here. However this seems to be outdated
and unsupported with newer versions of cuda. Infact I was unable to find the download location of the “nvmex” file that the solution refers to.

Any idea on how to accomplish this with latest versions of cuda?

Thanks,
Sachintha.

See my post here, explaining the latest state of CUDA/MEX/MATLAB integration.

Go straight to object files instead of cpp.

From inside Matlab:

!nvcc -c my.cu -Xcompiler -fPIC -I /usr/local/matlab/extern/include

mex my.o -L /usr/local/cuda/lib64 -lcudart -lcufft ( or if you are on a 32 bit system /usr/local/cuda/lib)