开发者

Get started with CUDA in Matlab

开发者 https://www.devze.com 2023-02-27 06:45 出处:网络
Hey there, I need to get started to Cuda in Matlab. As I need additional functions than provided from matlab, I need to write my own c++ code, e.g. I want to run my program on 1..N GPU-processors and

Hey there, I need to get started to Cuda in Matlab. As I need additional functions than provided from matlab, I need to write my own c++ code, e.g. I want to run my program on 1..N GPU-processors and compare the results to calculate the speedup, which is not supported by Matlab itself (as Matlab always optimizes itself to use all processors).

Now I wonder how to get started best. I already read a lot of papers, but I still wonder for example, what those files are all about:

.cu .cubin .ptx .mex

So which way do I need to go? Writing my code to a .cu file and than compiling it (which tool to use?

My computer is:

Q9550 with GTX460, Win7 x64, Matlab R2010b x64, Visual Express C++ 2008 (free -> 32bit version), Cuda Toolkit 3.2 (64bit), Latest Nvidia Driver and GPU Programming SDK 3.2.16_win_64

How to get on? When I try to open one of the examples out of the GPU Programming SDK, e.g. the file vectorAdd_vc90.vcproj ouf ot C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\C\src\vectorAdd

I get

"The following XML parsing-error occured:

File: C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\C\src\vectorAdd\vectorAdd_vc90.vcproj Row: 22 Column: 4 Fehlermeldung: The user build-file "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\VCProjectDefaults\NvCudaRuntimeApi.rules" wasnt found or couldn't be loaded The file "C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\C\src\vectorAdd\vectorAdd_vc90.vcproj" could开发者_JS百科n't be loaded"

When I just open the vectorAdd.cu I don't find any way to compile it to run it in Matlab. Perhaps it would also be possible to just work completely without Visual Studio, so that I write my code in Notepad++ for example and compile it myself?

Thanks a lot in advance guys!


If you have access to Parallel Computing Toolbox, you can use the GPU directly using GPUArrays. You can also more easily integrate your own hand-written CUDA code using the parallel.gpu.CUDAKernel object


If the parallel toolbox isn't available, you can still use the mexFunction capability to use the GPU's

http://www.mathworks.com.au/help/distcomp/create-and-run-mex-files-containing-cuda-code.html

I dont think this is available for earlier versions than 2013a. In this case, you can write the mexfunction entry point and include the cuda function calls to pass the memory to and from the device

http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/docs/online/

0

精彩评论

暂无评论...
验证码 换一张
取 消