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

5 次查看(过去 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
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