GPU coder,CUDA in MATLAB

4 次查看(过去 30 天)
Mohammadreza
Mohammadreza 2022-10-25
编辑: Ram Kokku 2022-10-26
Hi All
I have used GPU coder and convert m file to CUDA code. But I could not run CUDA code.
Could you please help me how can I run it?

回答(1 个)

Ram Kokku
Ram Kokku 2022-10-25
Thanks for reaching out. Can you say more about where you want to run the generated code, with in MATLAB or outside MATLAB?
If you want to call generated CUDA code from MATLAB, you can use MEX to so. Here is an example for this : https://www.mathworks.com/help/gpucoder/gs/gpu-code-generation-the-mandelbrot-set.html
If you want to run the generated CUDA code outside MATLAB, you can generate a exe from GPU Coder by setting BuildType. Note that you may want to modify the generated main() function to your needs. This document points to steps to do that for C/C++. but steps are similar for CUDA as well. https://www.mathworks.com/help/coder/ug/standalone-c-c-executables-from-matlab-code.html.
  2 个评论
Mohammadreza
Mohammadreza 2022-10-25
Hi,
As you beter than me the main problem of m file is speed run time.
I want to convert mfile to CUDA file for speed up.
I want to run cuda code on GPU in MATLAB.
Best Regards,
Mohammadreza
Ram Kokku
Ram Kokku 2022-10-25
编辑:Ram Kokku 2022-10-26
Hi Mohammadreza,
thanks for the response. Generating MEX and calling from MATLAB makes sense for your use case. please find the examples here: https://www.mathworks.com/help/gpucoder/examples.html?s_tid=CRUX_topnav

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 GPU Computing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by