Unnecessary copies in code when using nested non-virtual buses with atomic subsystems
13 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm using Matlab/Simulink r2017B with Embedded Coder, to generate C code of my model. In my model, I have nested atomic subsystems, packaged as 'Reusable Function', which emits nonvirtual bus signals. Going deep to surface, those nonvirtual bus signals at the same level, combined into another nonvirtual bus signal.
The problem is, when I look to the generated code, in each subsystem function that have nonvirtual bus output with nested buses, there are unnecessary copies occured. For example:
void subsys_inner(uint32 rtu_in1, uint32 rtu_in2, Out_Bus* rty_out, /* some other args like block struct and DWorks */)
{
uint32 rtb_outsig1;
uint32 rtb_outsig2;
rtb_outsig1 = rtu_in1 + 1;
rtb_outsig2 = rtu_in2 + 1;
/* It uses local signal copies and assigns to output instead of using rty_out
inside code directly
*/
rty_out->outsig1 = rtb_outsig1;
rty_out->outsig2 = rtb_outsig2;
}
void subsys_outer(Outer_Bus* rty_out, /* some other args like block struct and DWorks */)
{
/* It creates a local copy of the nested bus */
Out_Bus rtb_Out_Bus_signal;
subsys_inner(1, 2, &rtb_Out_Bus_signal ...);
/* Again it made a deep copy instead of using rty_out->outbus directly in the above call */
rty_out->outbus = rtb_Out_Bus_signal;
}
That code is something I've made up right now to express the thing briefly, not a direct output of Embedded Coder.
I tried a lot of configuration options in Model Configuration pane but could not succeed to eliminate those copies. Is there any way to eliminate those copies?
Thanks in advance.
0 Commenti
Risposte (1)
Mark McBroom
il 29 Set 2025 alle 1:07
Each release of Embedded Coder incluces improved optimization, and removing data copies is one of the most common improvements. Do you have access to a newer MATLAB release?
Thanks.
Mark.
Vedere anche
Categorie
Scopri di più su Deployment, Integration, and Supported Hardware in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!