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
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,
- https://www.mathworks.com/help/gpucoder/gs/gpu-code-generation-the-mandelbrot-set.html
- https://www.mathworks.com/help/gpucoder/ref/coder.gpucodeconfig.html
- https://www.mathworks.com/help/coder/ref/codegen.html#d126e4648
Hope this is helpful.
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에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!