Before you take steps to improve code generation, read about your options in Optimization Strategies.
parfor |
Parallel for-loop |
coder.varsize |
Declare variable-size array |
coder.const |
Fold expressions into constants in generated code |
coder.inline |
Control inlining in generated code |
coder.unroll |
Copy body of for-loop in generated code for each iteration |
coder.ceval |
Call external C/C++ function |
coder.CodeConfig |
codegen configuration object |
coder.ExternalDependency |
Interface to external code |
coder.LAPACKCallback |
Abstract class for specifying the LAPACK library and LAPACKE header file for LAPACK calls in generated code |
Minimize Dynamic Memory Allocation
Improve execution time by minimizing dynamic memory allocation.
Provide Maximum Size for Variable-Size Arrays
Use techniques to help the code generator determine the upper bound for a variable-size array.
Disable Dynamic Memory Allocation During Code Generation
Disable dynamic memory allocation in the app or at the command line.
Set Dynamic Memory Allocation Threshold
Disable dynamic memory allocation for arrays less than a certain size.
Generate Code with Parallel for-Loops (parfor)
Generate a loop that runs in parallel on shared-memory multicore platforms.
Specify Maximum Number of Threads in parfor-Loops
Generate a MEX function that executes loop iterations in parallel on specific number of available cores.
Control Compilation of parfor-Loops
Treat parfor
-loops as parfor
-loops
that run on a single thread.
Minimize Redundant Operations in Loops
Move operations outside of loop when possible.
Generate a copy of for
-loop body
for each loop iteration.
Eliminate Redundant Copies of Function Inputs
Use the same variable as a function input and output.
Inlining eliminates the overhead of a function call by replacing the function call with the body of the function.
Restrict inlining to reduce the size of generated code and memory usage.
Fold Function Calls into Constants
Reduce execution time by replacing expression with constant in the generated code.
Disable Support for Integer Overflow or Non-Finites
Improve performance by suppressing generation of supporting code for integer overflow or non-finites.
Integrate External/Custom Code
Improve performance by integrating your own optimized code.
Speed Up Linear Algebra in Generated Standalone Code by Using LAPACK Calls
Generate LAPACK calls for certain linear algebra functions. Specify LAPACK library to use.
Optimize the execution speed or memory usage of generated code.
Dynamic Memory Allocation and Performance
Dynamic memory allocation can slow down execution speeds.
Algorithm Acceleration Using Parallel for-Loops (parfor)
Generate MEX functions for parfor
-loops.
Classification of Variables in parfor-Loops
Variables inside parfor
-loops are
classified as loop, sliced, broadcast, reduction, or temporary.
Reduction Assignments in parfor-Loops
A reduction variable accumulates a value that depends on all the loop iterations together.
MATLAB Coder Optimizations in Generated Code
To improve the performance of generated code, the code generator uses optimizations.
The code generator optimizes generated code by using memcpy
.
The code generator optimizes generated code by using memset
.
LAPACK Calls in Generated Code
LAPACK function calls improve the execution speed of code generated for certain linear algebra functions.
Diagnose errors for code generation of parfor
-loops.