Skip to content

Commit fac68fe

Browse files
author
Volker Waurich
committed
- changed evaluateLoop function for resolveLoops
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19269 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 0ada991 commit fac68fe

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Compiler/BackEnd/BackendDAEOptimize.mo

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7174,7 +7174,7 @@ algorithm
71747174
// check if its worth to resolve the loops
71757175
loops = List.filter1OnTrue(loops,evaluateLoop,(m_uncut,mT_uncut,eqCrossLst));
71767176
//print("the loops that will be resolved: \n"+&stringDelimitList(List.map(loops,HpcOmTaskGraph.intLstString),"\n")+&"\n");
7177-
7177+
71787178
// resolve the loops
71797179
(eqLst,_) = resolveLoops_resolveAndReplace(loops,eqCrossLst,varCrossLst,mIn,mTIn,eqMapping,varMapping,daeEqs,daeVars,{});
71807180
eqLst = resolveLoops_resolvePartitions(rest,mIn,mTIn,m_uncut,mT_uncut,eqMapping,varMapping,eqLst,daeVars,nonLoopEqs);
@@ -7187,6 +7187,7 @@ algorithm
71877187
end matchcontinue;
71887188
end resolveLoops_resolvePartitions;
71897189

7190+
71907191
protected function arrayEntryLengthIs "gets the indexed entry of the array and compares the length with the given value,
71917192
author:Waurich TUD 2014-01"
71927193
input Integer idx;
@@ -7483,9 +7484,13 @@ algorithm
74837484
eqVars := List.map1(loopIn,Util.arrayGetIndexFirst,m);
74847485
allVars := List.flatten(eqVars);
74857486
loopVars := doubleEntriesInLst(allVars,{},{});
7487+
74867488
// check if its worth to resolve the loop. Therefore compare the amount of vars in and outside the loop
74877489
(_,nonLoopVars,_) := List.intersection1OnTrue(allVars,loopVars,intEq);
7488-
nonLoopVars := List.filter1OnTrue(nonLoopVars, isOutsideLoop, (mT,eqCrossLst)); // do not consider vars between 2 crossNodes
7490+
7491+
(eqCrossLst,_,_) := List.intersection1OnTrue(loopVars,eqCrossLst,intEq);
7492+
//nonLoopVars := List.filter1OnTrue(nonLoopVars, isOutsideLoop, (mT,eqCrossLst)); // do not consider vars between 2 crossNodes
7493+
74897494
numInLoop := listLength(loopVars);
74907495
numOutLoop := listLength(nonLoopVars);
74917496
resolve := intGe(numInLoop,numOutLoop);
@@ -7498,13 +7503,15 @@ author:Waurich TUD 2014-02"
74987503
input tuple<BackendDAE.IncidenceMatrix,list<Integer>> tplIn;
74997504
output Boolean isNonLooopNode;
75007505
protected
7506+
Boolean isDeadEndNode;
75017507
BackendDAE.IncidenceMatrix m;
75027508
list<Integer> adjNodes, crossNodes;
75037509
algorithm
75047510
(m,crossNodes) := tplIn;
75057511
adjNodes := arrayGet(m,node);
7512+
isDeadEndNode := intEq(listLength(adjNodes),1);
75067513
(_,adjNodes,_) := List.intersection1OnTrue(adjNodes,crossNodes,intEq);
7507-
isNonLooopNode := List.isNotEmpty(adjNodes);
7514+
isNonLooopNode := isDeadEndNode or List.isNotEmpty(adjNodes);
75087515
end isOutsideLoop;
75097516

75107517

@@ -7750,7 +7757,6 @@ algorithm
77507757
list<BackendDAE.Equation> eqLst;
77517758
case({},_,_,_,_,_,_,_,_,_)
77527759
equation
7753-
//print("done!\n");
77547760
then
77557761
(eqLstIn,replEqsIn);
77567762
case(loop1::rest,crossEq::crossEqs,{},_,_,_,_,_,_,_)
@@ -7771,8 +7777,7 @@ algorithm
77717777
//pos = Debug.bcallret1(List.isNotEmpty(eqs),List.first,eqs,pos); // CHECK THIS
77727778
pos = Debug.bcallret1(List.isNotEmpty(replEqs),List.first,replEqs,pos);
77737779
pos = Debug.bcallret1(List.isNotEmpty(eqs),List.first,eqs,pos); // CHECK THIS
7774-
7775-
7780+
77767781
eqs = List.deleteMember(loop1,pos);
77777782
//print("contract eqs: "+&stringDelimitList(List.map(eqs,intString),",")+&" to eq "+&intString(pos)+&"\n");
77787783

@@ -7781,8 +7786,6 @@ algorithm
77817786
vars = List.flatten(eqVars);
77827787
loopVars = doubleEntriesInLst(vars,{},{}); // the vars in the loop
77837788
(_,adjVars,_) = List.intersection1OnTrue(vars,loopVars,intEq); // the vars adjacent to the loop
7784-
//print("redirected vars: "+&stringDelimitList(List.map(adjVars,intString),",")+&"\n");
7785-
//print("disjoint vars: "+&stringDelimitList(List.map(loopVars,intString),",")+&"\n");
77867789

77877790
// update incidenceMatrix
77887791
List.map2_0(loopVars,Util.arrayUpdateIndexFirst,{},mTIn); //delete the vars in the loop
@@ -7793,7 +7796,6 @@ algorithm
77937796
_ = arrayUpdate(mIn,pos,adjVars); // redirect the replaced equation to the vars outside of the loops
77947797

77957798
// update remaining paths
7796-
//rest = List.map2(rest,replaceContractedNodes,pos,crossEqs2);
77977799
rest = List.map2(rest,replaceContractedNodes,pos,eqs);
77987800
rest = List.unique(rest);
77997801
//print("the remaining paths: "+&stringDelimitList(List.map(rest,HpcOmTaskGraph.intLstString),"\n")+&"\n\n");

0 commit comments

Comments
 (0)