Main Content

Model Performance Optimization


Run your application with Accelerator or Rapid Accelerator instead of Normal mode. Note that some scopes do not plot data when run in Rapid Accelerator mode.

When you use accelerator or rapid accelerator mode, on the Model Configuration Parameters dialog box, navigate to Compiler optimization level tab, and then set the parameter value to Optimizations on (faster runs).

Performance analysis for SDRu Blocks

Starting in R2022a, the SDRu blocks show improved speed performance with fewer underruns and overruns. For example, you can observe a speedup (in megasamples per second (MS/s)) with fewer underruns or overruns at 10000 samples per frame when you simulate these models in Normal, Accelerator, or Rapid Accelerator mode.

Transmitter performance model

SDRu transmitter block diagram

Receiver performance model

SDRu receiver block diagram

The table shows the speedup analysis of these models with no underruns or overruns for USB-based radios and Ethernet-based radios. This speedup analysis is carried out between R2021b and R2022a.

Transmitter / ReceiverRadio typeR2021b Normal ModeR2022a Normal ModeR2021b Rapid Accelerator ModeR2022a Rapid Accelerator Mode
ReceiverB-series15 MS/s25 MS/s20 MS/s35 MS/s
ReceiverX-series2 MS/s50 MS/s15.36 MS/s61.44 MS/s
TransmitterB-series5 MS/s15 MS/s10 MS/s20 MS/s
TransmitterX-series10 MS/s30.72 MS/s10 MS/s40 MS/s

The models were timed on a Windows® 10, Intel® Xeon® CPU E5-1650 v4 @ 3.60 GHz test system.

Model Tuning

  • Use frame-based processing. With frame-based processing, the model processes multiple samples during a single execution call to a block. Consider using frame sizes from roughly 100 to several thousand.

  • In Model Configuration Parameters > Data Import/Export, turn off all logging.

  • The model should be single-rate. If the model requires resampling, then choose rational coefficients that will keep the model single-rate.

  • Do not add any Buffer blocks to the model. If you want to create convenient frame sizes, do it in your data sources. Using a Buffer block typically degrades performance.

  • Avoid feedback loops. Typically, such loops imply scalar processing, which will slow down the model considerably.

  • Avoid using scopes. To visualize your data, send it to a workspace variable and post-process it.

  • If your model has Constant blocks with values that do not change during simulation, make sure that the sample time is set to inf (default).

Simulink Code Generation

  • If you are generating code from the model, set the Solver setting to Fixed-step/ discrete. Set tasking mode to SingleTasking.

  • You can generate a standalone executable for your Simulink® model to improve performance. The generated code runs without Simulink in the loop. To perform any code generation, you must have an appropriate compiler installed. See for a list of supported compilers.

    You can generate generic real-time target (GRT) code if you have a Simulink Coder™ license. To do so, set Model Configuration Parameters > Code Generation > System target file to grt.tlc (Generic Real-Time Target).

  • When you generate code for any target (not just GRT), uncheck the Model Configuration Parameters > Hardware Implementation > Test hardware > Test hardware is the same as production hardware checkbox. After the checkbox is unchecked, set the Device type popup to MATLAB Host Computer.

  • You can create generated code with a smaller stack then the GRT code if you have an Embedded Coder® license. To do so, set the Model Configuration Parameters > Code Generation > System target file to ert.tlc (Embedded Coder). Then, add the following lines to the Model Configuration Parameters > Code Generation > Custom Code > Include custom C code in generated: > Source file edit field:

    #include <stdio.h>
    #include <stdlib.h>

Related Topics