Reduction of Copy Operations
Article 3 of 3: Model Optimization with emmtrix”
February 18, 2025
To conclude our series on optimizing code size in the Simulink workflow, we will show how variable coalescing can be used to reduce copy operations and memory consumption.
The goal of this transformation is to reuse variables in different places to avoid unnecessary copy operations and reduce the number of variables that consume memory. The transformation uses variable liveness analysis to identify code segments where variable accesses to one variable could be replaced by accesses to another variable. Here a simple example.
Variable b is unnecessary and by replacing accesses to it with a, a potential copy operation and memory required for b can be saved.
Used in a workflow with C code generated from Simulink models, the emmtrix tools can provide the developer information on where it is beneficial to reuse signals and names and where other structures of the subsystem are feasible.
Analysis of actual production code has shown the potential to reduce code size by up to 5% for individual modules.
In this series, we’ve demonstrated how the emmtrix Performance Estimator supports common automotive Simulink workflows by reducing code size and improving performance. From signal vectorization to redundancy elimination and variable coalescing, these techniques unlock significant memory and runtime efficiencies, making your models leaner and more effective.
Ready to optimize your code? Visit our ePE webpage or reach out to Rainer Heim directly for technical inquiries: 📞 +49 170 447 2986, 📧 rainer.heim@emmtrix.com