How to reduce the execution and/or compilation time of a model with Simscape components?
7 views (last 30 days)
Show older comments
MathWorks Support Team
on 28 Sep 2023
Edited: MathWorks Support Team
on 31 Mar 2024
I have a computationally heavy Simulink model with Simscape components for a battery-driven electric vehicle and I want to reduce the execution and/or compilation time of the model. Earlier I ran the model on my laptop with 16GB RAM and noticed performance issues.
Then I used the company's computing equipment with 512GB RAM and to execute the model, but the CPU utilization for MATLAB (as noted from the Task Manager) is far below the maximum.
We also have a distributed server environment that I could leverage to improve performance. Can using Parallel Computing Toolbox improve performance?
Accepted Answer
MathWorks Support Team
on 31 Mar 2024
Edited: MathWorks Support Team
on 31 Mar 2024
You should note that Parallel Computing Toolbox can only be used to run multiple simulations of the same model concurrently through "parsim" and "batchsim". So, for performance improvement over multiple simulations, PCT will indeed improve performance.
Now as to why a single simulation cannot be sped up via PCT, for the most part, a single simulation is single-threaded, so increasing the number of cores will not improve the performance of a single simulation. This is why you will only see a simulation using up to 100% of one core, so if you have 10 cores you will see 10% usage in Windows Task Manager.
Multi-threaded simulations are supported but only in extremely limited situations. Some reasons for these limitations are that multi-threading requires the presumption that the model can be broken into components that can run independently. For models that include Simscape components, there is no support for multi-threading different parts of a Simscape network. The lines or signals in a Simscape network represent physical connections, not the flow of data, which means that you cannot easily cut pieces of a network off and solve them independently.
Please refer to the following link under the "S Function Block Limitations" section to determine whether the Simscape blocks satisfy the restrictions of being able to run co-simulations or not.
Also, if the memory utilization is not maximum then increasing RAM will not improve performance.
To improve the performance of a single simulation, refer to the following article which has many helpful tips to achieve the same:
0 Comments
More Answers (0)
See Also
Categories
Find more on Data Logging in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!