Main Content

Design Your Model for Effective Acceleration

Select Blocks for Accelerator Mode

Accelerator mode runs the following blocks as if you were running normal mode because these blocks do not generate code for the accelerator build. Consequently, if your model contains a high percentage of these blocks, accelerator mode may not increase performance significantly. All of these Simulink® blocks use interpreted code.

The following blocks can cause poor simulation runtime performance when run in the default JIT accelerator mode.

Select Blocks for Rapid Accelerator Mode

Blocks that do not support code generation (such as SimEvents®) or blocks that generate code only for a specific target cannot be simulated in rapid accelerator mode.

Additionally, rapid accelerator mode does not work if your model contains any of the following blocks:

  • Interpreted MATLAB Function

  • Device driver S-functions, such as blocks from the Simulink Real-Time™ product, or those targeting Freescale® MPC555

Control S-Function Execution


In the default JIT accelerator mode, inlining of user-written TLC S-Functions is not supported. If you run a model containing TLC S-Functions in the JIT accelerator mode, there is a possibility of the execution speed reducing. The code generation speed, however, will be high due to JIT acceleration.

Inlining S-functions using the Target Language Compiler increases performance with the classic accelerator mode by eliminating unnecessary calls to the Simulink API. By default, however, the classic accelerator mode ignores an inlining TLC file for an S-function, even though the file exists. The rapid accelerator mode always uses the TLC file if one is available.

A device driver S-Function block written to access specific hardware registers on an I/O board is one example of why this behavior was chosen as the default. Because the Simulink software runs on the host system rather than the target, it cannot access the target I/O registers and so would fail when attempting to do so.

To direct the classic accelerator mode to use the TLC file instead of the S-function MEX-file, specify SS_OPTION_USE_TLC_WITH_ACCELERATOR in the mdlInitializeSizes function of the S-function, as in this example:

static void mdlInitializeSizes(SimStruct *S)
/* Code deleted */

Rapid accelerator mode will make use of the MEX file if the S-Function C file is not present in the same folder.


To use the .c or .cpp code for your S-Function, ensure that they are in the same folder as the S-Function MEX-file. Otherwise, you can include additional files to an S-function or bypass the path limitation by using the rtwmakecfg.m file. For more information, see Use rtwmakecfg.m API to Customize Generated Makefiles (Simulink Coder).

Accelerator and Rapid Accelerator Mode Data Type Considerations

  • Accelerator mode supports fixed-point signals and vectors up to 128 bits.

  • Rapid accelerator mode supports fixed-point parameters up to 128 bits.

  • Rapid accelerator mode supports fixed-point root inputs up to 32 bits

  • Rapid accelerator mode supports root inputs of Enumerated data type

  • Rapid accelerator mode does not support fixed-point data for the From Workspace block.

  • Rapid accelerator mode ignores the Log fixed-point data as a fi object parameter for the To Workspace block.

  • Rapid accelerator mode supports bus objects as parameters.

  • Accelerator mode and rapid accelerator mode store integers as compactly as possible.

  • Fixed-Point Designer™ does not collect min, max, or overflow data in the accelerator or rapid accelerator modes.

  • Accelerator mode supports a limited set of runtime diagnostics, including the assertion block.

  • Rapid accelerator mode supports a limited set of runtime diagnostics, including the assertion block.

Behavior of Scopes and Viewers with Rapid Accelerator Mode

Running the simulation programmatically or interactively determines the behavior of scopes and viewers in rapid accelerator mode.

Scope or Viewer TypeSimulation Run InteractivelySimulation Run Programmatically
Simulink Scope blockSame support as normal mode
  • Logging is supported

  • Scope window is not updated

Simulink signal viewer scopesGraphics are updated, but logging is not supportedNot supported
Other signal viewer scopesSupport limited to that available in external modeNot supported
Signal loggingSupported.Supported.

Visualizers with inputs from logging

(Such as the Simulation Data Inspector or Logic Analyzer)

Data not visualized during simulation.Data not visualized during simulation.
Stateflow® chartsSame support for chart animation as normal modeNot supported


Although scopes and viewers do not update when you run rapid accelerator simulations programmatically, they do update when you run the simulation interactively. Run Acceleration Mode from the User Interface shows how to run rapid accelerator mode from the menu. Interact with the Acceleration Modes Programmatically shows how to run the simulation programmatically.

Factors Inhibiting Acceleration

  • You cannot use accelerator mode or rapid accelerator mode if your model:

    • Passes array parameters to MATLAB® S-functions that are not numeric, logical, or character arrays, are sparse arrays, or that have more than two dimensions.

    • Uses Fcn blocks containing trigonometric functions having complex inputs.

  • In some cases, changes associated with external or custom code do not cause accelerator or rapid accelerator simulation results to change. These include:

    • TLC code

    • S-function source code, including rtwmakecfg.m files

    • Integrated custom code

    • S-Function Builder

    In such cases, consider force regeneration of code for a top model. Alternatively, you can force regeneration of top model code by deleting code generation folders, such as slprj or the generated model code folder.


    With JIT acceleration, the acceleration target code is in memory. It is therefore available for reuse as long as the model is open, even if you delete the slprj folder.

Rapid Accelerator Mode Limitations

  • Rapid accelerator mode does not support:

    • Algebraic loops.

    • Targets written in C++.

    • Interpreted MATLAB Function blocks.

    • Noninlined MATLAB language or Fortran S-functions. You must write S-functions in C or inline them using the Target Language Compiler (TLC) or you can also use the MEX file. For more information, see Write Fully Inlined S-Functions (Simulink Coder).

    • Debugging utilities or Simulink Profiler.

    • Run time objects for Simulink.RunTimeBlock and Simulink.BlockCompOutputPortData blocks.

  • Model parameters must be one of these data types:

    • boolean

    • uint8 or int8

    • uint16 or int16

    • uint32 or int32

    • single or double

    • Fixed-point

    • Enumerated

  • You cannot pause a simulation in rapid accelerator mode.

  • In certain cases, changing block parameters can result in structural changes to your model that change the model checksum. An example of such a change is changing the number of delays in a DSP simulation. In these cases, you must regenerate the code for the model. See Code Regeneration in Accelerated Models for more information.

  • For root inports, when you specify the minimum and maximum values that the block should output, rapid accelerator mode does not recognize these limits during simulation.

  • In rapid accelerator mode, To File or To Workspace blocks inside function-call subsystems do not generate any logging files if the function-call port is connected to Ground or unconnected.

  • Rapid accelerator mode does not support systems that run RHEL / CentOS 6.x or 7.x.

  • In rapid accelerator mode, struct/enum redefinition occurs when model has custom code types.

Reserved Keywords

Certain words are reserved for use by the Simulink Coder™ code language and by accelerator mode and rapid accelerator mode. These keywords must not appear as function or variable names on a subsystem, or as exported global signal names. Using the reserved keywords results in the Simulink software reporting an error, and the model cannot be compiled or run.

The keywords reserved for the Simulink Coder product are listed in Construction of Generated Identifiers (Simulink Coder). Additional keywords that apply only to the accelerator and rapid accelerator modes are:

muDoubleScalarAbs muDoubleScalarCosmuDoubleScalarMod
muDoubleScalarAcos muDoubleScalarCoshmuDoubleScalarPower
muDoubleScalarAsinh muDoubleScalarHypotmuDoubleScalarSin
muDoubleScalarCeil muDoubleScalarMin muDoubleScalarTanh

Related Topics