Code Regeneration in Accelerated Models
Changing the structure of your model causes rapid accelerator mode to regenerate the standalone executable, and for the accelerator mode to regenerate the target code and update (overwrite) the existing MEX-file. Changing the value of a tunable parameter does not trigger a rebuild.
Determine If the Simulation Will Rebuild
The accelerator and rapid accelerator modes use a checksum to determine if the model has changed, indicating that the code should be regenerated. The checksum is an array of four integers computed using an MD5 checksum algorithm based on attributes of the model and the blocks it contains.
Use the
Simulink.BlockDiagram.getChecksum
function to obtain the checksum for your model. For example:cs1 = Simulink.BlockDiagram.getChecksum('myModel');
Obtain a second checksum after you have altered your model. The code regenerates if the new checksum does not match the previous checksum.
Use the information in the checksum to determine why the simulation target rebuilt.
For a detailed explanation of this procedure, see Determine Why Simulink Accelerator Is Regenerating Code.
Parameter Tuning in Rapid Accelerator Mode
In model rebuilds, rapid accelerator mode handles block diagram and runtime parameters differently from other parameters.
Tuning Block Diagram Parameters
You can change some block diagram parameters during
simulation without causing a rebuild. Tune these
parameters using the
set_param
function or using
the Model Configuration
Parameters dialog box. These block
diagram parameters include:
Solver Parameters | ||
---|---|---|
AbsTol | MaxNumMinSteps | RelTol |
ConsecutiveZCsStepRelTol | MaxOrder | StartTime |
ExtrapolationOrder | MaxStep | StopTime |
InitialStep | MinStep | ZCDetectionTol |
MaxConsecutiveMinStep | OutputTimes | |
MaxConsecutiveZCs | Refine |
Tuning Runtime Parameters
To tune runtime parameters for maximum acceleration in
rapid accelerator mode, follow this procedure
which yields better results than using
set_param
for the same purpose:
Collect the runtime parameters in a runtime parameter structure while building a rapid accelerator target executable using the
Simulink.BlockDiagram.buildRapidAcceleratorTarget
function.To change the parameters, use the
Simulink.BlockDiagram.modifyTunableParameters
function.To specify the modified parameters to the
sim
function, use theRapidAcceleratorParameterSets
andRapidAcceleratorUpToDateCheck
parameters.
All other parameter changes can necessitate a rebuild of the model.
Parameter Changes | Passed Directly to sim
function | Passed Graphically via Block Diagram or via
set_param function |
---|---|---|
Runtime | Does not require rebuild | Can require rebuild |
Block diagram (logging parameters) | Does not require rebuild | Does not require rebuild |
For information about parameter tunability limitations with accelerated simulation modes, see Tunability Considerations and Limitations for Other Modeling Goals.