|On this page…|
Compiler optimizations are off by default. This results in faster build times, but slower simulation times. You can optimize the build process toward a faster simulation.
From the Simulation menu, select Model Configuration Parameters.
In the left pane of the Configuration Parameters dialog box, select Optimization, and then from the Compiler optimization level drop-down list, select Optimizations on (faster runs).
Code generation takes longer with this option, but the model simulation runs faster.
Select Verbose accelerator builds to display progress information using code generation, and to see the compiler options in use.
By default, the Accelerator mode places the generated code in a subfolder of the working folder called slprj/accel/modelname (for example, slprj/accel/f14), and places a compiled MEX-file in the current working folder. To change the name of the folder into which the Accelerator Mode writes generated code:
In the Simulink® editor window, select File > Simulink Preferences.
The Simulink Preferences window appears.
In the Simulink Preferences window, navigate to the Simulation cache folder parameter.
Enter the absolute or relative path to your subfolder and click Apply.
To accelerate a model, first open it, and then from the Simulation > Mode menu, select either Accelerator or Rapid Accelerator. Then start the simulation.
The following example shows how to accelerate the already opened f14 model using the Accelerator mode:
From the Simulation > Mode menu, select Accelerator.
Alternatively, you can select Accelerator from the Simulink Editor toolbar.
From the Simulation menu, select Run.
The Accelerator and Rapid Accelerator modes first check to see if code was previously compiled for your model. If code was created previously, the Accelerator or Rapid Accelerator mode runs the model. If code was not previously built, they first generate and compile the C code, and then run the model.
For an explanation of why these modes rebuild your model, see Code Regeneration in Accelerated Models.
The Accelerator mode places the generated code in a subfolder of the working folder called slprj/accel/modelname (for example, slprj/accel/f14), and places a compiled MEX-file in the current working folder. If you want to change this path, see Changing the Location of Generated Code.
The Rapid Accelerator mode places the generated code in a subfolder of the working folder called slprj/raccel/modelname (for example, slprj/raccel/f14).
A feature of the Accelerator and Rapid Accelerator modes is that simple adjustments (such as changing the value of a Gain or Constant block) can be made to the model while the simulation is still running. More complex changes (for example, changing from a sin to tan function) are not allowed during run time.
The Simulink software issues a warning if you attempt to make a change that is not permitted. The absence of a warning indicates that the change was accepted. The warning does not stop the current simulation, and the simulation continues with the previous values. If you wish to alter the model in ways that are not permitted during run time, you must first stop the simulation, make the change, and then restart the simulation.
In general, simple model changes are more likely to result in code regeneration when in Rapid Accelerator mode than when in Accelerator mode. For instance, changing the stop time in Rapid Accelerator mode causes code to regenerate, but does not cause Accelerator mode to regenerate code.