Changing the structure of your model causes the 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.
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
command
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 the
example model slAccelDemoWhyRebuild
.
In model rebuilds, Rapid Accelerator Mode handles block diagram and runtime parameters differently from other parameters.
You can change some block diagram parameters during simulation
without causing a rebuild. Tune these parameters using the set_param
command
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 |
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
command,
use the RapidAcceleratorParameterSets
and RapidAcceleratorUpToDateCheck
parameters.
All other parameter changes can necessitate a rebuild of the model.
Parameter Changes | Passed Directly to sim command | Passed Graphically via Block Diagram or via set_param
command |
---|---|---|
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.