Info

この質問は閉じられています。 編集または回答するには再度開いてください。

emlc C code generation error "Unable to apply the reference parameter optimization"

1 回表示 (過去 30 日間)
John
John 2013 年 4 月 15 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have a code base with several M functions I am converting to be included into an existing C code base. I am trying to limit the input by value overhead of large structures so created a glob structure. Some data is input, some output, some are persistent.
I have 2 functions which use this same global structure.
function [glob] = foo_gen
Data = struct('Input',zeros(8,1),'Output',zeros(8,1),'State',zeros(1));
eml.cstructname(Data,'DataStruct_t');
glob = struct('AllData',repmat(Data,3,1));
eml.cstructname(glob,'GlobalStruct_t');
end
function [glob] = foo(glob)
eml.cstructname(glob,'GlobalStruct_t');
eml.cstructname(glob.AllData(1),'DataStruct_t');
glob.AllData(1).Output = glob.AllData(1).Input;
end
I have many difficulties with getting this compile. Sometimes, it errors out that the tpyes do not match or is reused when the foo and foo_gen do not match exactly. It errors out if the foo function encapsulates the eml.cstructnames in an if ~isempty(eml.target) block.
I am using a multiple-entry point emlc invocation: emlc -c -s rtw_config -d ..\M_Code_Release foo -eg {glob} foo_gen
What does the error message "Unable to apply the reference parameter optimization to 'glob' of function 'foo'" mean and how do I fix it. The suggestion is to rewrite the code to not have outputs and inputs with matching names but my real code would be unworkable like that.
  1 件のコメント
John
John 2013 年 4 月 15 日
This is using Matlab 2010.

回答 (1 件)

Fred Smith
Fred Smith 2013 年 4 月 15 日
This sounds like a bug. What version of MATLAB are you using?
Your example worked in the latest version of MATLAB after upgrading to the latest syntax:
.m:
function [glob] = foo(glob)
coder.cstructname(glob,'GlobalStruct_t');
coder.cstructname(glob.AllData(1),'DataStruct_t');
glob.AllData(1).Output = glob.AllData(1).Input;
end
foo_gen.m:
function [glob] = foo_gen
Data = struct('Input',zeros(8,1),'Output',zeros(8,1),'State',zeros(1));
coder.cstructname(Data,'DataStruct_t');
glob = struct('AllData',repmat(Data,3,1));
coder.cstructname(glob,'GlobalStruct_t');
end
doit.m:
glob = foo_gen;
codegen -c -config:lib -d ..\M_Code_Release foo -args {glob} foo_gen
  1 件のコメント
John
John 2013 年 4 月 15 日
See Comment added to original question

製品

Community Treasure Hunt

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

Start Hunting!

Translated by