Skip to content

Commit

Permalink
Handle a stack overflow in HpcOm
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Jul 25, 2017
1 parent 74ffe70 commit abde81d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
5 changes: 4 additions & 1 deletion Compiler/BackEnd/BackendDAEOptimize.mo
Expand Up @@ -5668,14 +5668,17 @@ protected

array<list<Integer>> mapEqnIncRow;
array<Integer> mapIncRowEqn;
Integer systemNumber=0, numberOfSystems;
algorithm
daeOut := daeIn;

BackendDAE.DAE(systs,shared) := daeIn;
BackendDAE.SHARED(functionTree = funcTree) := shared;
systsNew := {};
//traverse the simulation-DAE systems
numberOfSystems := listLength(systs);
for syst in systs loop
systemNumber := systemNumber+1;
BackendDAE.EQSYSTEM(orderedVars = vars, orderedEqs=eqs, matching=matching) := syst;
BackendDAE.MATCHING(ass1=ass1, ass2=ass2, comps=comps) := matching;

Expand Down Expand Up @@ -5773,7 +5776,7 @@ algorithm
syst := BackendDAETransform.strongComponentsScalar(syst,shared,mapEqnIncRow,mapIncRowEqn);
syst.removedEqs := BackendEquation.emptyEqns();
else
print("No output variables in this system\n");
Error.addCompilerNotification("No output variables in this system ("+String(systemNumber)+"/"+String(numberOfSystems)+")");
end if;

systsNew := syst::systsNew;
Expand Down
46 changes: 27 additions & 19 deletions Compiler/BackEnd/HpcOmTaskGraph.mo
Expand Up @@ -6292,26 +6292,34 @@ protected function getNodeForVarIdx"traverse the whole varCompMapping from eqSys
input Integer varIdx;
input Integer eqSysIdx;
input array<tuple<Integer,Integer,Integer>> varCompMapping;
input Integer tryThisIndex;
output Integer nodeIdxOut;
algorithm
nodeIdxOut := matchcontinue(varIdx,eqSysIdx,varCompMapping,tryThisIndex)
local
Integer offset,eqSys,node;
Boolean eqSysNeq;
case(_,_,_,_)
equation
((node,eqSys,offset)) = arrayGet(varCompMapping,tryThisIndex);
eqSysNeq = intNe(eqSys,eqSysIdx);
node = if eqSysNeq then getNodeForVarIdx(varIdx,eqSysIdx,varCompMapping,offset+2) else node+varIdx-1;
then node;
case(-1,-1,_,_)
then -1;
input Integer inTryThisIndex;
output Integer node;
protected
Integer offset,eqSys,tryThisIndex=inTryThisIndex,n=0,arrayLengthVarCompMapping;
Boolean eqSysNeq;
algorithm
arrayLengthVarCompMapping := arrayLength(varCompMapping);
while true loop
if tryThisIndex >= 1 and tryThisIndex <= arrayLengthVarCompMapping then
((node,eqSys,offset)) := arrayGet(varCompMapping,tryThisIndex);
if eqSys == eqSysIdx then
node := node+varIdx-1;
return;
else
tryThisIndex := offset+2;
end if;
elseif varIdx==-1 and eqSysIdx==-1 then
node := -1;
return;
else
equation
print("HpcOmTaskGraph.getNodeForVarIdx failed\n");
then -1;
end matchcontinue;
print("HpcOmTaskGraph.getNodeForVarIdx failed\n");
end if;
n := n+1;
if n>arrayLengthVarCompMapping then
Error.addInternalError(getInstanceName() + " failed (there is a loop somewhere)", sourceInfo());
fail();
end if;
end while;
end getNodeForVarIdx;


Expand Down

0 comments on commit abde81d

Please sign in to comment.