方式来处理在linux中编写CUDA + MEX代码? [英] way to handle to write CUDA+MEX code in linux?
问题描述
我尝试编写matlab mex代码与Cuda集成,但它是足够困难的编译和调试周围。有没有更好的方法来代码和测试?我在Matlab 2012b。
I try to write matlab mex code with Cuda integrated but it is just hard enough to compile and debug all around. Is there any better approach to code and test? I am on Matlab 2012b.
目前我在sublime编写代码,然后在matlab编译,但我也是新手CUDA,因此它只是很难编码没有立即看到结果。
Currently I am writing code in sublime then compile it on matlab but I am also newbie at CUDA as well thus it is just hard to code it without seeing the result instantly.
推荐答案
Robert Crovella的评论很有意思。
The comment by Robert Crovella is interesting.
我只是想提到我用CUDA指令编译mex文件的方式(它也适用于不同版本的MATLAB)。
I just wanted to mention the way I was used to compile mex file with CUDA instructions (and which works also on different versions of MATLAB).
1)通过 nvcc
编译并通过命令转换C ++代码中的源代码
1) Compile by nvcc
and transform the source code in C++ code by the command
system(sprintf('nvcc -I"%s/extern/include" -cuda "mex-fun.cu" -output-file "mexfun.cpp"', matlabroot));
2)通过
mex -I/opt/cuda/include -L/opt/cuda/lib -lcudart mex-fun.cpp
这最初是在 MATLAB新闻阅读器第页。
这篇关于方式来处理在linux中编写CUDA + MEX代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!