coder.EmbeddedCodeConfig - Configuration parameters for C/C++ code generation from MATLAB code with Embedded Coder - MATLAB (original) (raw)
Main Content
Configuration parameters for C/C++ code generation from MATLAB code with Embedded Coder
Description
A coder.EmbeddedCodeConfig
object contains the configuration parameters that codegen
uses for generating a static library, a dynamically linked library, or an executable program with Embedded Coder®. Pass the object to the codegen
function by using the-config
option.
Properties
BuildConfiguration
— Compiler optimization or debug settings for toolchain
'Faster Runs'
(default) | 'Faster Builds'
| 'Debug'
| 'Specify'
Compiler optimization or debug settings for toolchain, specified as one of the values in this table.
Value | Description |
---|---|
'Faster Builds' | Optimizes the build for shorter build times. |
'Faster Runs' | Optimizes the build for faster running executables. |
'Debug' | Optimizes the build for debugging. |
'Specify' | Enables theCustomToolchainOptions property for customization of settings for tools in the selected toolchain. If theToolchain property is set to'Automatically locate an installed toolchain', then settingBuildConfiguration to'Specify' changesToolchain to the located toolchain. |
If you set the Toolchain
property to one of the available CMake toolchain definitions, the allowed values of this property are 'Release'
, 'Debug'
,'RelWithDebInfo'
, 'MinSizeRel'
, and 'Specify'
. See Configure CMake Build Process.
CacheDynamicArrayDataPointer
— Dynamic array optimization
true
(default) | false
Dynamic array optimization, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator improves the execution time of generated C code by optimizing dynamic array access. |
false | The code generator does not optimize dynamic array access. |
See Optimize Dynamic Array Access.
CastingMode
— Data type casting level
'Nominal'
(default) | 'Standards'
| 'Explicit'
Data type casting level for variables in the generated C/C++ code, specified as one of the values in this table.
Value | Description |
---|---|
'Nominal' | This value is the default value.Generates C/C++ code that uses default C compiler data type casting. For example:short addone(short x) { int i; i = x + 1; if (i > 32767) { i = 32767; } return (short)i; } |
'Standards' | Generates C/C++ code that casts data types to conform to MISRA™ standards. For example:short addone(short x) { int i; i = (int)x + (int)1; if (i > (int)32767) { i = (int)32767; } return (short)i; } |
'Explicit' | Generates C/C++ code that casts data type values explicitly. For example:short addone(short x) { int i; i = (int)x + 1; if (i > 32767) { i = 32767; } return (short)i; } |
See Control Data Type Casts in Generated Code (Embedded Coder).
ClangFormatFile
— Control generation of clang-format
file
'Generate'
(default) | 'Existing'
Set this option to specify if you want to generate or use an existingclang-format
file to format the generated code. Choose the formatting file selection method, specified as one of the values in the table.
Value | Description |
---|---|
'Generate' | This value is the default value.Creates aclang-format file for your build based on your configuration settings. Theclang-format file is generated in the codegen folder. |
'Existing' | Formats the generated code by using aclang-format file of your choice. Using clang-format enables detailed control over the formatting of your generated code.The code generator searches for an existingclang-format file in the code generation folder and then the folder tree above the code generation folder. The code generator looks for files whose name includes_clang-format or is a.clang-format file that it finds. If it is unable to find the required file, the code generator uses the built-in format specification. |
For more information, see https://clang.llvm.org/docs/ClangFormatStyleOptions.html.
clang-format
does not have native CUDA® C++ support. When generating CUDA code using GPU Coder™, setting the formatting tool to'Clang-format'
might result in build failures during code compilation.
CodeCoverage
— Analysis of C/C++ code coverage
false
(default) | true
Coverage analysis of both generated C/C++ code and custom C/C++ during a software-in-the-loop (SIL) or processor-in-the-loop (PIL) execution, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.Disables code coverage analysis during a SIL or PIL execution. |
true | Instruments C/C++ code for coverage analysis in the SIL or PIL application. |
To use this name-value argument, you must have a MATLAB® Test™ license.
Data Types: logical
CodeExecutionProfiling
— Execution time profiling during a SIL or PIL execution
false
(default) | true
Execution-time profiling of entry-point functions during a software-in-the-loop (SIL) or processor-in-the-loop (PIL) execution, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.Disables execution-time profiling during a SIL or PIL execution. |
true | Calculates execution times of entry-point functions, using data obtained from instrumentation code in the SIL or PIL application. Use the Code Profile Analyzer (Embedded Coder) to view the call tree and corresponding execution times for the generated code. |
See Execution Time Profiling for SIL and PIL (Embedded Coder) and Generate Execution Time Profile (Embedded Coder).
CodeFormattingTool
— Formatting tool for generated code
'Auto'
(default) | 'Clang-format'
| 'MathWorks'
Code formatting options for generated code, specified as one of the values in the table.
Value | Description |
---|---|
'Clang-format' | The code generator formats the generated code according to a clang-format file. |
'Auto' | Uses an internal heuristic to determine if the generated code is formatted byclang-format or a MathWorks® formatting tool.If the code configuration propertyVerbosity is set to'Verbose', the code generator produces a warning if the heuristic chooses a MathWorks formatting tool. |
'MathWorks' | Causes the code generator to revert to the MathWorks formatting tool. |
CodeProfilingCodeMetrics
— PMU metric
"time"
(default) | "totinstr"
| "floatinsts"
| "floatopts"
| "intinstr"
| "loadinstr"
| "storeinstr"
| "totcyc"
| "l1dcm"
| "l1icm"
| "l2dcm"
| "l2icm"
| "tlbdm"
| "tlbim"
| "memstall"
| "totstall"
Performance Monitoring Unit (PMU) metric profiling of functions, specified as one of the values in this table.
Value | Description |
---|---|
"time" (default) | This value is the default value.Extracts no metric from the PMU of the target hardware. |
"totinstr" | Extracts total instruction count. |
"floatinsts" | Extracts FPU instruction count. |
"floatopts" | Extracts FPU operation count. |
"intinstr" | Extracts ALU instruction count. |
"loadinstr" | Extracts load instruction count. |
"storeinstr" | Extracts store instruction count. |
"totcyc" | Extracts total cycle count. |
"l1dcm" | Extracts L1 data cache misses. |
"l1icm" | Extracts L1 instruction cache misses. |
"l2dcm" | Extracts L2 data cache misses. |
"l2icm" | Extracts L2 instruction cache misses. |
"tlbdm" | Extracts TLB data misses. |
"tlbim" | Extracts TLB instruction misses. |
"memstall" | Extracts memory stall cycles. |
"totstall" | Extracts total stall cycles. |
See Investigate Execution-Time Issues Using PMU Metrics (Embedded Coder).
Data Types: char
| string
CodeProfilingInstrumentation
— Execution time profiling of functions called within entry-point functions during a SIL or PIL execution
false
(default) | true
Execution-time profiling of functions that are called within entry-point functions during a software-in-the-loop (SIL) or processor-in-the-loop (PIL) execution, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.Disables execution-time profiling of functions called within entry-point functions during a SIL or PIL execution. |
true | Calculates execution times of functions called within entry-point functions, using data obtained from instrumentation code in the SIL or PIL application. Use the Code Profile Analyzer (Embedded Coder) to view the call tree and corresponding execution times for the generated code. |
Dependency: CodeExecutionProfiling
enables this parameter.
See Execution Time Profiling for SIL and PIL (Embedded Coder) and Generate Execution Time Profile (Embedded Coder).
CodeProfilingSaveOptions
— Collection and storage of execution-time measurements
"AllData"
(default) | "SummaryOnly"
| "MetricsOnly"
Options for collection and storage of execution-time measurements, specified as one of the values in this table.
Value | Description |
---|---|
"AllData" | This value is the default value.As execution runs, collects and immediately uploads profiling measurement and analysis data from target device to development computer. At the end of execution, saves all data in base workspace. |
"SummaryOnly" | As execution runs, evaluates only execution-time metrics required for report and immediately uploads metrics from target device. At the end of execution, saves evaluated metrics in base workspace. |
"MetricsOnly" | As execution runs, processes profiling data and stores certain metrics on target device. At the end of execution, uploads the stored metrics from target device. |
Data Types: char
| string
CodeStackProfiling
— Stack usage profiling during a SIL or PIL execution
false
(default) | true
Stack usage profiling of entry-point functions during a software-in-the-loop (SIL) or processor-in-the-loop (PIL) execution, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.Disables stack usage profiling during a SIL or PIL execution. |
true | Calculates stack usage of functions in the generated code, using data obtained from instrumentation code in the SIL or PIL application. Use the Code Profile Analyzer (Embedded Coder) to view the stack usage values for entry-point and internal functions. |
See Stack Usage Profiling for Code Generated From MATLAB Code (Embedded Coder).
CodeTemplate
— Code generation template for file and function banners
0-by-0 array ofcoder.MATLABCodeTemplate
class (default) | coder.MATLABCodeTemplate
object
Code generation template for file and function banners in the generated code. By default, CodeTemplate
is empty and the code generator produces default banners. To produce custom banners, setCodeTemplate
to acoder.MATLABCodeTemplate
object created from a code generation template (CGT) file. See Generate Custom File and Function Banners for C/C++ Code (Embedded Coder).
CodeReplacementLibrary
— Code replacement library for generated code
character vector
Code replacement library for generated code, specified as one of the values in this table:
Value | Description |
---|---|
'None' | This value is the default value.Does not use a code replacement library. |
Named code replacement library | Generates calls to a specific platform, compiler, or standards code replacement library. The list of named libraries depends on: Installed support packages.System target file, language, language standard, and device vendor configuration.Whether you created and registered code replacement libraries, using the Embedded Coder product. |
Compatible libraries depend on these parameters:
TargetLang
TargetLangStandard
ProdHWDeviceType
in the hardware implementation configuration object.
Embedded Coder offers more libraries and the ability to create and use custom code replacement libraries.
MATLAB Coder™ generates the minimal set of #include
statements for header files required by the selected code replacement library.
Before setting this parameter, verify that your compiler supports the library that you want to use. If you select a parameter value that your compiler does not support, compiler errors can occur.
Note
MATLAB Coder software does not support TLC callbacks.
ColumnLimit
— Maximum number of columns before a line break in the generated code
80 (default) | positive integer
Maximum number of columns before a line break in the generated code, specified as a positive integer in the range [45, 65536].
Other rules for placement of the line break can take precedence over the column limit that you specify.
— Comment style in the generated code
'Auto'
(default) | 'Single-line'
| 'Multi-line'
Comment style in the generated code, specified as one of the values in this table.
Value | Description |
---|---|
'Auto' | For C, generate multiline comments. For C++, generate single-line comments. |
'Single-line' | Generate single-line comments preceded by//. |
'Multi-line' | Generate single or multiline comments delimited by/* and*/. |
For C code generation, specify the single-line comment style only if your compiler supports it.
Dependency: GenerateComments
enables this parameter.
See Specify Comment Style for C/C++ Code (Embedded Coder).
CompileTimeRecursionLimit
— Maximum number of function specializations for compile-time recursion
50 (default) | positive integer
Maximum number of function specializations for compile-time recursion, specified as a positive integer. To disallow recursion in the MATLAB code, set CompileTimeRecursionLimit
to 0. The default compile-time recursion limit is large enough for most recursive functions that require this type of recursion. If code generation fails because of the compile-time recursion limit, and you want compile-time recursion, try to increase the limit. Alternatively, change your MATLAB code so that the code generator uses run-time recursion. SeeCompile-Time Recursion Limit Reached.
ConstantFoldingTimeout
— Maximum number of instructions to be executed by the constant folder
40000 (default) | positive integer
Maximum number of instructions that the constant folder executes. In some situations, code generation requires specific instructions to be constant. If constant folding stops before these instructions are constant-folded, code generation fails. In this case, increase the value ofConstantFoldingTimeout
.
See MATLAB Coder Optimizations in Generated Code.
ConvertIfToSwitch
— Conversion of if-elseif-else
patterns to switch-case
statements
false
(default) | true
Conversion of if-elseif-else
patterns toswitch-case
statements in the generated code, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.The code generator does not convert if-elseif-else patterns to switch-case statements. |
true | The code generator tries to convertif-elseif-else patterns toswitch-case statements. The code generator produces a switch-case statement only if all potential case expressions are scalar integer values. |
See Controlling C Code Style (Embedded Coder).
CppGenerateEnumClass
— Whether to generate C++ enumeration classes for MATLAB enumerations
true
(default) | false
Whether to generate C++ code that contains enumeration classes, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator converts MATLAB enumerations to enumeration classes in the generated C++ code. This option is only supported ifTargetLangStandard is set to C++11 or a newer standard.See Code Generation for Enumerations. |
false | The code generator produces ordinary C enumerations for MATLAB enumerations in the generated C++ code. |
Dependency:
- Setting
TargetLang
to'C++'
enables this parameter.
CppInterfaceClassName
— Interface class name for generated C++ code
''
(default) | character vector
Name of interface class when you generate C++ code withCppInterfaceStyle
set to'Methods'
. In this case, the generated code for MATLAB entry-point functions consists of methods contained in a C++ class with name specified by CppInterfaceClassName
. This property has no effect when you setCppInterfaceStyle
to'Functions'
.
See Generate C++ Code with Class Interface.
CppInterfaceStyle
— Interface style for generated C++ code
'Functions'
(default) | 'Methods'
Style of interface to the generated C++ code for the MATLAB entry-point functions that you generate code from. By default, entry-point functions become C++ functions. If you choose'Methods'
, then entry-point functions become methods in a C++ class. Specify the name of the class by using the propertyCppInterfaceClassName
.
See Generate C++ Code with Class Interface.
Dependency:
- Setting
TargetLang
to'C++'
enables this parameter.
CppNamespace
— Namespace name for generated C++ code
''
(default) | character vector
Namespace for the generated C++ code. The code generator does not produce code in a namespace unless you specify a nonempty character vector.
See Organize Generated C++ Code into Namespaces.
Dependency:
- Setting
TargetLang
to'C++'
enables this parameter.
CppNamespaceForMathworksCode
— Place C++ code generated for MathWorks code in a separate namespace
'coder'
(default) | character vector
Namespace for the C++ code generated for MathWorks code. The code generator does not produce such a namespace if you specify this property as an empty character vector.
See Organize Generated C++ Code into Namespaces.
Dependency:
- Setting
TargetLang
to'C++'
enables this parameter.
Data Types: char
CppPreserveClasses
— Generate C++ classes for MATLAB classes
true
(default) | false
Whether to generate C++ classes or C style structures for MATLAB classes, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator produces C++ classes for MATLAB classes. See Generate C++ Classes for MATLAB Classes. |
false | The code generator produces C style structures for MATLAB classes. |
When using GPU Coder, the code generator always disables this parameter.
Dependency:
- Setting
TargetLang
to'C++'
enables this parameter.
Data Types: logical
CppPreserveNamespaces
— Generate C++ namespaces for MATLAB namespaces
true
(default) | false
Whether to generate C++ namespaces for the namespaces in your MATLAB code, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator produces C++ namespaces for the namespaces in your MATLAB code. See Organize Generated C++ Code into Namespaces. |
false | The code generator does not produce C++ namespaces for the namespaces in your MATLAB code. |
Dependency:
- Setting
TargetLang
to'C++'
enables this parameter.
Data Types: logical
CustomBLASCallback
— BLAS callback class
' ' (default) | character vector
Callback class for BLAS library calls in code generated for certain low-level vector and matrix operations in MATLAB code, specified as a character vector.
If you specify a BLAS callback class, for certain low-level vector and matrix functions, the code generator produces BLAS calls by using the CBLAS C interface to your BLAS library. The callback class provides the name of your CBLAS header file, the names of CBLAS data types, and the information required to link to your BLAS library. If this parameter is empty, the code generator produces code for matrix functions instead of a BLAS call.
See Speed Up Matrix Operations in Generated Standalone Code by Using BLAS Calls.
CustomFileNameStr
— File name customization macro
'$N$M' (default) | character vector
Macro that specifies the customization of generated file names with additional characters and tokens. For more information, see Customize C/C++ File Names Generated from MATLAB Code (Embedded Coder).
CustomFFTCallback
— Callback class for FFTW library calls
' ' (default) | character vector
Callback class for FFTW library calls in code generated for FFT functions in MATLAB code, specified as a character vector.
To improve the execution speed of FFT functions, the code generator produces calls to the FFTW library that you specify in the callback class. If this parameter is empty, the code generator uses its own algorithms for FFT functions instead of calling the FFTW library.
UseBuiltinFFTWLibrary
takes precedence overCustomFFTCallback
if you enable both these properties.
See Speed Up Fast Fourier Transforms in Generated Standalone Code by Using FFTW Library Calls.
— Custom code that appears at top of generated C/C++ header files
' ' (default) | character vector
Custom code that appears near the top of each C/C++ header file generated from your MATLAB code, except rtwtypes.h
andrtwhalf.h
, specified as a character vector.
CustomInclude
— Include folders to add to include path for compiling generated code
' ' (default) | string array | cell array of character vectors | character vector
Include folders to add to the include path when compiling the generated code. Specify the list of include folders as a string array, cell array of character vector, or character vector.
To specify a single include folder, you can use a character vector or a string scalar.
To specify multiple folder names, use one of the values in this table.
Value | Description |
---|---|
String array | A string array inCustomInclude. For example,cfg.CustomInclude = ["C:\Project","C:\Custom Files"]; |
Cell array of character vectors | A cell array of character vectors inCustomInclude. For example,cfg.CustomInclude = {'C:\Project','C:\Custom Files'}; |
CustomInitializer
— Custom code to include in the generated initialize function
' ' (default) | character vector
Custom code to include in the generated initialize function, specified as a character vector.
CustomLAPACKCallback
— LAPACK callback class
' ' (default) | character vector
Callback class for LAPACK library calls in code generated for certain linear algebra functions in MATLAB code, specified as a character vector.
If you specify a LAPACK callback class, for certain linear algebra functions, the code generator produces LAPACK calls by using the LAPACKE C interface to your LAPACK library. The callback class provides the name of your LAPACKE header file and the information required to link to your LAPACK library. If this parameter is empty, the code generator produces code for linear algebra functions instead of a LAPACK call.
See Speed Up Linear Algebra in Generated Standalone Code by Using LAPACK Calls.
CustomLibrary
— Static library files to link with the generated code
' ' (default) | string array | cell array of character vectors | character vector
Static library files to link with the generated code, specified as a string array, cell array of character vector, or character vector.
To specify a single static library file, you can use a character vector or a string scalar.
To specify multiple static library file names, use one of the values in this table.
Value | Description |
---|---|
String array | A string array inCustomLibrary. For example,cfg.CustomLibrary = ["myLib1.lib","myLib2.lib"]; |
Cell array of character vectors | A cell array of character vectors inCustomLibrary. For example,cfg.CustomLibrary = {'myLib1.lib','myLib2.lib'}; |
CustomSource
— Source files to compile and link with the generated code
' ' (default) | string array | cell array of character vectors | character vector
Source files to compile and link with the generated code, specified as a string array, cell array of character vector, or character vector.
The build process searches for the source files first in the current folder, and then in the include folders that you specify inCustomInclude
. If source files with the same name occur in multiple folders on the search path, the build process might use a different file than the file that you specified.
Suppose that you specify foo.cpp
as a source file. Iffoo.c
and foo.cpp
are both on the search path, you cannot be sure whether the build process usesfoo.c
or foo.cpp
.
To specify a single source file, you can use a character vector or a string scalar.
To specify multiple source file names, use one of the values in this table.
Value | Description |
---|---|
String array | A string array inCustomSource. For example,cfg.CustomSource = ["mySrc1.c","mySrc2.c"]; |
Cell array of character vectors | A cell array of character vectors inCustomSource. For example,cfg.CustomSource = {'mySrc1.c','mySrc2.c'}; |
CustomSourceCode
— Code to appear near the top of generated .c
or .cpp
files
' ' (default) | character vector
Specify code to appear near the top of each generated.c
or .cpp
file (exceptrtwhalf.c
or rtwhalf.cpp
), outside of any function. Specify code as a character vector.
Do not specify a C static function definition.
CustomSymbolStrEMXArray
— Custom identifier format for EMX array types
'emxArray_$M$N'
(default) | character vector
Custom identifier format for generated EMX Array types (Embeddable mxArray types), specified as a character vector. To specify the format, see Customize Generated Identifiers (Embedded Coder).
CustomSymbolStrEMXArrayFcn
— Custom identifier format for EMX array utility functions
'emx$M$N'
(default) | character vector
Custom identifier format for generated EMX Array (Embeddable mxArrays) utility functions, specified as a character vector. To specify the format, see Customize Generated Identifiers (Embedded Coder).
CustomSymbolStrFcn
— Custom identifier format for local function identifiers
'm_$M$N'
(default) | character vector
Custom identifier format for generated local function identifiers, specified as a character vector. To specify the format, see Customize Generated Identifiers (Embedded Coder).
CustomSymbolStrField
— Custom identifier format for field names in global type identifiers
'$M$N'
(default) | character vector
Custom identifier format for generated field names in global type identifiers, specified as a character vector. To specify the format, seeCustomize Generated Identifiers (Embedded Coder).
CustomSymbolStrGlobalVar
— Custom identifier format for global variable identifiers
'$M$N'
(default) | character vector
Custom identifier format for generated global variable identifiers, specified as a character vector. To specify the format, see Customize Generated Identifiers (Embedded Coder).
CustomSymbolStrMacro
— Custom identifier format for constant macro identifiers
'$M$N'
(default) | character vector
Custom identifier format for generated constant macro identifiers, specified as a character vector. To specify the format, see Customize Generated Identifiers (Embedded Coder).
CustomSymbolStrTmpVar
— Custom identifier format for local temporary variable identifiers
'$M$N'
(default) | character vector
Custom identifier format for generated local temporary variable identifiers, specified as a character vector. To specify the format, seeCustomize Generated Identifiers (Embedded Coder).
CustomSymbolStrType
— Custom identifier format for global type identifiers
'$M$N'
(default) | character vector
Custom identifier format for generated global type identifiers, specified as a character vector. To specify the format, see Customize Generated Identifiers (Embedded Coder).
CustomTerminator
— Code that appears in the generated terminate function
' ' (default) | character vector
Code that appears in the generated terminate function, specified as a character vector.
CustomToolchainOptions
— Custom settings for tools in selected toolchain
cell array
Custom settings for tools in selected toolchain, specified as a cell array.
Dependencies:
- The
Toolchain
property determines which tools and options appear in the cell array. - Setting the
BuildConfiguration
property toSpecify
enablesCustomToolchainOptions
.
First, get the current settings. For example:
cfg = coder.config('lib'); cfg.BuildConfiguration='Specify'; opt = cfg.CustomToolchainOptions
Then, edit the values in opt
.
These values derive from the toolchain definition file and the third-party compiler options. See Custom Toolchain Registration.
DataTypeReplacement
— Data type replacement in generated code
'CBuiltIn'
| 'CoderTypeDefs'
Data type replacement in generated code, specified as one of the values in this table.
Value | Description |
---|---|
'CBuiltIn' | This value is the default value.The code generator uses built-in C data types. |
'CoderTypeDefs' | The code generator uses predefined data types fromrtwtypes.h |
DeepLearningConfig
— Configuration object for deep learning code generation
coder.MklDNNConfig
object | coder.ARMNEONConfig
object | coder.CuDNNConfig
object | coder.TensorRTConfig
object
Configuration object for code generation for deep learning networks, specified as specified as one of the objects in this table.
Dependency: If DeepLearningConfig
is set,codegen
sets TargetLang
toC++
.
Description
— Object description
'class CodeConfig: C code generation configuration.'
(default) | character vector
Object description, specified as a character vector.
DynamicMemoryAllocation
— Dynamic memory allocation mode
'Threshold'
(default) | 'AllVariableSizeArrays'
| 'Off'
Dynamic memory allocation mode, specified as one of the values in this table.
Value | Description |
---|---|
'Threshold' | This value is the default value.The code generator allocates memory dynamically on the heap for variable-size arrays whose size (in bytes) is greater than or equal toDynamicMemoryAllocationThreshold. |
'AllVariableSizeArrays' | The code generator dynamically allocates memory for all variable-size arrays on the heap. |
'Off' | The code generator statically allocates memory for variable-size arrays on the stack. |
Unbounded variable-size arrays require dynamic memory allocation.
Dependencies:
EnableVariableSizing
enables this parameter.- Setting this
DynamicMemoryAllocation
to'Threshold'
enables theDynamicMemoryAllocationThreshold
parameter.
See Generate Code for Variable-Size Data.
Note
DynamicMemoryAllocation
configuration option will be removed in a future release. To dynamically allocation memory for variable-sized arrays, use theEnableDynamicMemoryAllocation
option. To set the threshold, use theDynamicMemoryAllocationThreshold
option.
DynamicMemoryAllocationForFixedSizeArrays
— Dynamic memory allocation for fixed-size arrays
false
(default) | true
Dynamic memory allocation for fixed-size arrays, specified as one of the values in this table.
Value | Description |
---|---|
true | The code generator allocates memory dynamically on the heap for fixed-size arrays whose size (in bytes) is greater than or equal toDynamicMemoryAllocationThreshold. |
false | This value is the default value.The code generator statically allocates memory for fixed-size arrays on the stack. |
Dependency:
- Setting
EnableDynamicMemoryAllocation
totrue
enables this option.
See, Control Dynamic Memory Allocation for Fixed-Size Arrays.
DynamicMemoryAllocationInterface
— Dynamically allocated array at generated function interface
'Auto'
(default) | 'C'
| 'C++'
Implementation of dynamically allocated array at the interface of the generated C/C++ function, specified as one of the values in this table.
When using GPU Coder, the code generator always uses the C style emxArray
data structure.
Dependency:
EnableVariableSizing
enables this parameter.
DynamicMemoryAllocationThreshold
— Size threshold for dynamic memory allocation of variable-size arrays
65536
(default) | positive integer
Size threshold for dynamic memory allocation of fixed-size and variable-size arrays, specified as a positive integer. The code generator uses dynamic memory allocation for fixed-size and variable-size arrays whose size (in bytes) is greater than or equal to the threshold.
Dependency:
- Setting
DynamicMemoryAllocation
to'Threshold'
enables this parameter.
See Generate Code for Variable-Size Data.
EnableAutoExtrinsicCalls
— Automatic extrinsic function calls
true
(default) | false
Automatic extrinsic function calls, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator treats some common visualization functions as extrinsic functions. You do not have to declare these functions as extrinsic by using coder.extrinsic. This capability reduces the amount of time that you spend making your code suitable for code generation. |
false | The code generator does not treat common visualization functions as extrinsic functions unless you declare them as extrinsic by using coder.extrinsic |
Some common visualization functions are plot
,disp
, and figure
. See Use MATLAB Engine to Execute a Function Call in Generated Code.
EnableAutoParallelization
— Automatic parallelization of for
loops
false
(default) | true
Automatic parallelization of for
loops, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.Code generator does not automatically parallelizefor loops. |
true | The code generator automatically parallelizesfor loops in the generated code. Automatic parallelization can significantly improve the execution speed of the generated code. See Automatically Parallelize for Loops in Generated Code. |
When using GPU Coder, the code generator always enables automatic parallelization of for
loops.
Data Types: logical
EnableAutoParallelizationReporting
— Reporting for automatic parallelization of for
loops
true
(default) | false
Reporting for automatic parallelization of for
loops, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.If you set EnableAutoParallelization to true, the code generator produces a code generation report for automatic parallelization of for loops |
false | The code generator does not produce a code generation report for automatic parallelization offor loops. |
EnableCustomReplacementTypes
— Custom names for data types in generated code
false
(default) | true
Custom names for MATLAB data types in generated C/C++ code, specified as one of the values in the table.
Value | Description |
---|---|
false | This value is the default value.Custom names for the MATLAB data types are not allowed. |
true | Custom names for the MATLAB data types are allowed. Specify custom names by using ReplacementTypes. SettingEnableCustomReplacementTypes totrue enables theReplacementTypes parameter. |
EnableDynamicMemoryAllocation
— Enable dynamic memory allocation for variable-size arrays
true
(default) | false
Dynamic memory allocation for variable-size arrays, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator allocates memory dynamically on the heap for variable-size arrays whose size (in bytes) is greater than or equal toDynamicMemoryAllocationThreshold. |
false | The code generator statically allocates memory for variable-size arrays on the stack. |
EnableImplicitExpansion
— Implicit expansion capabilities in generated code
true
(default) | false
Implicit expansion capabilities in the generated code, specified as one of the values listed in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator enables implicit expansion in the generated code. The code generator includes modifications in the generated code to apply implicit expansion. See Compatible Array Sizes for Basic Operations. |
false | The generated code does not follow the rules of implicit expansion. |
Data Types: logical
EnableMemcpy
— memcpy
optimization
true
(default) | false
memcpy
optimization, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.If possible, the code generator uses thememcpy optimization. To optimize code that copies consecutive array elements, the memcpy optimization replaces the code with a memcpy call. When the number of elements to copy is known at compile time, the code generator uses theMemcpyThreshold property to determine whether to use the optimization. See memcpy Optimization. |
false | The code generator does not use thememcpy optimization. |
When using GPU Coder, the code generator always disables Memcpy
optimization.
EnableOpenMP
— Parallelization of parfor
-loops
true
(default) | false
Parallelization of parfor
-loops, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.If possible, the code generator uses the OpenMP library to produce loop iterations that run in parallel. |
false | The code generator treatsparfor-loops asfor-loops. |
See parfor.
Use of the OpenMP library is not compatible with just-in-time (JIT) compilation. If EnableJIT
andEnableOpenMP
are true
, the code generator uses JIT compilation and treats parfor
-loops asfor
-loops.
When using GPU Coder, the code generator always treats parfor
-loops asfor
-loops.
EnableRuntimeRecursion
— Run-time recursion support
true
(default) | false
Run-time recursion support, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.Recursive functions are allowed in the generated code. |
false | Recursive functions are not allowed in the generated code. |
Some coding standards, such as MISRA, do not allow recursion. To increase the likelihood of generating code that is compliant with MISRA C™, set EnableRuntimeRecursion
tofalse
.
If your MATLAB code requires run-time recursion andEnableRuntimeRecursion
is false
, code generation fails.
See Code Generation for Recursive Functions.
EnableSignedLeftShifts
— Replacement of multiplications by powers of two with signed left bitwise shifts
true
(default) | false
Replacement of multiplications by powers of two with signed left bitwise shifts in the generated C/C++ code, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator uses signed left shifts for multiplication by powers of two. An example of generated C code that uses signed left shift for multiplication by eight is:i <<= 3; |
false | The code generator does not use signed left shifts for multiplication by powers of two. An example of generated C code that does not use signed left shift for multiplication by eight is:i = i * 8; |
GPU Coder always sets theEnableSignedLeftShifts
property to true.
Some coding standards, such as MISRA, do not allow bitwise operations on signed integers. To increase the likelihood of generating MISRA C compliant code, set EnableSignedLeftShifts
to false
.
See Control Signed Left Shifts in Generated Code (Embedded Coder).
EnableSignedRightShifts
— Signed right bitwise shifts in generated code
true
(default) | false
Signed right bitwise shifts in generated code, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator uses signed right shifts. An example of generated C code that uses a signed right shift is:i >>= 3 |
false | The code generator replaces right shifts on signed integers with a function call in the generated code. For example:i = asr_s32(i, 3U); |
GPU Coder always sets theEnableSignedRightShifts
property to true.
Some coding standards, such as MISRA, do not allow bitwise operations on signed integers. To increase the likelihood of generating MISRA-C:2004 compliant code, setEnableSignedRightShifts
tofalse
.
EnableStrengthReduction
— Strength reduction optimization
false
(default) | true
Strength reduction optimization, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.The code generator does not use the strength reduction optimization. |
true | The code generator tries to use the strength reduction optimization to simplify array indexing in loops in the generated code. When possible, for array indices in loops, the code generator replaces multiply operations with add operations. Multiply operations can be expensive. When the C/C++ compiler on the target platform does not optimize the array indexing, the strength reduction optimization is useful. Even when the optimization replaces the multiply operations in the generated code, it is possible that the C/C++ compiler can generate multiply instructions. |
EnableTraceability
— Traceability in code generation report
true (default) | false
Traceability in code generation report, specified as one of the values in this table.
EnableVariableSizing
— Variable-size array support
true
(default) | false
Variable-size array support, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.Variable-size arrays are allowed for code generation. |
false | Variable-size arrays are not allowed for code generation. |
Dependency:
- Enables
Dynamic memory allocation
.
See Code Generation for Variable-Size Arrays.
FilePartitionMethod
— File partitioning mode
'MapMFileToCFile'
(default) | 'SingleFile'
File partitioning mode specified as one of the values in this table.
Value | Description |
---|---|
'MapMFileToCFile' | This value is the default value.The code generator produces separate C/C++ files for each MATLAB language file. |
'SingleFile' | The code generator produces a single file for C/C++ functions that map to your MATLAB entry-point functions. The code generator produces separate C/C++ files for utility functions. |
See How MATLAB Coder Partitions Generated Code.
GenerateCodeMetricsReport
— Static code metrics report
false
(default) | true
Static code metrics report, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.The code generator does not run static code metrics analysis at code generation time. You can run the analysis and produce the report later by clicking Code Metrics on theSummary tab of the code generation report. |
true | The code generator runs static code metrics analysis and produces the report at code generation time. |
To open a code metrics report, click the Code Metrics link on the Summary tab of the code generation report.
Dependency:
- The code generator produces a static code metrics report only if GenerateReport is
true
or if you specify the-report
option of thecodegen
report.
See Generating a Static Code Metrics Report for Code Generated from MATLAB Code (Embedded Coder).
GenCodeOnly
— Generation of only source code
false
(default) | true
Generation of only source code, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value. The code generator produces C/C++ source code and builds object code. |
true | The code generator produces C/C++ source code, but does not invoke the make command or build object code. When you iterate between modifying MATLAB code and generating C/C++ code, generating only code can save time. |
GenerateCodeReplacementReport
— Code replacement report
false
(default) | true
Code replacement report, specified as on of the values in this table.
Value | Description |
---|---|
false | This value is the default value.The code generator does not produce a code replacements report. |
true | The code generator produces a code replacements report that summarizes the replacements from the selected code replacement library. The report provides a mapping between each code replacement instance and the line of MATLAB code that triggered the replacement. |
— Comments in generated code
true
(default) | false
Comments in generated code, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator places comments in the generated code. |
false | The code generator does not place comments in the generated code. |
If you set GenerateComments
to true
, the code generator places default comments, such as inferred argument types, in the generated code. The code generator also copies code comments that you make inside your MATLAB functions into the generated code, with some exceptions. For example, the generated code generally does not include code comments from MATLAB functions that are removed due to internal optimizations.
If you generate code for a live function (.mlx
file), the code generator does not include the text sections in the generated code, even if GenerateComments
is set totrue
. To include live function text sections as comments in the generated code, first save the .mlx
file as a .m
file, which converts the text sections to code comments within the function body. Because the code generator gives precedence to functions in .mlx
files over those in.m
files, you must rename one of the functions or move one of the files to a different folder. Then, generate code for the function in the .m
file. The code generator includes the text sections as comments in the generated code.
GenerateDefaultInSwitch
— Default case for all switch statements
false
(default) | true
Default case for all switch statements, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.The code generator might not generate a default case for some switch statements. |
true | The code generator produces a default case for all switch statements in the generated code. |
Some coding standards, such as MISRA, require the default case for switch statements.
GenerateExampleMain
— Example C/C++ main file generation
'GenerateCodeOnly'
(default) | 'DoNotGenerate'
| 'GenerateCodeAndCompile'
Example C/C++ main file generation, specified as one of the values in this table.
Value | Description |
---|---|
'GenerateCodeOnly' | This value is the default value.The code generator generates an example C/C++ main function but does not compile it. |
'DoNotGenerate' | The code generator does not generate an example C/C++ main function. |
'GenerateCodeAndCompile' | The code generator generates an example C/C++ main function and compiles it to create a test executable. This executable does not return output.If the GenCodeOnly parameter istrue, the code generator does not compile the C/C++ main function. |
An example main function is a template to help you to write a C/C++ main function that calls generated C/C++ code. See Incorporate Generated Code Using an Example Main Function.
GenerateMakefile
— Makefile generation
true
(default) | false
Makefile generation during the build process, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator generates a makefile during the build process. |
false | The code generator does not generate a makefile during the build process. Specify instructions for post-code-generation processing, including compilation and linking, in a post-code-generation command. SeeBuild Process Customization. |
GenerateNonFiniteFilesIfUsed
— Generate support files for nonfinite data only if nonfinite data is used
true
(default) | false
Generation of support files for nonfinite data, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator produces the support files for nonfinite data (Inf andNaN) only if the generated code uses nonfinite data. |
false | The code generator always produces the support files for nonfinite data (Inf andNaN). |
Dependency:
- Setting
SupportNonFinite
totrue
enables this parameter.
GenerateReport
— Code generation report
false
(default) | true
Code generation report, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.The code generator produces a report only if error or warning messages occur, or if you set LaunchReport totrue. |
true | The code generator produces a code generation report. |
GpuConfig
— Configuration object for GPU code generation
GpuCodeConfig
object
Configuration object for generating CUDA GPU code using GPU Coder. A GpuCodeConfig
object contains parameters specific to CUDA GPU code generation. To create aGpuCodeConfig
object, use coder.gpuConfig (GPU Coder). For example:
cfg = coder.gpuConfig('lib'); cfg.GpuConfig
ans =
GpuCodeConfig with properties:
Enabled: 1
MallocMode: 'discrete'
KernelNamePrefix: ''
EnableCUBLAS: 1
EnableCUSOLVER: 1
EnableCUFFT: 1
Benchmarking: 0
SafeBuild: 0
ComputeCapability: 'Auto'
CustomComputeCapability: ''
CompilerFlags: ''
StackLimitPerThread: 1024
MallocThreshold: 200
MaximumBlocksPerKernel: 0
EnableMemoryManager: 1
SelectCudaDevice: -1
For more information, see Generate Code Using the Command Line Interface (GPU Coder).
Dependencies: If GpuConfig
is set,codegen
modifies thecoder.EmbeddedCodeConfig
properties to values in this table.
Hardware
— Object that specifies a hardware board
coder.Hardware
object
Object that specifies a hardware board. To create the coder.Hardware
object, use coder.hardware. For example:
cfg = coder.config('lib'); hw = coder.hardware('Raspberry Pi'); cfg.Hardware = hw;
Before you use coder.hardware
, you must install the support package for the hardware board.
Dependencies:
- Setting
Hardware
customizes the hardware implementation object and other configuration parameters for a particular hardware board. - If
DeepLearningConfig
is set to acoder.ARMNEONConfig
object andHardware
is empty, thencodegen
sets theGenCodeOnly
property totrue
.
Note:
- Suppose that you create a
coder.CodeConfig
objectcfg
in a MATLAB session and use it in another MATLAB session. If the MATLAB host computer for the second session does not have the hardware board specified in thecfg.Hardware
property installed on it, this parameter reverts to its default value. The default value is[]
. Setting the Hardware Board option toMATLAB Host Computer
in the app is equivalent to usingcfg.Hardware
andcfg.HardwareImplementation.ProdHWDeviceType
with their default value.
To specify a hardware board for PIL execution, see PIL Execution with ARM Cortex-A at the Command Line (Embedded Coder).
HardwareImplementation
— Hardware implementation object
coder.HardwareImplementation
object
Hardware implementation object that specifies hardware-specific configuration parameters for C/C++ code generation. coder.config creates acoder.EmbeddedCodeConfig
object with theHardwareImplementation
property set to a coder.HardwareImplementation object with default parameter values for the MATLAB host computer.
— Style of preprocessor directive in generated code
UseIncludeGuard
(default) | UsePragmaOnce
To prevent compilation errors due to multiple inclusion of header files, the code generator produces either #ifndef
or#pragma once
constructs in generated header files. If your project uses distinct files that use the same preprocessor macros, then generate code with the #pragma once
construct. The compilation behavior of #pragma once
is not standardized.
Specify HeaderGuardStyle
as one of the values in this table.
Value | Description |
---|---|
UseIncludeGuard | The code generator produces#ifndef style#include guards. |
UsePragmaOnce | The code generator produces #pragma once style #include guards. |
HighlightPotentialDataTypeIssues
— Highlighting of potential data type issues in the code generation report
false
(default) | true
Highlighting of potential data type issues in the code generation report, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.This code generation report does not highlight potential data type issues. |
true | The code generation report highlights MATLAB code that results in single-precision or double-precision operations in the generated C/C++ code. If you have Fixed-Point Designer™, the report also highlights expressions in the MATLAB code that result in expensive fixed-point operations in the generated code. |
HighlightPotentialRowMajorIssues
— Potential row-major layout issues
true
(default) | false
Display of potential row-major layout efficiency issues, specified as one of the values in this table.
Value | Description |
---|---|
true | The code generation report displays potential efficiency issues due to row-major layout. (This value is the default value.) |
false | The code generation report does not display issues related to array layout. |
See Code Design for Row-Major Array Layout.
IncludeInitializeFcn
— Initialize function generation
true
(default) | false
Initialize function generation, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator produces an initialize function. |
false | The code generator does not produce an initialize function. If you setIncludeInitializeFcn tofalse and an initialize function is required, for example, to call supporting code for nonfinite data (Inf orNaN), the code generator produces an error message.See MATLAB Code Patterns That Require a Nonempty Initialize Function in Generated Code (Embedded Coder). |
When using GPU Coder, the code generator always produces an initialize function.
IncludeTerminateFcn
— Terminate function generation
true
(default) | false
Terminate function generation, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator produces a terminate function. |
false | The code generator does not produce a terminate function. If you setIncludeTerminateFcn tofalse and a terminate function is required, for example, to free memory, the code generator issues a warning. |
When using GPU Coder, the code generator always produces an terminate function.
IndentSize
— Number of characters per indentation level
2 (default) | positive integer
Number of characters per indentation level, specified as a positive integer in the range [2,8].
IndentStyle
— Style for placement of braces in the generated code
'K&R'
(default) | 'Allman'
Style for placement of braces in the generated code, specified as one of the values in this table.
Value | Description |
---|---|
'K&R' | This value is the default value.For blocks within a function, an opening brace is on the same line as its control statement. For example:void addone(const double x[6], double z[6]) { int i0; for (i0 = 0; i0 < 6; i0++) { z[i0] = x[i0] + 1.0; } } |
'Allman' | For blocks within a function, an opening brace is on its own line at the same indentation level as its control statement. For example:void addone(const double x[6], double z[6]) { int i0; for (i0 = 0; i0 < 6; i0++) { z[i0] = x[i0] + 1.0; } } |
InitFltsAndDblsToZero
— Assignment of float and double zero with memset
true
(default) | false
Assignment of float and double zero with memset
, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.If possible, the code generator uses thememset optimization for assignment of floating-point zero to consecutive array elements. To assign consecutive array elements, the memset optimization uses a memset call. When the number of elements to assign is known at compile time, the code generator uses theMemcpyThreshold property to determine whether to use the optimization. See memset Optimization. |
false | The code generator does not use thememset optimization for assignment of float and double zero to consecutive array elements. |
InlineBetweenMathWorksFunctions
— Control inlining between MathWorks functions
'Speed'
(default) | 'Always'
| 'Readability'
| 'Never'
Inlining behavior at all call sites where a MathWorks calls another MathWorks function, specified as one of the values in this table.
Value | Description |
---|---|
'Speed' | This value is the default value.Uses internal heuristics to determine whether to perform inlining at a call site. This setting usually leads to highly optimized code. |
'Always' | Always performs inlining at a call site. |
'Readability' | Almost never inlines function calls, except for calls to very small functions. Preserves modularity of code without sacrificing too much speed, whenever possible. Results in highly readable code. |
'Never' | Never inlines function calls. Results in maximum readability. This setting might significantly reduce the performance of the generated code. |
Even if you select the 'Always'
or the'Never'
option for a setting, in certain cases, the code generator might not strictly follow that instruction. For example, if there is a conflict, the coder.inline('always')
orcoder.inline('never')
directive placed inside a function body overrides this option. For more information, see Control Inlining to Fine-Tune Performance and Readability of Generated Code.
InlineBetweenUserAndMathWorksFunctions
— Control inlining between user-written functions and MathWorks functions
'Readability'
(default) | 'Always'
| 'Speed'
| 'Never'
Inlining behavior at all call sites where a function that you wrote calls a MathWorks function, or a MathWorks function calls a function that you wrote. Specified as one of the values in this table.
Value | Description |
---|---|
'Readability' | This value is the default value.Almost never inlines function calls, except for calls to very small functions. Preserves modularity of code without sacrificing too much speed, whenever possible. Results in highly readable code. |
'Always' | Always performs inlining at a call site. |
'Speed' | Uses internal heuristics to determine whether to perform inlining at a call site. This setting usually leads to highly optimized code. |
'Never' | Never inlines function calls. Results in maximum readability. This setting might significantly reduce the performance of the generated code. |
Even if you select the 'Always'
or the'Never'
option for a setting, in certain cases, the code generator might not strictly follow that instruction. For example, if there is a conflict, the coder.inline('always')
orcoder.inline('never')
directive placed inside a function body overrides this option. For more information, see Control Inlining to Fine-Tune Performance and Readability of Generated Code.
InlineBetweenUserFunctions
— Control inlining between user-written functions
'Speed'
(default) | 'Always'
| 'Readability'
| 'Never'
Inlining behavior at all call sites where a function that you wrote calls another function that you wrote, specified as one of the values in this table.
Value | Description |
---|---|
'Speed' | This value is the default value.Uses internal heuristics to determine whether to perform inlining at a call site. This setting usually leads to highly optimized code. |
'Always' | Always performs inlining at a call site. |
'Readability' | Almost never inlines function calls, except for calls to very small functions. Preserves modularity of code without sacrificing too much speed, whenever possible. Results in highly readable code. |
'Never' | Never inlines function calls. Results in maximum readability. This setting might significantly reduce the performance of the generated code. |
Even if you select the 'Always'
or the'Never'
option for a setting, in certain cases, the code generator might not strictly follow that instruction. For example, if there is a conflict, the coder.inline('always')
orcoder.inline('never')
directive placed inside a function body overrides this option. For more information, see Control Inlining to Fine-Tune Performance and Readability of Generated Code.
InstructionSetExtensions
— SIMD instruction set for target hardware
'Auto'
(default) | 'SSE'
| 'SSE2'
| 'SSE4.1'
| 'AVX'
| 'AVX2'
| 'FMA'
| 'AVX512F'
| 'Neon v7'
| 'None'
Instruction sets to generate single instruction, multiple data (SIMD) code for target hardware. This list shows the dependency of the instruction sets, where each instruction set depends on the instruction sets that precede it. The code generator loads the selected instruction set and the instruction sets that it depends on. For example, if you select AVX
, the code generator loads AVX
, SSE4.1
,SSE2
, and SSE
.
If you select Auto
, the default setting, the code generator selects an instruction set according to your hardware board:
- MATLAB Host Computer, Intel, or AMD® -
SSE2
- ARM
-None
See Generate SIMD Code from MATLAB Functions for Intel Platforms.
When using GPU Coder, the code generator always disables InstructionSetExtensions
.
InstructionSetExtensionsConfig
— Options for SIMD instruction sets
InstructionSetExtensionsConfig
object
Options for the SIMD instruction sets of theInstructionSetExtensions
setting, specified as aInstructionSetExtensionsConfig
object. Use the properties of the object to specify the options for the instruction sets. This parameter is applicable for only the instruction set Neon v7
.
Example: 'InstructionSetExtensionsConfig.FMA = true'
FMA
— Whether to use SIMD instructions for fused multiply add operations
false
(default) | true
Whether to use SIMD instructions from theInstructionSetExtensions
setting for fused multiply add operations, specified astrue
or false
.
JustifyMISRAViolations
— Add annotations to suppress known MISRA/AUTOSAR violations
false
(default) | true
Annotates the generated C/C++ code to suppress known MISRA and AUTOSAR violations, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.The code generator does not add annotations to the generated C/C++ code. |
true | The code generator adds annotations to the generated C/C++ code only if GenerateComments is also true. |
LargeConstantGeneration
— Whether to write large deep learning constants to binary data files
'WriteOnlyDNNConstantsToDataFiles'
(default) | 'KeepInSourceFiles'
Whether the code generator embeds large constants for a deep neural network (DNN) in the generated source code or writes these constants to binary data files, specified as one of the values in the following table. To specify the threshold (in bytes) above which the DNN constants are written to binary data files, set the LargeConstantThreshold
property. The default value of this property is131072
.
This property is applicable only if you generate code that does not depend on third-party deep learning libraries.
Value | Description |
---|---|
'WriteOnlyDNNConstantsToDataFiles' | This value is the default value.The code generator writes large constants for a deep neural network (DNN) in binary data files. |
'KeepInSourceFiles' | The code generator embeds large constants for a deep neural network (DNN) in the generated source code. |
The generated binary data files are located in the code generation folder and are loaded by the generated code at run time. If you relocate these files, set the environment variable CODER_DATA_PATH
to this new location before running the generated code.
The code generator always embeds the non-DNN constants in the generated source code, irrespective of the sizes of these constants.
Dependency:
EnableDynamicMemoryAllocation
enables this parameter.
LargeConstantThreshold
— Threshold above which the code generator writes DNN constants to binary data files
131072
(default) | integer
The LargeConstantThreshold
property specifies the threshold (in bytes) above which the constants for a deep neural network (DNN) are written to binary data files. The code generator by default sets this threshold to 131072 bytes. Depending on your application, you can set this threshold to a different integer value.
This property is applicable only if you generate code that does not depend on third-party deep learning libraries.
Dependencies: To enable this property, perform both these actions.
- Set
EnableDynamicMemoryAllocation
totrue
. - Set
LargeConstantGeneration
to'WriteOnlyDNNConstantsToDataFiles'
.
LaunchReport
— Automatic open of code generation report
false
(default) | true
Automatic open of code generation report, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.If errors or warnings occur, or ifGenerateReport istrue, the code generator produces a report, but does not open the report. |
true | The code generator produces and opens a code generation report. |
LoopUnrollThreshold
— Threshold on the number of iterations that determines whether to automatically unroll a for
-loop and aparfor
-loop
5 (default) | positive integer
Loops with fewer iterations than this threshold are candidates for automatic unrolling by the code generator. This threshold applies to allfor
-loops and parfor
-loops in your MATLAB code. For an individual for
-loop, acoder.unroll directive placed immediately before the loop takes precedence over the loop unrolling optimization. The threshold can also apply to somefor
-loops produced during code generation.
See Unroll for-Loops and parfor-Loops.
MATLABFcnDesc
— MATLAB function help text in function banner
true
(default) | false
MATLAB function help text in function banner in generated code specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator includes MATLAB function help text in the function banner in the generated code. |
false | The code generator treats the help text as a user comment. |
If not selected, MATLAB Coder treats the help text as a user comment.
Dependencies:
GenerateComments
enables this parameter.
— Inclusion of MATLAB source code as comments in generated code
false
(default) | true
Inclusion of MATLAB source code as comments in generated code, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.The code generator does not insert MATLAB source code as comments in the generated code. The code generator does not include the MATLAB function signature in the function banner. |
true | The code generator inserts MATLAB source code as comments in the generated code. A traceability tag immediately precedes each line of source code. The traceability tag helps you to locate the corresponding MATLAB source code. See Tracing Generated C/C++ Code to MATLAB Source Code.If you have Embedded Coder, in the code generation report, the traceability tag links to the source code.The code generator also includes the MATLAB function signature in the function banner. |
Dependency:
GenerateComments
enables this parameter.
See Tracing Generated C/C++ Code to MATLAB Source Code.
— Include line numbers of MATLAB source code as comments in the generated code
true
(default) | false
Whether to include line numbers of MATLAB source code as comments in the generated code, specified astrue
or false
. Setting this property to false
removes traceability tags from the code generation report.
Dependency:
- Setting
GenerateComments
totrue
enables this parameter.
MaxIdLength
— Maximum number of characters in generated identifiers
31
| 1024 | positive integer
Maximum number of characters in generated identifiers, specified as a positive integer in the range [31, 2048]. This property applies to generated function, type definition, and variable names. To avoid truncation of identifiers by the target C/C++ compiler, specify a value that matches the maximum identifier length of the target C/C++ compiler.
This property does not apply to exported identifiers, such as the generated names for entry-point functions or emxArray API functions. If the length of an exported identifier exceeds the maximum identifier length of the target C/C++ compiler, the target C/C++ compiler truncates the exported identifier.
Default values:
- If
TargetLang
is set to'C'
, the default value ofMaxIdLength
is31
. - If
TargetLang
is set to'C++'
, the default value ofMaxIdLength
is1024
.
MemcpyThreshold
— Minimum size for memcpy
or memset
optimization
64 (default) | positive integer
Minimum size, in bytes, for memcpy or memset optimization, specified as a positive integer.
To optimize generated code that copies consecutive array elements, the code generator tries to replace the code with a memcpy
call. To optimize generated code that assigns a literal constant to consecutive array elements, the code generator tries to replace the code with a memset
call.
The number of bytes is the number of array elements to copy or assign multiplied by the number of bytes required for the C/C++ data type.
If the number of elements to copy or assign is variable (not known at compile time), the code generator ignores theMemcpyThreshold
property.
See memcpy Optimization and memset Optimization.
MultiInstanceCode
— Multi-instance, reentrant code
false
(default) | true
Multi-instance, reentrant code, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.The code generator does not produce multi-instance, reentrant code. |
true | The code generator produces reusable, multi-instance code that is reentrant. |
See Reentrant Code.
This option is not supported by the GPU Coder product.
Name
— Object name
'EmbeddedCodeConfig'
(default) | character vector
Object name, specified as a character vector.
OptimizeReductions
— Generate SIMD code for reduction operations | Parallelize for-loops performing reduction operations
'false'
(default) | 'true'
To generate SIMD code for reduction operations, use one of the values as specified in this table.
Value | Description |
---|---|
false | This value is the default value.Code generator does not generate SIMD code for reduction operations. |
true | To use this parameter, you must select an instruction set for theInstructionSetExtensions parameter. The code generator uses the specified instruction set to generate SIMD code for reduction operations. |
See Generate SIMD Code from MATLAB Functions for Intel Platforms.
To generate parallel for
-loops performing reduction operations, use one of the values as specified in this table.
Value | Description |
---|---|
false | This value is the default value.Code generator does not automatically parallelizefor-loops performing reduction operations. |
true | The code generator automatically parallelizesfor-loops performing reduction operations in the generated code, only if you setEnableAutoParallelization totrue. |
See Reduction Operations Supported for Automatic Parallelization of for-loops.
OutputType
— Output to build from generated C/C++ code
'LIB'
| 'DLL'
| 'EXE'
Output to build from generated C/C++ code, specified as one of the values in this table.
Value | Description |
---|---|
'LIB' | Static library |
'DLL' | Dynamically linked library |
'EXE' | Executable program |
ParenthesesLevel
— Parenthesization level in the generated code
'Nominal'
(default) | 'Minimum'
| 'Maximum'
Parenthesization level in the generated code, specified as one of the values in this table.
Value | Description |
---|---|
'Nominal' | This value is the default value.The code generator inserts parentheses to balance readability and visual complexity. For example:Out = ((In2 - In1 > 1.0) && (In2 > 2.0)); |
'Maximum' | The code generator includes parentheses to specify meaning without relying on operator precedence. Code generated with this setting conforms to MISRA requirements. For example: Out = (((In2 - In1) > 1.0) && (In2 > 2.0)); |
'Minimum' | The code generator inserts parentheses where required by ANSI® C or C++, or to override default precedence. For example: Out = In2 - In1 > 1.0 && In2 > 2.0; If you generate C/C++ code that uses the minimum level, for certain settings in some compilers, you can receive compiler warnings. To eliminate these warnings, try the nominal level. |
PassStructByReference
— Pass structures by reference
true
(default) | false
Pass structures by reference to entry-point functions, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The generated code passes structures by reference, which reduces memory usage and execution time by minimizing the number of copies of parameters at entry-point function boundaries. NoteAn entry-point function that writes to a field of a structure parameter overwrites the input value. |
false | The generated code passes structures by value. |
This parameter applies only to entry-point functions.
See Pass Structure Arguments by Reference or by Value in Generated Code.
PostCodeGenCommand
— Command to customize build processing
''
(default) | character vector
Command to customize build processing after MEX function generation withcodegen
, specified as a character vector.
See Build Process Customization.
PreserveExternInFcnDecls
— Preservation of the extern
keyword in function declarations
true
(default) | false
Preservation of the extern
keyword in function declarations in the generated code, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator includes theextern keyword in declarations for external functions. |
false | The code generator removes theextern keyword from function declarations. |
PreserveArrayDimensions
— N-dimensional indexing
false
(default) | true
Generation of code that uses N-dimensional indexing, specified as one of the values in this table.
Value | Description |
---|---|
false | Generate code that uses one-dimensional indexing. (This value is the default value.) |
true | Generate code that uses N-dimensional indexing. |
See Generate Code That Uses N-Dimensional Indexing.
PreserveInputData
— Whether to protect entry-point input data from modification
false
(default) | true
Since R2024b
Whether to protect entry-point input data from modification when the generated code is called from your custom C/C+ code, specified asfalse
or true
. See Generate Code That Preserves Entry-Point Input Data.
If you enable this setting, the generated code might include extra copies of the input data. If you pass large-size data, this behavior might increase the execution time and memory use of the generated code.
If you generate code for a MATLAB entry-point function that uses the same variable as both an input and an output, the code generator does not preserve this input data even when you set the PreserveInputData
configuration property to true
. See Avoid Data Copies of Function Inputs in Generated Code.
PreserveUnusedStructFields
— Preserve unused class properties or structure fields in the generated C/C++ code
false
(default) | true
Preserve unused class properties or structure fields in the generated C/C++ code, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.The code generator produces the C/C++ code by removing the unused properties and fields in the generated code. |
true | The code generator produces the C/C++ code by preserving the unused properties and fields in the generated code. |
See Preserve Unused Class Properties in Generated C/C++ Code (Embedded Coder).
PreserveVariableNames
— Variable names to preserve in the generated code
'None'
(default) | 'UserNames'
| 'All'
Variable names to preserve in the generated code, specified as one of the values in this table.
Value | Description |
---|---|
'None' | This value is the default value.The code generator does not have to preserve any variable names. It can reuse any variables that meet the requirements for variable reuse.If your code uses large structures or arrays, settingPreserveVariableNames to'None' can reduce memory usage or improve execution speed. |
'UserNames' | The code generator preserves names that correspond to variables that you define in the MATLAB code. It does not replace your variable name with another name and does not use your name for another variable. To improve readability, setPreserveVariableNames to'UserNames'. Then, you can more easily trace the variables in the generated code back to the variables in your MATLAB code.SettingPreserveVariableNames to'UserNames' does not prevent an optimization from removing your variables from the generated code or prevent the C/C++ compiler from reusing the variables in the generated binary code. |
'All' | Preserve all variable names. This parameter value disables variable reuse. Use it only for testing or debugging, not for production code. |
See Preserve Variable Names in Generated Code.
PurelyIntegerCode
— Detection of floating-point code
false
(default) | true
Detection of floating-point code, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.The code generator allows floating-point data and operations. |
true | The code generator does not allow floating-point data or operations. If the code generator detects floating-point data or operations, code generation ends with an error. |
Dependency:
- Setting
PurelyIntegerCode
totrue
disables theSupportNonFinite
parameter. SettingPurelyIntegerCode
tofalse
enables theSupportNonFinite
parameter.
ReplacementTypes
— Specify custom names for MATLAB data types
coder.ReplacementTypes
object
Specify custom names for these MATLAB built-in data types: double
,single
, uint8
,uint16
, uint32
,uint64
, int8
,int16
, int32
,int64
, char
, andlogical
that are in the generated C/C++ code.
Dependency:
- Setting
EnableCustomReplacementTypes
totrue
enables theReplacementTypes
parameter. See Customize Data Type Replacement (Embedded Coder).
ReportInfoVarName
— Name of variable containing code generation report information
''
(default) | character vector
Name of variable to which you export information about code generation, specified as a character vector. The code generator creates this variable in the base MATLAB workspace. This variable contains information about code generation settings, input files, generated files, and code generation messages.
See Access Code Generation Report Information Programmatically andcoder.ReportInfo Properties.
ReportPotentialDifferences
— Potential differences reporting
true
(default) | false
Potential difference reporting, specified as one of the values in this table:
Value | Description |
---|---|
true | The code generator reports potential behavior differences between generated code and MATLAB code. The potential differences are listed on a tab of the code generation report. A potential difference is a difference that occurs at run time only under certain conditions. |
false | The code generator does not report potential differences. |
See Potential Differences Reporting.
ReqsInCode
— Include requirements links as comments
false
(default) | true
Option to include requirement links (Requirements Toolbox™) as comments, specified as true
orfalse
.
The comments appear as hyperlinks in the code generation report that navigate to the requirement and linked MATLAB code range. See Requirements Traceability for Code Generated from MATLAB Code (Requirements Toolbox).
ReservedNameArray
— Names that code generator must not use for functions or variables
''
(default) | string array | cell array of character vectors | character vector
List of names that the code generator must not use for functions or variables, specified as a string arrays, cell array of character vectors, or character vector.
Multiple reserved names, specified as one of the values in this table.
Value | Description |
---|---|
String arrays | A string array inReservedNameArray. For example,cfg.ReservedNameArray = ["reserve1","reserve2","reserve3"]. |
Cell array of character vectors | A cell array of character vectors inReservedNameArray. For example,cfg.ReservedNameArray = {'reserve1','reserve2','reserve3'}. |
Character vectors | A semicolon-separated list of reserved names inReservedNameArray. For example,cfg.ReservedNameArray = 'reserve1;reserve2;reserve3'.NoteSpecifying multiple entries in code configuration objects by using character vectors will be removed in a future release. Use string array and cell array of character vector instead. For more information, see Compatibility Considerations. |
RowMajor
— Row-major array layout
false
(default) | true
Generation of code that uses row-major array layout, specified as one of the values in this table.
Value | Description |
---|---|
false | Generate code that uses column-major array layout. (This value is the default value.) |
true | Generate code that uses row-major array layout. |
See Generate Code That Uses Row-Major Array Layout.
RunInitialzeFcn
— Automatically run the initialize function
true (default) | false
Generation of a call to the initialize function at the beginning of the generated entry-point functions, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value. A call to the initialize function is included at the beginning of the generated entry-point functions. The generated code includes checks to make sure that the initialize function is called only once, even if there are multiple entry-point functions. |
false | The generated entry-point functions do not include calls to the initialize function. |
Dependency:
- Setting
IncludeInitializeFcn
andIncludeTerminateFcn
totrue
enables this parameter. - Setting
MultiInstanceCode
totrue
disables this parameter.
See Use Generated Initialize and Terminate Functions.
RuntimeChecks
— Run-time error detection and reporting in generated code
false
(default) | true
Run-time error detection and reporting in generated code, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value. The generated code does not check for errors such as out-of-bounds array indexing. |
true | The generated code checks for errors such as out-of-bounds array indexing.The error-reporting software usesfprintf to write error messages to stderr. It usesabort to terminate the application. If fprintf andabort are not available, you must provide them. The abort function abruptly terminates the program. If your system supports signals, you can catch the abort signal (SIGABRT) so that you can control the program termination.Error messages are in English. |
See Generate Standalone C/C++ Code That Detects and Reports Run-Time Errors.
SaturateOnIntegerOverflow
— Integer overflow support
true
(default) | false
Integer overflow support, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The code generator produces code to handle integer overflow. Overflows saturate to either the minimum or maximum value that the data type can represent. |
false | The code generator does not produce code to handle integer overflow. Do not setSaturateOnIntegerOverflow tofalse unless you are sure that your code does not depend on integer overflow support. If you disable integer overflow support and run-time error checking is enabled, the generated code produces an error for overflows. If you disable integer overflow support and you disable run-time error checking, the overflow behavior depends on your target C compiler. In the C standard, the behavior for integer overflow is undefined. However, most C compilers wrap on overflow. |
This parameter applies only to MATLAB built-in integer types. It does not apply to doubles, singles, or fixed-point data types.
See Disable Support for Integer Overflow or Nonfinites.
SILPILDebugging
— Debugging of generated code during a SIL or PIL execution
false
(default) | true
Debugging of generated code during a software-in-the-loop (SIL) or processor-in-the-loop (PIL) execution, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.Disables debugging of generated code during a SIL or PIL execution. |
true | Enables the debugger to observe code behavior during a software-in-the-loop (SIL) or processor-in-the-loop (PIL) execution.Supported debuggers for SIL execution: On Windows®: Microsoft® Visual Studio® IDE.Visual Studio Code with MinGW® GDB. Requires installation ofMATLAB Coder Interface for Visual Studio Code Debugging support package.On macOS, Visual Studio Code with LLDB. Requires installation ofMATLAB Coder Interface for Visual Studio Code Debugging support package.On Linux®: GNU® Data Display Debugger (DDD).Visual Studio Code with GDB. Requires installation ofMATLAB Coder Interface for Visual Studio Code Debugging support package.For information about installing the support package, see https://www.mathworks.com/matlabcentral/fileexchange/103555-matlab-coder-interface-for-visual-studio-code-debugging.For information about setting up debuggers for PIL execution, see Set Up PIL Connectivity by Using Target Framework (Embedded Coder). |
See Debug Generated Code During SIL or PIL Execution (Embedded Coder).
SILPILCheckConstantInputs
— Constant input checking mode for a SIL or PIL execution
true
(default) | false
Constant input checking mode for a SIL or PIL execution, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.The SIL or PIL execution compares the value that a test file provides for a constant input argument with the value specified at code generation time. If the values do not match, an error occurs. |
false | The SIL or PIL execution does not compare the value that a test file provides for a constant input argument with the value specified at code generation time. The SIL or PIL execution uses the value specified at code generation time. If the test file uses a different value, then the results in MATLAB might differ from the results in the SIL or PIL execution.It is possible to speed up a SIL or PIL execution by settingSILPILCheckConstantInputs tofalse. |
See Speed Up SIL/PIL Execution by Disabling Constant Input Checking and Global Data Synchronization (Embedded Coder)
SILPILSyncGlobalData
— Global data synchronization mode for a SIL or PIL execution
true
(default) | false
Global data synchronization mode for a SIL or PIL execution, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.A SIL or PIL execution synchronizes the values of global variables in the SIL or PIL execution environment with the values in the MATLAB workspace. If a global variable is constant and its value in the SIL or PIL execution environment differs from its value in the MATLAB workspace, an error occurs. |
false | The SIL or PIL execution does not synchronize the values of global variables in the SIL or PIL execution environment with the values in the MATLAB workspace. If the values are not synchronized, the results in MATLAB might differ from the results in the SIL or PIL execution.It is possible to speed up a SIL or PIL execution by settingSILPILSyncGlobalData tofalse. |
See Speed Up SIL/PIL Execution by Disabling Constant Input Checking and Global Data Synchronization (Embedded Coder)
SILPILVerbosity
— Display communication I/O information during SIL or PIL execution
'off'
(default) | 'on'
Display of communication I/O information during software-in-the-loop (SIL) or processor-in-the-loop (PIL) execution, specified as one of the values in this table.
Value | Description |
---|---|
'off' | This value is the default value.The code generator does not display communication I/O information during SIL or PIL execution. |
'on' | The code generator displays communication I/O information during SIL or PIL execution. |
See Troubleshooting Host-Target Communication (Embedded Coder).
StackUsageMax
— Maximum stack usage per application
200000
(default) | positive integer
Maximum stack usage per application, in bytes, specified as a positive integer. Set a limit that is lower than the available stack size. Otherwise, a run-time stack overflow might occur. The C compiler detects and reports stack overflows.
See Disable Support for Integer Overflow or Nonfinites.
SupportNonFinite
— Support for nonfinite values
true
(default) | false
Support for nonfinite values, specified as one of the values in this table.
Value | Description |
---|---|
true | This value is the default value.IfGenerateNonFiniteFilesIfUsed is set to true, the code generator produces code to support nonfinite values (Inf andNaN) only if they are used.IfGenerateNonFiniteFilesIfUsed is set to false, the code generator always produces code to support nonfinite values (Inf andNaN). |
false | The code generator does not produce code to support nonfinite values. |
See Disable Support for Integer Overflow or Nonfinites.
TargetLang
— Language to use in generated code
'C'
(default) | 'C++'
Language to use in generated code, specified as 'C'
or'C++'
.
When using GPU Coder, the code generator sets TargetLang
toC++
.
Dependency: If DeepLearningConfig
is set,codegen
sets TargetLang
toC++
.
TargetLangStandard
— Language standard to use for the generated code
'Auto'
(default) | 'C89/C90 (ANSI)'
| 'C99 (ISO)'
| 'C++03 (ISO)'
| 'C++11 (ISO)'
| 'C++14 (ISO)'
| 'C++17 (ISO)'
| 'C++20 (ISO)'
Language standard to use for the generated code, specified as one of these character vectors:
'Auto'
'C89/C90 (ANSI)'
'C99 (ISO)'
'C++03 (ISO)'
'C++11 (ISO)'
'C++14 (ISO)'
'C++17 (ISO)'
'C++20 (ISO)'
Selecting the 'Auto'
option sets theTargetLangStandard
property based on the value of theTargetLang
property. For C, the default standard is'C99 (ISO)'
. For C++, the default standard is'C++11 (ISO)'
. The code generator uses the language features and the math libraries available in the selected C/C++ standard. See Change Language Standard Used for Code Generation.
Toolchain
— Toolchain to use for building a C/C++ library or executable program
'Automatically locate an installed toolchain'
(default) | character vector
Toolchain to use for building a C/C++ library or executable program, specified as a character vector. The list of available toolchains depends on the host computer platform, and can include custom toolchains that you added. If you do not specify a toolchain, the code generator locates an installed toolchain.
Note:
- Suppose that you create a
coder.CodeConfig
objectcfg
in a MATLAB session and use it in another MATLAB session. If the MATLAB host computer for the second session does not have the toolchain specified in thecfg.Toolchain
property installed on it, this parameter reverts to its default value. The default value is'Automatically locate an installed toolchain'
.
UseBuiltinFFTWLibrary
— Generate code that uses the FFTW library shipped with MATLAB
false
(default) | true
Whether to generate code that produces calls to the FFTW library shipped with MATLAB for fast Fourier transform (FFT) functions in your MATLAB code, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.The code generator does not produce calls to the built-in FFTW library for FFT functions in your MATLAB code. |
true | The code generator produces calls to the built-in FFTW library for FFT functions in your MATLAB code. |
UseBuiltinFFTWLibrary
takes precedence overCustomFFTCallback
if you enable both these properties.
Data Types: logical
UsePrecompiledLibraries
— Whether to use precompiled libraries in generated code
'Prefer'
| 'Avoid'
Since R2024b
Extent to which the generated code uses platform-specific precompiled libraries, specified as one of the values in this table.
Value | Instruction Sets |
---|---|
'Prefer' | For C/C++ code generation, this value is the default value.The code generator prefers to use the available platform-specific precompiled libraries.This setting is an appropriate choice when you want to optimize the performance of the generated code for specific platforms. |
'Avoid' | For CUDA code generation (requires GPU Coder), this value is the default value.The code generator uses platform-specific precompiled libraries only if no alternative implementations of their algorithms are available.This setting is useful when you want to create portable applications that can run on many platforms. |
For certain precompiled libraries (for example, BLAS, LAPACK, and FFTW), there exist individual configuration parameters that allow you to customize their usage. The UsePrecompiledLibraries
parameter does not affect the use of these libraries.
Verbose
— Code generation progress display (to be removed)
false (default) | ltrue
Code generation progress display, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value.The code generator does not display code generation progress. |
true | The code generator displays code generation progress, including code generation stages and compiler output. |
Verbosity
— Code generation progress display
'Info'
(default) | 'Silent'
| 'Verbose'
Whether to display the status of the code generation progress at the MATLAB command line, specified as one of the values in this table.
Value | Description |
---|---|
'Silent' | If code generation succeeds without warning, all messages are suppressed, including when you generate a report.Warning and error messages are displayed. |
'Info' | This value is the default value.Compared to the'Silent' mode, if code generation succeeds, these additional messages are displayed:Code generation successfulLink to the generated report, if one has been generated |
'Verbose' | In addition to the messages shown in the'Info' mode, code generation status and target build log messages are displayed. |
Examples
Specify Configuration Parameters for Generation of Standalone Code with Embedded Coder
Write a MATLAB function from which you can generate code. This example uses the function myadd
that returns the sum of its inputs.
function c = myadd(a,b) c = a + b; end
Create a configuration object for generation of standalone C/C++ code (a static library, a dynamically linked library, or an executable program). For example, create a configuration object for generation of a static library.
cfg = coder.config('lib');
If Embedded Coder is installed, coder.config
creates acoder.EmbeddedCodeConfig
object.
Change the values of the properties for which you do not want to use the default values. For example,change the comment style in the generated code to single-line comments preceded by//
.
cfg.CommentStyle = 'Single-line';
TheCommentStyle
property is available only in an Embedded Coder configuration object.
Generate code by using codegen
. Pass the configuration object to codegen
by using the-config
option. Specify that the input arguments are scalar double.
codegen myadd -config cfg -args {1 1} -report
Alternative Functionality
To use default configuration parameters for build types 'LIB'
,'DLL'
, or 'EXE'
, use thecodegen
option -config:lib
,-config:dll
, or -config:exe
, respectively. Then, you do not have to create and pass a configuration object tocodegen
.
Version History
Introduced in R2011a
R2024b: Change to default value of InlineBetweenUserAndMathWorksFunctions
property
The default setting for theInlineBetweenUserAndMathWorksFunctions
code configuration option is now 'Readability'
.
R2024b: Support for additional language standards
In addition to C++03 (ISO) and C++11 (ISO), the code generator can generate C++ code compatible with C++14 (ISO), C++17 (ISO), and C++20 (ISO).
R2024b: CodeProfilingCodeMetrics
Property Added
New property CodeProfilingCodeMetrics
allows you to profile generated code using metrics from the Performance Monitoring Unit (PMU) of the hardware.
R2024b: UsePrecompiledLibraries
Property Added
New property UsePrecompiledLibraries
allows you to specify the extent to which the generated code uses platform-specific precompiled libraries.
R2024b: PreserveInputData
Property Added
New property PreserveInputData
allows you to generate code that protects entry-point input data from modification when the generated code is called from your custom C/C+ code.
R2024a: Using Quotes to Specify a Single Filename or Path That Contains White Spaces has been Removed
If you try to use quotes to specify a single filename or path that contains white space (for example, '"folder1\folder2\sp ace\fun3.c"'
) for theCustomInclude
, CustomLibrary
, andCustomSource
code configuration parameters, the code generator produces an error.
R2023b: Specifying Multiple Entries in Code Configuration Objects by Using Character Vector Errors
Specifying multiple file names, paths, or reserved names in code configuration objects by using character vectors or string scalars that have delimiters produces an error. Use string arrays and a cell array of character vector instead. For example, to include multiple folder names, you can use either a string array inCustomInclude
as cfg.CustomInclude = ["C:\Project","C:\Custom Files"];
or a cell array of character vectors as cfg.CustomInclude = {'C:\Project','C:\Custom Files'};
to include the path for compiling the generated code.
R2023b: Using Quotes to Specify Single Filename or Path That Contains White Spaces Warns
Using quotes to specify a single filename or path that contains white spaces (for example, '"sp ace/fun3.c"'
) for theCustomInclude
, CustomLibrary
, andCustomSource
code configuration properties produces a warning and will be removed in a future release.
R2023a: DynamicMemoryAllocation
Property To Be Removed
In a future release, the DynamicMemoryAllocation
property will be removed.
To dynamically allocate memory for variable-size arrays, use theEnableDynamicMemoryAllocation
property. To configure the dynamic memory allocation threshold, useDynamicMemoryAllocationThreshold
property.
R2022b: Capability to Specify Multiple Entries in Code Configuration Objects by Using Character Vector Warns
Specifying multiple file names, paths, or reserved names in code configuration objects by using character vectors or string scalars that have delimiters produces a warning and will be removed in a future release. Use string arrays and a cell array of character vector instead. For example, to include multiple folder names, you can use either a string array in CustomInclude
ascfg.CustomInclude = ["C:\Project","C:\Custom Files"];
or a cell array of character vectors as cfg.CustomInclude = {'C:\Project','C:\Custom Files'};
to include the path for compiling the generated code.
R2021a: Capability to Specify Multiple Entries in Code Configuration Objects by Using Character Vector Will Be Removed
In a future release, specifying multiple file names, paths, or reserved names in code configuration objects by using character vectors or string scalars that have delimiters will be removed. Use string arrays and a cell array of character vector instead. For example, to include multiple folder names, you can use either a string array in CustomInclude
as cfg.CustomInclude = ["C:\Project","C:\Custom Files"];
or a cell array of character vectors as cfg.CustomInclude = {'C:\Project','C:\Custom Files'};
to include the path for compiling the generated code.
R2021a: Verbose
Property To Be Removed
In a future release, the Verbose
property will be removed.
To configure the code generation progress display, use theVerbosity
property.