The extrinsic function 'horzcat' is not available for standalone code generation. It must be eliminated for stand-alone code to be generated. It could not be eliminated becaus

조회 수: 3 (최근 30일)
Thanks Jan for your answer.
My mfile is now converted to MEX but can not generate a C/C++ sourse code using GPU Coder APP, giving the following error.
"The extrinsic function 'horzcat' is not available for standalone code generation. It must be eliminated for stand-alone code to be generated. It could not be eliminated because its outputs appear to influence the calling function. Fix this error by not using 'horzcat' or by ensuring that its outputs are unused."
I looked it up in myfile.cu and commmented out //horzcats but no success.
Any ideas?
  댓글 수: 3
Ram Kokku
Ram Kokku 2022년 12월 11일
@Fatemeh - horzcat is supported for code generation. here the doc for it https://www.mathworks.com/help//matlab/ref/double.horzcat.html.
Are you using coder.extrensic function anywhere? would you be able to share the problematic code snippet?

댓글을 달려면 로그인하십시오.

채택된 답변

Hariprasad Ravishankar
Hariprasad Ravishankar 2022년 12월 13일
Its very likely that you have a coder.extrinsic function defined on horzcat as follows:
function out = foo(a,b)
coder.extrinsic('horzcat');
out = horzcat(a,b);
end
>> codegen -args {ones(5,4), ones(5,4)} foo -config:dll
The extrinsic function 'horzcat' is not available for standalone code generation. It must be eliminated for stand-alone code to be
generated. It could not be eliminated because its outputs appear to influence the calling function. Fix this error by not using
'horzcat' or by ensuring that its outputs are unused.
For MEX code generation, coder.extrinsic calls back into MATLAB runtime to compute the horzcat function. However, for standalone code generation, we don't have MATLAB to call back into, so we see this error.
As my colleague Ram mentioned, since horzcat is supported for code generation, you can remove the coder.extrinsic pragma.
function out = foo(a,b)
out = horzcat(a,b);
end
>> codegen -args {ones(5,4), ones(5,4)} foo -config:dll
Code generation successful.
  댓글 수: 4
Fatemeh Kalantari
Fatemeh Kalantari 2022년 12월 15일
Yes, It worked apparently the code showing the timing for mex file generated from mfile is:
tic;myfile().mex;toc
from myfile.m we will generate myfile.mex
Still not clarified on how to generate the _gpu extension using GPU Coder app?
Ram Kokku
Ram Kokku 2022년 12월 15일
Hi Fatemeh,
MATLAB Coder and GPU Coder both generate same extension for MEX files, i.e mexa64 (or something similar based on your platform). if you want to confirm if the MEX was generated for GPU or CPU, take a look at the generated files located in codegen/mex/<your design name>. For GPU Coder, you should find .cu files in this directory.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2022년 12월 10일
이동: Image Analyst 2022년 12월 10일
Does the same problem occur if you use [] notation?
horzcat(a,b)
[a,b]
should be the same. Maybe it only allows [] with constants?
You could also try
cat(2,a,b)

카테고리

Help CenterFile 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!

Translated by