Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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

1 vue (au cours des 30 derniers jours)
JM
JM le 18 Mar 2019
Clôturé : MATLAB Answer Bot le 20 Août 2021
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?

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by