Use algorithms optimized for row-major array layout - Enable algorithm for row-major format code generation and simulation - MATLAB (original) (raw)

Main Content

Enable algorithm for row-major format code generation and simulation

Model Configuration Pane: Math and Data Types

Description

The Use algorithms optimized for row-major array layout parameter enables optimized algorithms for row-major format code generation and corresponding row-major algorithms for model simulation for certain blocks.

Settings

off (default) | on

When Array layout (Simulink Coder) is set to Row-major, the code generator uses algorithms to maintain consistency of numeric results between the simulation and the generated code. Sometimes, the generated code for these algorithms might be inefficient. You can enable the Use algorithms optimized for row-major array layout configuration parameter to enable efficient algorithms that are optimized for certain blocks. The Use algorithms optimized for row-major array layout parameter affects the simulation and the generated code.

This parameter affects only these blocks:

For these blocks, the column-major and row-major algorithms might differ in the order of output calculations, possibly resulting in slightly different numeric values.

On

Off

Tips

When Array layout is set to Row-major, the row-major algorithm operates on table data that is contiguous in memory. This table data leads to faster cache access, making these algorithms cache-friendly.

This table summarizes the relationship between array layout and cache-friendly algorithms. It is a best practice to use the algorithm that is optimized for the specified array layout to achieve good performance. For example, select Use algorithms optimized for row-major array layout when the Array layout is set to Row-major for code generation.

ArrayLayout UseRowMajorAlgorithm Algorithm Applied
Column-major 'off' Efficient column-major algorithmRecommended
Row-major 'off' Inefficient column-major algorithmNot recommended
Column-major 'on' Inefficient row-major algorithmNot recommended
Row-major 'on' Efficient row-major algorithmRecommended
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact

Programmatic Use

Parameter: UseRowMajorAlgorithm
Type: character vector
Value: 'on' | 'off'
Default: 'off'

Version History

Introduced in R2018b

See Also

Topics