C code generation: memory allocation for reference model in multi-instance mode
I am generating c code for model reference hierarchy using Embedded Coder.
There are reference models which are called multiple times from a parent model.
In the generated code, the block signals and block states data for each instance of reference model is accumulated in block states data of parent model creating a large structure(which causes compilation error).
I would like to have a single memory allocation(global) for this reference model data and reuse it for all instances.
I tried changing many settings related to code generation/optimization, but could not fix this.
Is there any method to achieve this?
/* Block states (default storage) for model ‘ParentModel’ */
typedef struct {
MdlrefDW_ChildModel_T Instance1;
MdlrefDW_ChildModel_T Instance2;
MdlrefDW_ChildModel_T Instance3;
…
}DW_ParentModel_xxxx_T
ChildModel is having an image processing logic and MdlrefDW_ChildModel_T is having a size of 200MB.
So when the number of instances increases, size of final _DW structure increases significantly.I am generating c code for model reference hierarchy using Embedded Coder.
There are reference models which are called multiple times from a parent model.
In the generated code, the block signals and block states data for each instance of reference model is accumulated in block states data of parent model creating a large structure(which causes compilation error).
I would like to have a single memory allocation(global) for this reference model data and reuse it for all instances.
I tried changing many settings related to code generation/optimization, but could not fix this.
Is there any method to achieve this?
/* Block states (default storage) for model ‘ParentModel’ */
typedef struct {
MdlrefDW_ChildModel_T Instance1;
MdlrefDW_ChildModel_T Instance2;
MdlrefDW_ChildModel_T Instance3;
…
}DW_ParentModel_xxxx_T
ChildModel is having an image processing logic and MdlrefDW_ChildModel_T is having a size of 200MB.
So when the number of instances increases, size of final _DW structure increases significantly. I am generating c code for model reference hierarchy using Embedded Coder.
There are reference models which are called multiple times from a parent model.
In the generated code, the block signals and block states data for each instance of reference model is accumulated in block states data of parent model creating a large structure(which causes compilation error).
I would like to have a single memory allocation(global) for this reference model data and reuse it for all instances.
I tried changing many settings related to code generation/optimization, but could not fix this.
Is there any method to achieve this?
/* Block states (default storage) for model ‘ParentModel’ */
typedef struct {
MdlrefDW_ChildModel_T Instance1;
MdlrefDW_ChildModel_T Instance2;
MdlrefDW_ChildModel_T Instance3;
…
}DW_ParentModel_xxxx_T
ChildModel is having an image processing logic and MdlrefDW_ChildModel_T is having a size of 200MB.
So when the number of instances increases, size of final _DW structure increases significantly. simulink, code generation, reference models, multiinstance, global memory, heap, internal data buffer MATLAB Answers — New Questions