Concurrent Execution support in SimWB
MLToolkit supports generating multi-threaded code that can be executed in
multiple processors using Simulink feature called Concurrent Execution.
Concurrent execution of different parts of the model offers several advantages for Hardware-In-the-Loop
(HIL) simulation such as:
-
Bigger computing horsepower
It is now possible to partition a big, complex, and computationally intensive model into smaller
parts and execute them in different processors. This opens up many possibilities and allows
the customers to utilize the modern multi-processor systems effectively.
-
Simulate the effects of data dependency
When executing different part of the model in different processors, there is an
inherent delay in exchanging data. Concurrent execution allows the customers
to simulate the effects before deploying the algorithm.
-
Scalable
Large monolithic models result in huge
computational cost. Scalability of Concurrent execution allows more complex models to be
executed in real-time.
For an overview of Concurrent Execution, please refer to the Simulink documentation.
Supported MATLAB® versions for Concurrent Execution
Configuring the models for Concurrent Execution support
When you generate code from a model, the MLToolkit automatically changes the model
to have certain settings so that concurrent execution is possible. These settings can be
configured either automatically or manually as explained below.
Automatic Configuration of the referenced models
To automatically configure all the referenced models in a top level model that is needed
to be built for SimWB,
please use the SimWB helper function named simwbConfigConcurExecution.
For example, the command simwbConfigConcurExecution('SYS')
configures all the models referenced in the model 'SYS' to work with MLToolkit and saves them.
It also saves a backup copy of all those models be default.
Additional arguments must be supplied as name-value pairs.
Allowed names are:
- ModelType - 'TopLevel' or 'Individual' (default: 'TopLevel')
- Target - 'grt' or 'ert' (default: 'grt')
- Backup - true or false (default: true)
Options are case-insensitive on all platforms.
Manually Configuring Concurrent Execution for both Top and referenced Models
For each model, you need to change the settings as explained below.
Before completing individual settings,
you need to convert the model configuration to support concurrent execution.
For this, please see the Simulink documentation section named
'Creating a Concurrent Execution Configuration Set'.
After converting the configuration to Concurrent Execution,
you need to configure the settings listed below for the referenced models
(used on the top model above) in order for the concurrent execution to work.
-
Under Simulation > Configuration Parameters > Code Generation
-
SystemTargetFile : Make sure you have selected grt.tlc.
-
Template makefile :This should be changed to simwb_concurrent_rt.tmf
-
Generate code only :This option should be checked.
-
Under Simulation > Configuration Parameters > Code Generation > Interface
-
Code replacement library : Make sure you have selected C99 (ISO).
-
Support non-finite numbers :This option should be checked.
-
Classic call interface :This option should be checked.
- MAT-file logging :This option should be NOT be checked.
-
Under Simulation > Configuration Parameters > Code Generation > Symbols
-
Maximum identifier length (Optional) : Changing this to 64 reduces the chance of name collision in the generated code.
Limitations in Concurrent Execution Support
-
The RTDB variables need to be manually configured by using the RTDBIn or
RTDBOut blocks from MLToolkit library accessible by the command
simwbSfunlib and should be inside the referenced models.
-
You can not have multiple instances of models that have RTDB variables
configured in them. You can still have multiple instances of models that do
not have any RTDB variables.
-
You need to generate code from MATLAB installed in Linux.
Simulink does not generate Linux POSIX threads for its Windows version if you use GRT.
See Also