Main Content

ssSetArrayLayoutForCodeGen

Specify array layout of the S-function

Syntax

void ssSetArrayLayoutForCodeGen(SimStruct *S, SSArrayLayout arrayLayout)

Arguments

S

SimStruct representing an S-Function block.

arrayLayout

Array layout of the S-function.

Description

Specify the array layout of the user-defined S-function. Use this macro in the mdlInitializeSizes to set the array layout of the S-function. If the SSArrayLayout specified for the S-function is different from the value specified for model configuration parameter Array layout (Simulink Coder), Simulink® Coder™ reports an error. You can turn off the error by changing the External functions compatibility for row-major code generation (Simulink Coder) to warning or none.

The enumerated type SSArrayLayout defines the set of values that arrayLayout can have.

Array Layout Value

Majority Supported

SS_UNSET

Unspecified

SS_COLUMN_MAJOR

Column-major

SS_ROW_MAJOR

Row-major

SS_ALL

Column-major or row-major

By default, SSArrayLayout is set to SS_UNSET.

Set SSArrayLayout as SS_ALL if your S-function is not affected by the array layout. The generated code does not affect cache performance.

When running row-major simulations in Accelerator and Rapid Accelerator modes, Simulink uses the S-function's MEX files instead of inlining the S-function by using the Target Language Compiler (TLC).

Languages

C, C++

Examples

Specify the S-function for column-major code generation:

static void mdlInitializeSizes(SimStruct *S)
{    
    ssSetArrayLayoutForCodeGen(S, SS_COLUMN_MAJOR);
}

Specify the S-function for row-major code generation:

static void mdlInitializeSizes(SimStruct *S)
{    
    ssSetArrayLayoutForCodeGen(S, SS_ROW_MAJOR);
}

Specify the S-function for column-major or row-major code generation:

static void mdlInitializeSizes(SimStruct *S)
{    
    ssSetArrayLayoutForCodeGen(S, SS_ALL);
}

Introduced in R2018b