#3902 closed defect (fixed)
FMU compilation with minimal runtime fails for some models
Reported by: | Adrian Pop | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | Run-time | Version: | |
Keywords: | Cc: | Rüdiger Franke, Henning Kiel |
Description
It seems that when building the FMU using the minimal runtime we get undefines such as mmc_mk_rcon
which should not happen. I believe this is because for each function we generate also a boxed function. Maybe those boxed functions should be ifdef-ed out for the minimal runtime.
Change History (8)
comment:1 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 9 years ago
comment:3 by , 9 years ago
And the function file: {Modelica_Fluid_Examples_Tanks_ThreeTanks_functions.c
contains boxed functions which refer to mmc_mk_rcon and other MetaModelica functions which are ifdef-ed out via OMC_MINIMAL_RUNTIME or OMC_FMI_RUNTIME.
#include "Modelica_Fluid_Examples_Tanks_ThreeTanks_functions.h" #ifdef __cplusplus extern "C" { #endif #include "Modelica_Fluid_Examples_Tanks_ThreeTanks_literals.h" #include "Modelica_Fluid_Examples_Tanks_ThreeTanks_includes.h" .... DLLExport modelica_real omc_Modelica_Fluid_Pipes_BaseClasses_FlowModels_Medium_density(threadData_t *threadData, Modelica_Fluid_Pipes_BaseClasses_FlowModels_Medium_ThermodynamicState _state) { modelica_real _d; _tailrecursive: OMC_LABEL_UNUSED _d = 995.586; _return: OMC_LABEL_UNUSED return _d; } modelica_metatype boxptr_Modelica_Fluid_Pipes_BaseClasses_FlowModels_Medium_density(threadData_t *threadData, modelica_metatype _state) { Modelica_Fluid_Pipes_BaseClasses_FlowModels_Medium_ThermodynamicState tmp1; modelica_real tmp2; modelica_real tmp3; modelica_real _d; modelica_metatype out_d; modelica_metatype tmpMeta[2] __attribute__((unused)) = {0}; tmpMeta[0] = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_state), 2))); tmp2 = mmc_unbox_real(tmpMeta[0]); tmp1._p = tmp2; tmpMeta[1] = (MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_state), 3))); tmp3 = mmc_unbox_real(tmpMeta[1]); tmp1._T = tmp3; _d = omc_Modelica_Fluid_Pipes_BaseClasses_FlowModels_Medium_density(threadData, tmp1); out_d = mmc_mk_rcon(_d); return out_d; } .... #ifdef __cplusplus } #endif
comment:4 by , 9 years ago
Yeah, this is a bit more complicated to fix than I expected, we need a better GC interface.
Basically we need to do at the global C runtime level something like:
#if (defined(OMC_MINIMAL_RUNTIME) || defined(OMC_FMI_RUNTIME)) #define GC_init omc_alloc_interface_pooled.init #define GC_malloc omc_alloc_interface_pooled.malloc #define GC_malloc_atomic omc_alloc_interface_pooled.malloc_atomic #define GC_strdup omc_alloc_interface_pooled.malloc_strdup #define GC_collect_a_little_or_not omc_alloc_interface_pooled.collect_a_little #define GC_malloc_uncollectable omc_alloc_interface_pooled.malloc_uncollectable #define GC_free omc_alloc_interface_pooled.free_uncollectable #define nofree omc_alloc_interface_pooled.free_string_persist #else #include "gc.h" /* include Boehm GC */ #endif /* #if (defined(OMC_MINIMAL_RUNTIME) || defined(OMC_FMI_RUNTIME)) */
comment:5 by , 8 years ago
Cc: | added |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Fixed in 28420a1f62e11aaed9fff3f7c9a6cb59ac464ed3/OMCompiler with help from @hkiel.
I'll add a test with another commit.
comment:7 by , 8 years ago
Even more fixes in c7a21f/OMCompiler and added a test in 193fe4/OpenModelica-testsuite.
comment:8 by , 8 years ago
Hopefully final fix for this ticket ec6bb2/OMCompiler. The library coverage last night was aborted because the simulation executable were using the memory_pool not the Boehm GC in all cases, but it should have been only for minimal runtime and FMI.
Cross compiling for example
Modelica.Fluid.Examples.Tanks.ThreeTanks
as FMU via:results in these errors: