Main Content

Execution Speed

Improve execution speed of generated code

The code generator increases the execution speed of the generated code where possible by replacing global variables with local variables, removing data copies, using the memset and memcpy functions, and reducing the amount of memory for storing data. You can increase the execution speed of the generated code by implementing compiler and processor specific optimizations, specifying buffer reuse, and removing code you might not need.

Model Settings

expand all

Optimize using the specified minimum and maximum valuesOptimize using minimum and maximum values for signals and parameters
Simplify array indexingReplace multiply operations in array indices when accessing arrays in a loop
Loop unrolling threshold Specify minimum array size width for generating for loops
Optimize reductionsSingle instruction, multiple data (SIMD) code for reduction operation loops (Since R2022a)
Use memset to initialize floats and doubles to 0.0Control generation of code that explicitly initializes floating-point data to 0.0
Data type replacementMethod for replacing built-in data type names in generated code (Since R2023a)
Simulation behavior for denormal numbersOption to emulate hardware handling of denormal numbers
Use floating-point multiplication to handle net slope correctionsNet slope correction computation for floating-point to fixed-point casts
Leverage target hardware instruction set extensionsInstruction sets to generate single instruction, multiple data (SIMD) code (Since R2021b)
Signal storage reuseReuse signal memory
Optimize global data accessOptimize global variable usage
Optimize block operation order in generated codeSpecify to reorder block operations for improved code execution speed
Loop unrolling threshold Specify minimum array size width for generating for loops
Use memcpy for vector assignmentOptimize code generated for vector assignments
Conditional input branch executionOption to optimize input paths for Switch and Multiport Switch blocks
Dynamic memory allocation in MATLAB functionsOption to use dynamic memory allocation for MATLAB code
Code replacement librariesLibraries that define code optimizations for specific target environment
Generate Halide codeGenerate Halide code for faster array computation (Since R2023b)

Topics

Execution Speed Optimization Basics

Processor Specific Optimizations

Optimizations that Improve Execution Efficiency

Optimizations Using Halide Code Generation

Related Information

Featured Examples