Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Prevent codegen from creating matrix copy for use as const* function parameter

조회 수: 5 (최근 30일)
JM
JM 2019년 3월 18일
마감: MATLAB Answer Bot 2021년 8월 20일
Using MATLAB R2018a with MEX code generation I have some troubling preventing from creating unnecessary copies of a value class present in the MATLAB code to be converted into C code.
The code pattern is as follows:
output = cell(P,1)
hugeblockoflogical = false(M,N)
% Fill all of output{:}
for i = 1:P
(code that reads/writes to/from hugeblockoflogical)
% ???
hugeblockoflogical_copy = initheap(hugeblockoflogical)
% Create class from matrix and store in output argument
% ValueClass constructor does NOT modify input argument
output{i} = ValueClass(hugeblockoflogical_copy)
end
At the assignment of output{i} Codegen decides to create a full copy of hugeblockoflogical before passing that copy into the constructor of ValueClass as a const pointer.
From inspecting the generated C code I see no reason why the huge copy should be generated.
Anyone have a suggestion as to why this is happening and how to prevent it?

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by