Can I optimize buffer usage in generated code for input and output arguments of a subsystem with Embedded Coder R2024a?

조회 수: 6 (최근 30일)

I have a large Simulink model that contains numerous subsystems and model references. The way my model works is that it modifies a large struct type (defined as a Simulink Bus) in place as it passes through components of my model. I am using this model to produce production C++ code using Embedded Coder. Given the scale of my model, and the large memory footprint of the struct type, I do not want reusable functions in my code which copies the struct to a new buffer for output. I want the function to optimize its buffer usage by modifying one struct variable in place. 
This would effectively change the function signature for my reusable function from something like:

void exampleFunction(structType *structIn, structType *structOut) { ... }
to something like: 

void exampleFunction(structType *structInAndOut) { ... }
where one argument is modified in place and treated as output. 
I have done this with Model References in my model.
Is this possible for reusable functions of a subsystem? 

채택된 답변

MathWorks Support Team
MathWorks Support Team 2025년 8월 27일
As of MATLAB R2024b, this is not possible for a subsystem. 
The development team is aware of this limitation and will consider adding this as a feature in a future release or update.
Depending on the model, there are workarounds available that may be applicable. Different types of buffer reuse optimizations are available for Model References and entry point functions, Simulink Signals, and S-Functions. Please refer to the MathWorks documentation linked above to identify if these workflows can be applied to the model in question. 

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by