Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

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

2 visualizaciones (últimos 30 días)
JM
JM el 18 de Mzo. de 2019
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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?

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by