Skip to content

Commit

Permalink
- mergingSimpleNodes considers now endnodes
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17182 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Volker Waurich committed Sep 11, 2013
1 parent f9fa40e commit f88ec56
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
1 change: 0 additions & 1 deletion Compiler/BackEnd/HpcOmSimCode.mo
Expand Up @@ -206,7 +206,6 @@ algorithm
//Apply filters
//-------------
(taskGraph1,taskGraphData1) = applyFiltersToGraph(taskGraphOde,taskGraphDataOde,inBackendDAE);

//HpcOmTaskGraph.printTaskGraph(taskGraph1);
//HpcOmTaskGraph.printTaskGraphMeta(taskGraphData1);

Expand Down
37 changes: 26 additions & 11 deletions Compiler/BackEnd/HpcOmTaskGraph.mo
Expand Up @@ -3042,14 +3042,13 @@ algorithm
print(intString(cpIdx)+&". path: "+&intLstString(listGet(criticalPathsIn,cpIdx))+&"\n");
end printCriticalPathInfo1;


// functions to merge simple nodes
//------------------------------------------
//------------------------------------------


public function mergeSimpleNodes " merges all nodes in the graph that have only one predecessor and one successor.
author:Waurich TUD 2013-07"
author: Waurich TUD 2013-07"
input TaskGraph graphIn;
input TaskGraphMeta graphDataIn;
input BackendDAE.BackendDAE daeIn;
Expand All @@ -3075,9 +3074,9 @@ protected
algorithm
TASKGRAPHMETA(inComps = inComps, varSccMapping=varSccMapping, eqSccMapping=eqSccMapping, rootNodes = rootNodes, nodeNames =nodeNames,nodeDescs=nodeDescs, exeCosts = exeCosts, commCosts=commCosts, nodeMark=nodeMark) := graphDataIn;
BackendDAE.DAE(eqs = systs) := daeIn;
allTheNodes := List.intRange(arrayLength(graphIn)); // to parse the node indeces
oneChildren := findOneChildParents(allTheNodes,graphIn,{{}},0);
oneChildren := listDelete(oneChildren,listLength(oneChildren)-1); // remove the empty startValue
allTheNodes := List.intRange(arrayLength(graphIn)); // to traverse the node indeces
oneChildren := findOneChildParents(allTheNodes,graphIn,{{}},0); // paths of nodes with just one successor per node (extended: and endnodes with just one parent node)
oneChildren := listDelete(oneChildren,listLength(oneChildren)-1); // remove the empty startValue {}
oneChildren := List.removeOnTrue(1,compareListLengthOnTrue,oneChildren); // remove paths of length 1
//oneChildren := List.fold1(List.intRange(listLength(oneChildren)),checkParentNode,graphIn,oneChildren); // deletes the lists with just one entry that have more than one parent
(graphOut,graphDataOut) := contractNodesInGraph(oneChildren,graphIn,graphDataIn);
Expand Down Expand Up @@ -3344,11 +3343,12 @@ end equalLists;


protected function findOneChildParents " fold function to find nodes or paths in the taskGraph with just one successor per node.
author:Waurich TUD 2013-07"
extended: adds endnodes without successor as well
author: Waurich TUD 2013-07"
input list<Integer> allNodes;
input TaskGraph graphIn;
input list<list<Integer>> lstIn;
input Integer inPath; // the current nodeINdex in a path of only cildren. if no path then 0.
input Integer inPath; // the current nodeIndex in a path of only cildren. if no path then 0.
output list<list<Integer>> lstOut;
algorithm
lstOut := matchcontinue(allNodes,graphIn,lstIn,inPath)
Expand Down Expand Up @@ -3391,7 +3391,7 @@ algorithm
false = intEq(inPath,0);
nodeChildren = arrayGet(graphIn,inPath);
parents = getParentNodes(inPath,graphIn);
true = listLength(nodeChildren) == 1 and listLength(parents) == 1;
true = listLength(nodeChildren) == 1 and List.isNotEmpty(nodeChildren) and listLength(parents) == 1;
child = listGet(nodeChildren,1);
pathLst = List.first(lstIn);
pathLst = inPath::pathLst;
Expand All @@ -3401,14 +3401,29 @@ algorithm
then
lstTmp;
case(_,_,_,_)
// follow path and check that there are more children or a child with more parents
// follow path and check that there is an endnode without successor that will be added to the path
equation
false = intEq(inPath,0);
nodeChildren = arrayGet(graphIn,inPath);
parents = getParentNodes(inPath,graphIn);
true = listLength(nodeChildren) <> 1 or listLength(parents) <> 1;
true = List.isEmpty(nodeChildren) and listLength(parents) == 1;
pathLst = List.first(lstIn);
pathLst = inPath::pathLst;
lstTmp = List.replaceAt(pathLst,0,lstIn);
rest = List.deleteMember(allNodes,inPath);
lstTmp = findOneChildParents(rest,graphIn,lstIn,0);
lstTmp = findOneChildParents(rest,graphIn,lstTmp,0);
then
lstTmp;
case(_,_,_,_)
// follow path and check that there are more children or a child with more parents. end path before this node
equation
false = intEq(inPath,0);
nodeChildren = arrayGet(graphIn,inPath);
parents = getParentNodes(inPath,graphIn);
true = listLength(nodeChildren) <> 1 or listLength(parents) <> 1;
//rest = List.deleteMember(allNodes,inPath);
//lstTmp = findOneChildParents(rest,graphIn,lstIn,0);
lstTmp = findOneChildParents(allNodes,graphIn,lstIn,0);
then
lstTmp;
else
Expand Down

0 comments on commit f88ec56

Please sign in to comment.