Customize the Build Process
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 Configuration Parameters dialog box, 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.
Changing the Location of Generated Code
By default, the Accelerator mode places the generated
code in a subfolder of the working folder called
To change the name of the folder into which the
Accelerator Mode writes generated code:
In the Simulink® Editor window, on the Modeling tab, select Environment > 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.
Run Acceleration Mode from the User Interface
To accelerate a model, first open it, and then on the
Simulation tab, in the
Simulate section, select
Rapid Accelerator from
the drop-down menu. Then start the simulation.
The following example shows how to accelerate the already opened
f14 model using the Accelerator
On the Simulation tab, in the Simulate section, select
Acceleratorfrom the drop-down menu.
On the Simulation tab, click 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/f14). 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
The warnings that blocks generate during simulation (such as divide-by-zero and integer overflow) are not displayed when your model runs in Accelerator or Rapid Accelerator mode.
Making Run-Time Changes
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
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.
Switching Solvers between Runs
You can switch variable-step solvers between runs and Simulink will automatically determine if a solver change will trigger a rebuild, based on the mathematical structure of the model, such as whether the model is an Ordinary Differential of Equation (ODE) or a Differential Algebraic of Equation (DAE) model, if the solver needs a Jacobian, whether it handles mass matrices, or if the model contains rate limiter blocks.
- Design Your Model for Effective Acceleration
- Interact with the Acceleration Modes Programmatically
- Run Accelerator Mode with the Simulink Debugger