Skip to content

Commit

Permalink
- GraphMLNew added -> this module will replace the GraphML-Module in …
Browse files Browse the repository at this point in the history
…the next weeeks

- The hpcom-openmp-code is now static
- The hpcom-module creates another graph now, which contains cache-line informations (this is a prototype at the moment and will be extended soon)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19065 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Marcus Walther committed Feb 12, 2014
1 parent 6207706 commit 3be0cff
Show file tree
Hide file tree
Showing 11 changed files with 1,657 additions and 149 deletions.
97 changes: 57 additions & 40 deletions Compiler/BackEnd/HpcOmEqSystems.mo
Expand Up @@ -54,7 +54,7 @@ protected import ComponentReference;
protected import Debug;
protected import Expression;
protected import Flags;
protected import GraphML;
protected import GraphMLNew;
protected import HpcOmTaskGraph;
protected import List;
protected import Matching;
Expand Down Expand Up @@ -1764,7 +1764,8 @@ algorithm
BackendDAE.Variables vars, orderedVars;
BackendDAE.EquationArray eqs, orderedEqs;
BackendDAE.EqSystem eqSysIn;
GraphML.Graph graph;
GraphMLNew.GraphInfo graphInfo;
Integer graphIdx;
list<BackendDAE.Var> varLst;
list<BackendDAE.Equation> eqLst;
Integer nameAttIdx, typeAttIdx, numberOfEqs, numberOfVars, sysIdx;
Expand Down Expand Up @@ -1796,13 +1797,14 @@ algorithm
BackendDump.dumpIncidenceMatrixT(mEqSysT);
varRange = List.intRange(numberOfVars);
eqRange = List.intRange(numberOfEqs);
graph = GraphML.getGraph("TornSystemGraph", true);
(typeAttIdx,graph) = GraphML.addAttribute("", "type", GraphML.TYPE_STRING(), GraphML.TARGET_NODE(), graph);
(nameAttIdx,graph) = GraphML.addAttribute("", "name", GraphML.TYPE_STRING(), GraphML.TARGET_NODE(), graph);
graph = List.fold2(varRange,addVarNodeToGraph,vars,{nameAttIdx,typeAttIdx}, graph);
graph = List.fold2(eqRange,addEqNodeToGraph,eqs,{nameAttIdx,typeAttIdx}, graph);
graph = List.fold1(eqRange,addEdgeToGraph,mEqSys,graph);
GraphML.dumpGraph(graph,"TornSystemGraph"+&intString(sysIdx)+&".graphml");
graphInfo = GraphMLNew.createGraphInfo();
(graphInfo,(_,graphIdx)) = GraphMLNew.addGraph("TornSystemGraph", true, graphInfo);
(graphInfo,(_,typeAttIdx)) = GraphMLNew.addAttribute("", "type", GraphMLNew.TYPE_STRING(), GraphMLNew.TARGET_NODE(), graphInfo);
(graphInfo,(_,nameAttIdx)) = GraphMLNew.addAttribute("", "name", GraphMLNew.TYPE_STRING(), GraphMLNew.TARGET_NODE(), graphInfo);
((graphInfo,_)) = List.fold2(varRange,addVarNodeToGraph,vars,{nameAttIdx,typeAttIdx}, (graphInfo,graphIdx));
((graphInfo,_)) = List.fold2(eqRange,addEqNodeToGraph,eqs,{nameAttIdx,typeAttIdx}, (graphInfo,graphIdx));
graphInfo = List.fold1(eqRange,addEdgeToGraph,mEqSys,graphInfo);
GraphMLNew.dumpGraph(graphInfo,"TornSystemGraph"+&intString(sysIdx)+&".graphml");
then
();
case(_,BackendDAE.EQUATIONSYSTEM(eqns=allEqs,vars=allVars, jac=_, jacType=_))
Expand All @@ -1825,13 +1827,14 @@ case(_,BackendDAE.EQUATIONSYSTEM(eqns=allEqs,vars=allVars, jac=_, jacType=_))
BackendDump.dumpIncidenceMatrix(mEqSys);
varRange = List.intRange(numberOfVars);
eqRange = List.intRange(numberOfEqs);
graph = GraphML.getGraph("EqSystemGraph", true);
(typeAttIdx,graph) = GraphML.addAttribute("", "type", GraphML.TYPE_STRING(), GraphML.TARGET_NODE(), graph);
(nameAttIdx,graph) = GraphML.addAttribute("", "name", GraphML.TYPE_STRING(), GraphML.TARGET_NODE(), graph);
graph = List.fold2(varRange,addVarNodeToGraph,vars,{nameAttIdx,typeAttIdx}, graph);
graph = List.fold2(eqRange,addEqNodeToGraph,eqs,{nameAttIdx,typeAttIdx}, graph);
graph = List.fold1(eqRange,addEdgeToGraph,mEqSys,graph);
GraphML.dumpGraph(graph,"EqSystemGraph"+&intString(sysIdx)+&".graphml");
graphInfo = GraphMLNew.createGraphInfo();
(graphInfo,(_,graphIdx)) = GraphMLNew.addGraph("EqSystemGraph", true, graphInfo);
(graphInfo,(_,typeAttIdx)) = GraphMLNew.addAttribute("", "type", GraphMLNew.TYPE_STRING(), GraphMLNew.TARGET_NODE(), graphInfo);
(graphInfo,(_,nameAttIdx)) = GraphMLNew.addAttribute("", "name", GraphMLNew.TYPE_STRING(), GraphMLNew.TARGET_NODE(), graphInfo);
((graphInfo,_)) = List.fold2(varRange,addVarNodeToGraph,vars,{nameAttIdx,typeAttIdx}, (graphInfo,graphIdx));
((graphInfo,_)) = List.fold2(eqRange,addEqNodeToGraph,eqs,{nameAttIdx,typeAttIdx}, (graphInfo,graphIdx));
graphInfo = List.fold1(eqRange,addEdgeToGraph,mEqSys,graphInfo);
GraphMLNew.dumpGraph(graphInfo,"EqSystemGraph"+&intString(sysIdx)+&".graphml");
then
();
end match;
Expand All @@ -1847,48 +1850,50 @@ protected
Integer nameAttIdx,typeAttIdx, numberOfVars,numberOfEqs;
list<Integer> varRange,eqRange;
BackendDAE.IncidenceMatrix m;
GraphML.Graph graph;
GraphMLNew.GraphInfo graphInfo;
Integer graphIdx;
algorithm
numberOfEqs := BackendDAEUtil.equationArraySize(eqsIn);
numberOfVars := BackendVariable.varsSize(varsIn);
varRange := List.intRange(numberOfVars);
eqRange := List.intRange(numberOfEqs);
graph := GraphML.getGraph("EqSystemGraph", true);
(typeAttIdx,graph) := GraphML.addAttribute("", "type", GraphML.TYPE_STRING(), GraphML.TARGET_NODE(), graph);
(nameAttIdx,graph) := GraphML.addAttribute("", "name", GraphML.TYPE_STRING(), GraphML.TARGET_NODE(), graph);
graph := List.fold2(varRange,addVarNodeToGraph,varsIn,{nameAttIdx,typeAttIdx}, graph);
graph := List.fold2(eqRange,addEqNodeToGraph,eqsIn,{nameAttIdx,typeAttIdx}, graph);
graph := List.fold1(eqRange,addEdgeToGraph,mIn,graph);
GraphML.dumpGraph(graph,name+&".graphml");
graphInfo := GraphMLNew.createGraphInfo();
(graphInfo,(_,graphIdx)) := GraphMLNew.addGraph("EqSystemGraph", true, graphInfo);
(graphInfo,(_,typeAttIdx)) := GraphMLNew.addAttribute("", "type", GraphMLNew.TYPE_STRING(), GraphMLNew.TARGET_NODE(), graphInfo);
(graphInfo,(_,nameAttIdx)) := GraphMLNew.addAttribute("", "name", GraphMLNew.TYPE_STRING(), GraphMLNew.TARGET_NODE(), graphInfo);
((graphInfo,_)) := List.fold2(varRange,addVarNodeToGraph,varsIn,{nameAttIdx,typeAttIdx}, (graphInfo,graphIdx));
((graphInfo,_)) := List.fold2(eqRange,addEqNodeToGraph,eqsIn,{nameAttIdx,typeAttIdx}, (graphInfo,graphIdx));
graphInfo := List.fold1(eqRange,addEdgeToGraph,mIn,graphInfo);
GraphMLNew.dumpGraph(graphInfo,name+&".graphml");
end dumpEquationSystemGraphML1;


protected function addEdgeToGraph "adds an edge to the graph by traversing the incidence matrix.
author:Waurich TUD 2013-12"
input Integer eqIdx;
input BackendDAE.IncidenceMatrix m;
input GraphML.Graph graphIn;
output GraphML.Graph graphOut;
input GraphMLNew.GraphInfo graphInfoIn;
output GraphMLNew.GraphInfo graphInfoOut;
protected
list<Integer> varLst;
algorithm
varLst := arrayGet(m,eqIdx);
graphOut := List.fold1(varLst,addEdgeToGraph2,eqIdx,graphIn);
graphInfoOut := List.fold1(varLst,addEdgeToGraph2,eqIdx,graphInfoIn);
end addEdgeToGraph;


protected function addEdgeToGraph2 "helper for addEdgeToGraph.
author:Waurich TUD 2013-12"
input Integer varIdx;
input Integer eqIdx;
input GraphML.Graph graphIn;
output GraphML.Graph graphOut;
input GraphMLNew.GraphInfo graphInfoIn;
output GraphMLNew.GraphInfo graphInfoOut;
protected
String eqNodeId, varNodeId;
algorithm
eqNodeId := getEqNodeIdx(eqIdx);
varNodeId := getVarNodeIdx(varIdx);
graphOut := GraphML.addEdge("Edge_"+&intString(varIdx)+&"_"+&intString(eqIdx),varNodeId,eqNodeId,GraphML.COLOR_BLACK,GraphML.LINE(),GraphML.LINEWIDTH_STANDARD,NONE(),(NONE(),NONE()),{}, graphIn);
(graphInfoOut,_) := GraphMLNew.addEdge("Edge_"+&intString(varIdx)+&"_"+&intString(eqIdx),varNodeId,eqNodeId,GraphMLNew.COLOR_BLACK,GraphMLNew.LINE(),GraphMLNew.LINEWIDTH_STANDARD,false,{},(GraphMLNew.ARROWNONE(),GraphMLNew.ARROWNONE()),{}, graphInfoIn);
end addEdgeToGraph2;


Expand All @@ -1915,14 +1920,17 @@ author:Waurich TUD 2013-12"
input Integer indx;
input BackendDAE.Variables vars;
input list<Integer> attributeIdcs;//<name,type>
input GraphML.Graph graphIn;
output GraphML.Graph graphOut;
input tuple<GraphMLNew.GraphInfo,Integer> graphInfoIn;
output tuple<GraphMLNew.GraphInfo,Integer> graphInfoOut;
protected
BackendDAE.Var var;
Integer nameAttrIdx,typeAttIdx;
String varString, varNodeId;
Integer nameAttrIdx,typeAttIdx, graphIdx;
String varString, varNodeId, idxString;
list<String> varChars;
GraphMLNew.GraphInfo graphInfo;
GraphMLNew.NodeLabel nodeLabel;
algorithm
(graphInfo,graphIdx) := graphInfoIn;
nameAttrIdx := listGet(attributeIdcs,1);
typeAttIdx := listGet(attributeIdcs,2); // if its a tearingvar or residual or an other
var := BackendVariable.getVarAt(vars,indx);
Expand All @@ -1931,7 +1939,10 @@ algorithm
varChars := List.map(varChars,HpcOmTaskGraph.prepareXML);
varString := stringCharListString(varChars);
varNodeId := getVarNodeIdx(indx);
graphOut := GraphML.addNode(varNodeId,intString(indx),GraphML.COLOR_ORANGE2,GraphML.ELLIPSE(),SOME(varString),{(nameAttrIdx,varString)},{},graphIn);
idxString := intString(indx);
nodeLabel := GraphMLNew.NODELABEL_INTERNAL(idxString,NONE(),GraphMLNew.FONTPLAIN());
(graphInfo,_) := GraphMLNew.addNode(varNodeId, GraphMLNew.COLOR_ORANGE2, {nodeLabel},GraphMLNew.ELLIPSE(),SOME(varString),{(nameAttrIdx,varString)},graphIdx,graphInfo);
graphInfoOut := (graphInfo,graphIdx);
end addVarNodeToGraph;


Expand All @@ -1940,22 +1951,28 @@ author:Waurich TUD 2013-12"
input Integer indx;
input BackendDAE.EquationArray eqs;
input list<Integer> attributeIdcs;//<name>
input GraphML.Graph graphIn;
output GraphML.Graph graphOut;
input tuple<GraphMLNew.GraphInfo,Integer> graphInfoIn;
output tuple<GraphMLNew.GraphInfo,Integer> graphInfoOut;
protected
BackendDAE.Equation eq;
Integer nameAttrIdx;
String eqString, eqNodeId;
Integer nameAttrIdx, graphIdx;
String eqString, eqNodeId, idxString;
list<String> eqChars;
GraphMLNew.GraphInfo graphInfo;
GraphMLNew.NodeLabel nodeLabel;
algorithm
(graphInfo,graphIdx) := graphInfoIn;
nameAttrIdx := listGet(attributeIdcs,1);
{eq} := BackendEquation.getEqns({indx}, eqs);
eqString := BackendDump.equationString(eq);
eqChars := stringListStringChar(eqString);
eqChars := List.map(eqChars,HpcOmTaskGraph.prepareXML);
eqString := stringCharListString(eqChars);
eqNodeId := getEqNodeIdx(indx);
graphOut := GraphML.addNode(eqNodeId,intString(indx),GraphML.COLOR_GREEN2,GraphML.RECTANGLE(),SOME(eqString),{(nameAttrIdx,eqString)},{},graphIn);
idxString := intString(indx);
nodeLabel := GraphMLNew.NODELABEL_INTERNAL(idxString,NONE(),GraphMLNew.FONTPLAIN());
(graphInfo,_) := GraphMLNew.addNode(eqNodeId,GraphMLNew.COLOR_GREEN2,{nodeLabel},GraphMLNew.RECTANGLE(),SOME(eqString),{(nameAttrIdx,eqString)},graphIdx,graphInfo);
graphInfoOut := (graphInfo,graphIdx);
end addEqNodeToGraph;

//--------------------------------------------------//
Expand Down
32 changes: 18 additions & 14 deletions Compiler/BackEnd/HpcOmScheduler.mo
Expand Up @@ -995,23 +995,24 @@ algorithm
end match;
end printTaskRefList;

public function convertScheduleStrucToInfo
public function convertScheduleStrucToInfo "author: marcusw
Convert the given schedule-information into an node-array of informations."
input Schedule iSchedule;
input Integer iTaskCount;
output array<tuple<Integer,Integer>> oScheduleInfo;
output array<tuple<Integer,Integer,Real>> oScheduleInfo; //array which contains <threadId,taskNumber,finishTime> for each node (index)
protected
array<tuple<Integer,Integer>> tmpScheduleInfo;
array<tuple<Integer,Integer,Real>> tmpScheduleInfo;
array<list<Task>> threadTasks;
algorithm
oScheduleInfo := match(iSchedule,iTaskCount)
case(THREADSCHEDULE(threadTasks=threadTasks),_)
equation
tmpScheduleInfo = arrayCreate(iTaskCount,(-1,-1));
tmpScheduleInfo = arrayCreate(iTaskCount,(-1,-1,-1.0));
tmpScheduleInfo = Util.arrayFold(threadTasks,convertScheduleStrucToInfo0,tmpScheduleInfo);
then tmpScheduleInfo;
case(LEVELSCHEDULE(_),_)
equation
tmpScheduleInfo = arrayCreate(iTaskCount,(-1,-1));
tmpScheduleInfo = arrayCreate(iTaskCount,(-1,-1,-1.0));
then tmpScheduleInfo;
else
equation
Expand All @@ -1020,27 +1021,30 @@ algorithm
end match;
end convertScheduleStrucToInfo;

protected function convertScheduleStrucToInfo0
protected function convertScheduleStrucToInfo0 "author: marcusw
Convert the given task list into an node-array of informations."
input list<Task> iTaskList;
input array<tuple<Integer,Integer>> iScheduleInfo;
output array<tuple<Integer,Integer>> oScheduleInfo;
input array<tuple<Integer,Integer,Real>> iScheduleInfo;
output array<tuple<Integer,Integer,Real>> oScheduleInfo;
algorithm
((oScheduleInfo,_)) := List.fold(iTaskList, convertScheduleStrucToInfo1, (iScheduleInfo,1));
end convertScheduleStrucToInfo0;

protected function convertScheduleStrucToInfo1
protected function convertScheduleStrucToInfo1 "author: marcusw
Convert the given task into a tuple of informations, if it is a CalcTask."
input Task iTask;
input tuple<array<tuple<Integer,Integer>>,Integer> iScheduleInfo; //ScheduleInfo and task number
output tuple<array<tuple<Integer,Integer>>,Integer> oScheduleInfo;
input tuple<array<tuple<Integer,Integer,Real>>,Integer> iScheduleInfo; //ScheduleInfo and task number
output tuple<array<tuple<Integer,Integer,Real>>,Integer> oScheduleInfo;
protected
Integer taskIdx, taskNumber;
Integer threadIdx;
array<tuple<Integer,Integer>> tmpScheduleInfo;
array<tuple<Integer,Integer,Real>> tmpScheduleInfo;
Real timeFinished;
algorithm
oScheduleInfo := match(iTask,iScheduleInfo)
case(CALCTASK(index=taskIdx,threadIdx=threadIdx),(tmpScheduleInfo,taskNumber))
case(CALCTASK(index=taskIdx,threadIdx=threadIdx,timeFinished=timeFinished),(tmpScheduleInfo,taskNumber))
equation
tmpScheduleInfo = arrayUpdate(tmpScheduleInfo,taskIdx,(threadIdx,taskNumber));
tmpScheduleInfo = arrayUpdate(tmpScheduleInfo,taskIdx,(threadIdx,taskNumber,timeFinished));
then ((tmpScheduleInfo,taskNumber+1));
case (ASSIGNLOCKTASK(_),_) then iScheduleInfo;
case (RELEASELOCKTASK(_),_) then iScheduleInfo;
Expand Down

0 comments on commit 3be0cff

Please sign in to comment.