Main Content

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.

  1. Use the Simulink.BlockDiagram.getChecksum function to obtain the checksum for your model. For example:

    cs1 = Simulink.BlockDiagram.getChecksum('myModel');
    

  2. Obtain a second checksum after you have altered your model. The code regenerates if the new checksum does not match the previous checksum.

  3. 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:

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:

  1. Collect the runtime parameters in a runtime parameter structure while building a rapid accelerator target executable using the Simulink.BlockDiagram.buildRapidAcceleratorTarget function.

  2. To change the parameters, use the Simulink.BlockDiagram.modifyTunableParameters function.

  3. To specify the modified parameters to the sim function, use the RapidAcceleratorParameterSets and RapidAcceleratorUpToDateCheck parameters.

All other parameter changes can necessitate a rebuild of the model.

Parameter ChangesPassed Directly to sim functionPassed Graphically via Block Diagram or via set_param function
RuntimeDoes 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.

Related Topics