Opened 3 years ago
Closed 3 years ago
#6296 closed defect (fixed)
FMI export recently fails with array outputs
Reported by: | rfranke | Owned by: | arun3688 |
---|---|---|---|
Priority: | blocker | Milestone: | 1.16.3 |
Component: | FMI | Version: | 1.16.0 |
Keywords: | Cc: | adrpo, arun3688 |
Description (last modified by rfranke)
This is a modified version of testArrayEquations, reduced by many features, but extended with a vector output yx1:
model ArrayEquationsTest parameter Integer n = 10; input Real[n] u(start = 1:n); Real[n] x1(each start = 1); output Real[n] yx1; output Real y1; equation when Clock(0.1) then // for eqation for i in 1:n loop x1[i] = if firstTick(x1[i]) then previous(x1[i]) else previous(x1[i]) + u[i]; yx1[i] = x1[i]; end for; end when; y1 = sum(x1); end ArrayEquationsTest;
Attempting to export this model as FMU with:
setCommandLineOptions("--std=3.3"); getErrorString(); setCommandLineOptions("-d=newInst,-nfScalarize,disableFMIDependency"); getErrorString(); setCommandLineOptions("--simCodeTarget=Cpp"); getErrorString(); loadFile("ArrayEquationsTest.mo"); getErrorString(); translateModelFMU(ArrayEquationsTest, version = "2.0"); getErrorString();
gives the error:
[/home/rfranke/OpenModelica/OMCompiler/Compiler/Template/Tpl.mo:2027:8-2027:159:writable] Error: Internal error Stack overflow when evaluating function: [bt] #1 /home/rfranke/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaRuntimeC.so(mmc_setStacktraceMessages_threadData) [bt] #2 /home/rfranke/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaRuntimeC.so(mmc_do_stackoverflow) [bt] #3 /home/rfranke/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCppInit.fun_87) [bt] #4 /home/rfranke/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCppInit.ScalarVariableTypeStartAttribute) [bt] #5 /home/rfranke/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCppInit.fun_83) [bt] #6 /home/rfranke/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCppInit.ScalarVariableType) [bt] #7 /home/rfranke/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCppInit.fun_73) [bt] #8 /home/rfranke/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCppInit.fun_76) [bt] #9 /home/rfranke/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCppInit.scalarVariableXML) [bt] #10 /home/rfranke/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCppInit.lm_74) [bt] #11 /home/rfranke/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCppInit.fun_76) [bt] #12 /home/rfranke/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCppInit.scalarVariableXML) ... [bt] #1024 /home/rfranke/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCppInit.lm_74) [bt] #1025 [...] Error: Template error: A template call failed (/home/rfranke/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so: (null)). One possible reason could be that a template imported function call failed (which should not happen for functions called from within template code; templates assert pure 'match'/non-failing semantics).
It was working with OM 1.14. It is not working with 1.16 and 1.17 anymore.
Change History (18)
comment:1 Changed 3 years ago by rfranke
- Description modified (diff)
comment:2 Changed 3 years ago by rfranke
- Component changed from Cpp Run-time to FMI
- Owner changed from rfranke to lochel
comment:3 Changed 3 years ago by rfranke
- Description modified (diff)
comment:4 Changed 3 years ago by rfranke
- Cc arun3688 added
It appears that the following commit clear up $cse variables for FMI modelDescription.xml (#640) by @arun3688 broke the function SimCodeUtil.getScalarElements with the introduction of fmi_index.
The function now returns the array, resulting in an endless loop when called from templates such as CodegenFMUCommon.ScalarVariable.
comment:5 Changed 3 years ago by arun3688
@rfranke, the immediate fix for this problem is to use the config flag fmiFilter as none
should work eg. omc --fmiFilter=none testArrayEquation
comment:6 Changed 3 years ago by rfranke
Thank you for this workaround!
comment:7 Changed 3 years ago by adrpo
I guess we could activate the --fmiFilter=none if -d=-nfScalarize is on.
comment:8 Changed 3 years ago by rfranke
I'd love to understand the root cause first. It's model outputs that should not be filtered out. Maybe a fix if the filter functionality is possible?
comment:9 Changed 3 years ago by casella
- Milestone changed from 1.16.2 to 1.17.0
@rfranke, we released 1.16.2 today. I would reschedule this for 1.17.0, due end of January. I hope that is fine for you, we could make a 1.16.3 mid-January, but it's probably not worth it. Feel free to comment on this
comment:10 Changed 3 years ago by rfranke
- Priority changed from blocker to critical
Fine with me. Actually it's not a blocker anymore since a workaround is known.
comment:11 Changed 3 years ago by rfranke
- Priority changed from critical to blocker
I'm afraid I need to escalate this ticket again. The flag --fmiFilter=none works for me with the current master under Linux. It seems to be ignored by the newly released 1.16.2 Win32bit though. No matter if I specify it or not under Tools->Options->Simulation Additional Translation Flags, OMEdit just disappears during FMI export. This makes any version released after 1.14 unusable.
Same with OMEdit under Linux: --fmiFilter does not take effect. So please, release 1.16.3!
comment:12 Changed 3 years ago by casella
- Owner changed from lochel to arun3688
- Status changed from new to assigned
comment:13 Changed 3 years ago by arun3688
@rfranke, This PR https://github.com/OpenModelica/OpenModelica/pull/7067 should fix the issue
comment:14 follow-up: ↓ 15 Changed 3 years ago by adrpo
Thanks Arun! I will cherry-pick this to maintenance/v1.16 for 1.16.3.
comment:15 in reply to: ↑ 14 Changed 3 years ago by casella
- Milestone changed from 1.17.0 to 1.16.3
Replying to adrpo:
Thanks Arun! I will cherry-pick this to maintenance/v1.16 for 1.16.3.
Please close the ticket once you've done it
comment:16 Changed 3 years ago by arun3688
- Resolution set to fixed
- Status changed from assigned to closed
comment:17 Changed 3 years ago by casella
- Resolution fixed deleted
- Status changed from closed to reopened
Sorry @arun3688, let's keep this open as a reminder until the commit is merged into maintenance/1.16, it still isn't.
comment:18 Changed 3 years ago by adrpo
- Resolution set to fixed
- Status changed from reopened to closed
Will be fixed with: https://github.com/OpenModelica/OpenModelica/pull/7106
That's the diff between CodegenCppInit.tpl of master vs v1.14
So, hardly the reason for the malfunction. This is why I'm reassigning the ticket to FMI.