GPU Coder Build Error

1 view (last 30 days)
ding barry
ding barry on 16 May 2022
Answered: Ram Kokku on 17 Dec 2023
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

Answers (2)

Infinite_king
Infinite_king on 13 Dec 2023
Edited: Infinite_king on 13 Dec 2023
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 on 17 Dec 2023
@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.

Categories

Find more on Get Started with GPU Coder in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!