GPU Coder Build Error

According to official documentation I run a GPUcoder example mandelbrot_count
This is official function,but get error in Check for Run-Time Issues step,
function count = mandelbrot_count(maxIterations,xGrid,yGrid) %#codegen
% Add kernelfun pragma to trigger kernel creation
coder.gpu.kernelfun;
% mandelbrot computation
z0 = xGrid + 1i*yGrid;
count = ones(size(z0));
z = z0;
for n = 0:maxIterations
z = z.*z + z0;
inside = abs(z)<=2;
count = count + inside;
end
count = log(count);
this is My device information, how Can I set the correct setting in this,Thank you

回答(2 个)

Infinite_king
Infinite_king 2023-12-13
编辑:Infinite_king 2023-12-13
Hi ding barry,
I understand that you are encountering an error while generating CUDA code for the 'mandelbrot_count' function using GPU Coder.
The cause of the error was incorrect code generation configuration settings. To generate the code without any errors, follow the steps below.
  • Create a GPU code generation configuration object.
% For mex
cfg = coder.gpuConfig('MEX');
% For static library
cfg = coder.gpuConfig('LIB');
% For Dynamic Linked library
cfg = coder.gpuConfig('DLL');
% For executable
cfg = coder.gpuConfig('EXE');
  • Enable or disable required libraries.
% set the value to 'false' to disable
% Enabling Nvidia cuFFT
cfg.GpuConfig.EnableCUFFT = true;
% Enabling Nvida cuBLAS
cfg.GpuConfig.EnableCUBLAS = true;
  • Set the required Compiler flags,
% For example
cfg.GpuConfig.CompilerFlags = '--fmad=false';
  • Generate the code using ‘codegen’ command
% arg1, arg2 … are the arguments
codegen mandelbrot_count -args {arg1,arg2,arg3} -nargout 1
  • You change the configuration settings of code generation in the app itself. In the ‘Check for Run-Time Issues’ screen, on the top right, you can find the ‘settings’ option
  • In the settings select GPU Code section, in which you can change the configuration settings.
For more information, refer the following MATLAB documentation,
  1. https://www.mathworks.com/help/gpucoder/gs/gpu-code-generation-the-mandelbrot-set.html
  2. https://www.mathworks.com/help/gpucoder/ref/coder.gpucodeconfig.html
  3. https://www.mathworks.com/help/coder/ref/codegen.html#d126e4648
Hope this is helpful.
Ram Kokku
Ram Kokku 2023-12-17

1 个投票

@ding barry - Looks like you encountered a bug in GPU Coder. I reported this to the team resposible.
Run-time checks is an optional step in code generation. You can skip this step and move on to code generation and verification. that should run just fine.

类别

在 帮助中心 和 File Exchange 中查找有关 Get Started with GPU Coder 的更多信息

提问:

2022-5-16

回答:

2023-12-17

Community Treasure Hunt

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

Start Hunting!

Translated by