Simulink start takes long time to compile

94 views (last 30 days)
I have a simulink model, with a few reference models. When I 'Update' the model, it is so fast.. But when I 'Run' the model, compliation takes more than 5 minutes. As per compile stats, below states are taking high time.
Cstat23: 163.72 seconds -- Running model reference normal mode DFS
Cstat28: 85.35 seconds -- Check And Compile Model Reference Normal Modes
Cstat451: 29.99 seconds -- Model initialize conditions_self
Cstat460: 28.79 seconds -- ShutdownModel
Could someone please help me to sort out this problem.

Accepted Answer

Daniel
Daniel on 20 Jun 2023
Edited: Daniel on 20 Jun 2023
In general, setting reference models to Accelerator mode can be useful if they're making your model run slowly. This generates and compiles code for the referenced models so they run as native code rather than going through the Simulink interpreter. You'll probably reduce the time in the run stage by using model referencing. The time spent in checking and compiling will probably increase since it will now need to generate some kind of code and compile the model.
To try accelerator mode, select the reference model that's taking a large chunk of your simulation time, and you can either click on "Normal" in the ribbon and change it to "Accelerator", or you can right-click on the Model block, select Block Properties from the context menu, and set the simulation mode there.
  2 Comments
D D
D D on 20 Jun 2023
Dear Daniel, Thank you for the reply. My concern is the high compilation time when pressing 'Run' button. It takes almost 5 minutes to actually start running. As I understand from you, setting accelerator mode, will not help to reduce compile time. Since we operate the models from MATLAB GUI, this high compile time causing issues. Could you please check once again.
Daniel
Daniel on 20 Jun 2023
It will be difficult to provide more targeted suggestions without being able to see the model, I'm afraid. One thing about accelerator mode that I forgot to mention yesterday: Once the compile is complete, it's cached, so you won't go through compile delays every time unless you're updating every model every time. I would still recommend turning on accelerator mode and timing the model twice. Let me know the results after both the first run (when it actually builds the model) and the second run (when it should be cached).

Sign in to comment.

More Answers (1)

Andy Bartlett
Andy Bartlett on 21 Jun 2023
If you have not done so already, I suggest you run Simulink Performance Advisor tool on your model.
The Tool knows lots of great techniques to speed up models. And even better, the tool conducts experiments to see if specific techniques speed things up or not, and then keeps only the model changes that speed things up.

Categories

Find more on Event Functions in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!