Multicore / multitask c++ codegeneration with reusable models

1 view (last 30 days)
Hello,
I have problems generating multi-core c++ code of a simple testmodel. I have attached the samplemodel, where the generated c-code can build, but the I cannot manage to build c++ code with reusable code for the submodels.
I was able to generate c-code and build the executable with the following settings:
  • topmodel: non-reusable function
  • Submodels: reusable functions
When changing the target language on all models to c++, I have problems:
1) scenario 1
  • topmodel: non-reusable function
  • submodels: c++ class
### Build procedure for model: 'MultiCoreHarness' aborted due to an error.
The following Configuration parameter option(s) do not match between the models 'MultiCoreHarness (Parent)' and 'TestModel1 (Child)'. Configuration references can help avoid parameter mismatches.
Code interface packaging (CodeInterfacePackaging):
Parent setting: Nonreusable function
Child setting: C++ class
Component:Simulink | Category:Block diagram error
2) scenario2
  • topmodel: non-reusable function
  • submodels: reusable function
Build 7 1 Clear
06:27 PM Elapsed: 29 sec
Updating Model Reference Simulation Targets
Elapsed: 0.93 sec
Updating Model Reference Code Generation Targets 4
Elapsed: 17 sec
Building TestModel1 2
Elapsed: 9 sec
### Checking the status of model reference code generation target for model 'TestModel1' used in 'MultiCoreHarness'
### Model reference code generation target (TestModel1.cpp) for model TestModel1 is out of date because TestModel1.cpp does not exist.
### Updating model reference code generation target for model: TestModel1
### Generating code and artifacts to 'Model specific' folder structure
Code Generation 1
Elapsed: 8 sec
### Generating code into build folder: F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\slprj\grt\TestModel1
### Invoking Target Language Compiler on TestModel1.rtw
### Using System Target File: C:\Program Files\MATLAB\R2019a\rtw\c\grt\grt.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
### Caching model source code
### Generating TLC interface API.
### Writing source file TestModel1_capi.cpp
.
### Writing header file TestModel1_capi.h
### Writing header file TestModel1_types.h
.
### Writing header file TestModel1.h
### Writing header file rtwtypes.h
### Writing header file builtin_typeid_types.h
### Writing header file multiword_types.h
### Writing source file TestModel1.cpp
### Writing header file TestModel1_private.h
.
### TLC code generation complete.
### Using toolchain: Microsoft Visual C++ 2017 v15.0 | nmake (64-bit Windows)
### Creating 'F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\slprj\grt\TestModel1\TestModel1.mk' ...
### Building 'TestModel1': nmake -f TestModel1.mk all
F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\slprj\grt\TestModel1>call "setup_msvc.bat"
F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\slprj\grt\TestModel1>set "VSCMD_START_DIR=F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\slprj\grt\TestModel1"
F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\slprj\grt\TestModel1>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\VCVARSALL.BAT " amd64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.24
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Microsoft (R) Program Maintenance Utility Version 14.16.27041.0
Copyright (C) Microsoft Corporation. All rights reserved.
cl /TP -c -nologo -GS -W4 -DWIN32 -D_MT -MT -EHs -D_CRT_SECURE_NO_WARNINGS /Od /Oy- -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DMODEL=TestModel1 -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL @TestModel1_comp.rsp -Fo"TestModel1.obj" "TestModel1.cpp"
TestModel1.cpp
cl /TP -c -nologo -GS -W4 -DWIN32 -D_MT -MT -EHs -D_CRT_SECURE_NO_WARNINGS /Od /Oy- -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DMODEL=TestModel1 -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL @TestModel1_comp.rsp -Fo"TestModel1_capi.obj" "TestModel1_capi.cpp"
TestModel1_capi.cpp
### Creating static library ".\TestModel1_rtwlib.lib" ...
lib /nologo -out:.\TestModel1_rtwlib.lib @TestModel1.rsp
### Created: .\TestModel1_rtwlib.lib
### Successfully generated all binary outputs.
### Successfully updated the model reference code generation target for model: TestModel1
Building TestModel2 2
Elapsed: 8 sec
### Checking the status of model reference code generation target for model 'TestModel2' used in 'MultiCoreHarness'
### Model reference code generation target (TestModel2.cpp) for model TestModel2 is out of date because TestModel2.cpp does not exist.
### Updating model reference code generation target for model: TestModel2
### Generating code and artifacts to 'Model specific' folder structure
Code Generation 1
Elapsed: 7 sec
### Generating code into build folder: F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\slprj\grt\TestModel2
### Invoking Target Language Compiler on TestModel2.rtw
### Using System Target File: C:\Program Files\MATLAB\R2019a\rtw\c\grt\grt.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
### Caching model source code
### Generating TLC interface API.
### Writing source file TestModel2_capi.cpp
.
### Writing header file TestModel2_capi.h
### Writing header file TestModel2_types.h
### Writing header file TestModel2.h
.
### Writing source file TestModel2.cpp
### Writing header file TestModel2_private.h
### TLC code generation complete.
### Using toolchain: Microsoft Visual C++ 2017 v15.0 | nmake (64-bit Windows)
### Creating 'F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\slprj\grt\TestModel2\TestModel2.mk' ...
### Building 'TestModel2': nmake -f TestModel2.mk all
F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\slprj\grt\TestModel2>call "setup_msvc.bat"
F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\slprj\grt\TestModel2>set "VSCMD_START_DIR=F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\slprj\grt\TestModel2"
F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\slprj\grt\TestModel2>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\VCVARSALL.BAT " amd64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.24
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Microsoft (R) Program Maintenance Utility Version 14.16.27041.0
Copyright (C) Microsoft Corporation. All rights reserved.
cl /TP -c -nologo -GS -W4 -DWIN32 -D_MT -MT -EHs -D_CRT_SECURE_NO_WARNINGS /Od /Oy- -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DMODEL=TestModel2 -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL @TestModel2_comp.rsp -Fo"TestModel2.obj" "TestModel2.cpp"
TestModel2.cpp
cl /TP -c -nologo -GS -W4 -DWIN32 -D_MT -MT -EHs -D_CRT_SECURE_NO_WARNINGS /Od /Oy- -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DMODEL=TestModel2 -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL @TestModel2_comp.rsp -Fo"TestModel2_capi.obj" "TestModel2_capi.cpp"
TestModel2_capi.cpp
### Creating static library ".\TestModel2_rtwlib.lib" ...
lib /nologo -out:.\TestModel2_rtwlib.lib @TestModel2.rsp
### Created: .\TestModel2_rtwlib.lib
### Successfully generated all binary outputs.
### Successfully updated the model reference code generation target for model: TestModel2
### Starting build procedure for model: MultiCoreHarness
### Generating code and artifacts to 'Model specific' folder structure
Code Generation 1
Elapsed: 9 sec
### Generating code into build folder: F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\MultiCoreHarness_grt_rtw
### Invoking Target Language Compiler on MultiCoreHarness.rtw
### Using System Target File: C:\Program Files\MATLAB\R2019a\rtw\c\grt\grt.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
.
### Caching model source code
### Generating TLC interface API.
### Writing source file MultiCoreHarness_capi.cpp
.
### Writing header file MultiCoreHarness_capi.h
### Writing header file MultiCoreHarness_types.h
### Writing header file MultiCoreHarness.h
.
### Writing source file MultiCoreHarness.cpp
### Writing header file MultiCoreHarness_private.h
### Writing header file rtmodel.h
### Writing source file rt_main.cpp
### TLC code generation complete.
### Creating HTML report file MultiCoreHarness_codegen_rpt.html
### Using toolchain: Microsoft Visual C++ 2017 v15.0 | nmake (64-bit Windows)
### Creating 'F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\MultiCoreHarness_grt_rtw\MultiCoreHarness.mk' ...
### Building 'MultiCoreHarness': nmake -f MultiCoreHarness.mk all
F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\MultiCoreHarness_grt_rtw>call "setup_msvc.bat"
F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\MultiCoreHarness_grt_rtw>set "VSCMD_START_DIR=F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\MultiCoreHarness_grt_rtw"
F:\VinteccProjects\17 SIG_RTP\MultiCoreCodegeneration\MCCodegenTest1\MultiCoreHarness_grt_rtw>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\VCVARSALL.BAT " amd64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.24
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Microsoft (R) Program Maintenance Utility Version 14.16.27041.0
Copyright (C) Microsoft Corporation. All rights reserved.
cl /TP -c -nologo -GS -W4 -DWIN32 -D_MT -MT -EHs -D_CRT_SECURE_NO_WARNINGS /Od /Oy- -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=1 -DTID01EQ=0 -DMODEL=MultiCoreHarness -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL @MultiCoreHarness_comp.rsp -Fo"MultiCoreHarness.obj" "MultiCoreHarness.cpp"
MultiCoreHarness.cpp
cl /TP -c -nologo -GS -W4 -DWIN32 -D_MT -MT -EHs -D_CRT_SECURE_NO_WARNINGS /Od /Oy- -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=1 -DTID01EQ=0 -DMODEL=MultiCoreHarness -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL @MultiCoreHarness_comp.rsp -Fo"MultiCoreHarness_capi.obj" "MultiCoreHarness_capi.cpp"
MultiCoreHarness_capi.cpp
cl /TP -c -nologo -GS -W4 -DWIN32 -D_MT -MT -EHs -D_CRT_SECURE_NO_WARNINGS /Od /Oy- -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=1 -DTID01EQ=0 -DMODEL=MultiCoreHarness -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DRT -DUSE_RTMODEL @MultiCoreHarness_comp.rsp -Fo"rt_main.obj" "rt_main.cpp"
rt_main.cpp
rt_main.cpp(55): error C2732: linkage specification contradicts earlier specification for 'MultiCoreHarness_step'
rt_main.cpp(55): note: see declaration of 'MultiCoreHarness_step'
rt_main.cpp(354): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.EXE"' : return code '0x2'
Stop.
The make command returned an error of 2
### Build procedure for model: 'MultiCoreHarness' aborted due to an error.
Error(s) encountered while building "MultiCoreHarness":
### Failed to generate all binary outputs.
3) Scenario 3
  • Topmodel: c++ class
  • Submodels: c++ class
### Build procedure for model: 'MultiCoreHarness' aborted due to an error.
This model is configured for concurrent execution and has modeling constraints. The block diagram parameter 'CodeInterfacePackaging' must be set to 'Nonreusable function'.
Scenario 1 would be the preferred way. Scenario 2 would also be ok if it would build. Scenario 3 would also be ok, but I guess that is a limitation of simulink coder.
Could someone explain me how to fix this for c++ code generation?
It is obviously possible using c-codegeneration.
Thank you in advance!

Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!