Knight: Optimizing Code Generation for Simulink Models With Loop Reshaping
- 5 August 2024
- journal article
- research article
- Published by Institute of Electrical and Electronics Engineers (IEEE) in IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems
- Vol. 44 (2) , 444-457
Abstract
Simulink has become a pivotal infrastructure in embedded scenarios, including automotive systems and aerospace designs. To improve the performance of the code generated from Simulink models, state-of-the-art code generators employ various optimization techniques, such as expression folding, variable reuse, and parallelism. However, they struggle to generate efficient code for loop-semantic models which are crucial in substantial data processing tasks. This inefficiency manifests in numerous redundant calculations, such as array calculations and conditional statements. As a result, the performance of the generated code is limited. This article proposes Knight, an efficient code generator for loop-semantic Simulink models with loop reshaping. Knight first parses the Simulink model to extract essential content, such as block functionalities and connections. Knight then identifies blocks with internal states and implements the specific interaction rules to discern those that are state-dependent. For state-dependent blocks, Knight conducts forward inference to obtain their preceding blocks, which influence the internal state calculations. Subsequently, Knight isolates blocks that are optimizable and irrelevant to the internal states. These blocks are strategically relocated outside the loop semantics while preserving critical semantics related to code generation. We implemented and evaluated Knight on benchmark Simulink models across different compilers and architectures. Compared with the state-of-the-art code generators Simulink Embedded Coder, DFSynth, and HCG, the code generated by Knight is $16.58 \times $ faster, $16.89 \times $ faster, and $15.38 \times $ faster in terms of execution duration on average, without incurring additional overhead of memory usage.
Keywords
Funding Information
- National Key Research and Development Project (2022YFB3104000)
- China Postdocoral Science Foundation (BX20230183, 2023M731954)
- NSFC Program (92167101, 62021002, 62372263)
This publication has 29 references indexed in Scilit:
- STCG: State-Aware Test Case Generation for Simulink Models2023
- Optimization and Enhancement of Charging Control System of Electric Vehicle Using MATLAB SIMULINKIOP Conference Series: Materials Science and Engineering, 2021
- Simulating Insulin Infusion Pump Risks by In-Silico Modeling of the Insulin-Glucose Regulatory System2012
- Automatic Control of Atmospheric and Space Flight Vehicles2011
- Hardware-in-the-Loop Simulation of Pure Electric Vehicle Control System2009
- Model driven design and aspect weavingSoftware and Systems Modeling, 2008
- A Code Generation Framework for Actor-Oriented Models with Partial EvaluationLecture Notes in Computer Science, 2007
- SCADE: Synchronous Design and Validation of Embedded Control Software2007
- Adaptive degraded document image binarizationPattern Recognition, 2006
- Ptolemy: A Framework for Simulating and Prototyping Heterogeneous Systems2002