Skip to content

Commit

Permalink
- generate complete DAE task-graph including asserts
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21617 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Volker Waurich committed Jul 25, 2014
1 parent 65d11fa commit d8d01ca
Show file tree
Hide file tree
Showing 7 changed files with 419 additions and 103 deletions.
10 changes: 10 additions & 0 deletions Compiler/BackEnd/BackendEquation.mo
Expand Up @@ -467,6 +467,16 @@ algorithm
(_,outExpComponentRefLst) := traverseBackendDAEExpsEqnList(inEquationLst,extractCrefsFromExp,{});
end equationsCrefs;

public function equationCrefs
"author: PA
From one equation return all
occuring component references."
input BackendDAE.Equation inEquation;
output list<DAE.ComponentRef> outExpComponentRefLst;
algorithm
(_,outExpComponentRefLst) := traverseBackendDAEExpsEqnList({inEquation},extractCrefsFromExp,{});
end equationCrefs;

public function getAllCrefFromEquations
input BackendDAE.EquationArray inEqns;
output list<DAE.ComponentRef> cr_lst;
Expand Down
46 changes: 32 additions & 14 deletions Compiler/BackEnd/HpcOmSimCodeMain.mo
Expand Up @@ -136,13 +136,13 @@ algorithm
list<SimCode.StateSet> stateSets;
array<Integer> systemIndexMap;
list<tuple<Integer,Integer>> equationSccMapping, equationSccMapping1; //Maps each simEq to the scc
array<list<Integer>> sccSimEqMapping; //Maps each scc to a list of simEqs
array<list<Integer>> sccSimEqMapping, daeSccMapping; //Maps each scc to a list of simEqs
array<Integer> simeqCompMapping; //Maps each simEq to the scc
list<BackendDAE.TimeEvent> timeEvents;
BackendDAE.StrongComponents allComps, initComps;

HpcOmTaskGraph.TaskGraph taskGraph, taskGraphOde, taskGraphEvent, taskGraphSimplified, taskGraphScheduled, taskGraphInit;
HpcOmTaskGraph.TaskGraphMeta taskGraphData, taskGraphDataOde, taskGraphDataEvent, taskGraphDataSimplified,taskGraphDataScheduled, taskGraphDataInit;
HpcOmTaskGraph.TaskGraph taskGraph, taskGraphDAE, taskGraphOde, taskGraphEvent, taskGraphSimplified, taskGraphScheduled, taskGraphInit;
HpcOmTaskGraph.TaskGraphMeta taskGraphData, taskGraphDataDAE, taskGraphDataOde, taskGraphDataEvent, taskGraphDataSimplified,taskGraphDataScheduled, taskGraphDataInit;
String fileName, fileNamePrefix;
Integer numProc;
list<list<Integer>> parallelSets;
Expand Down Expand Up @@ -192,42 +192,59 @@ algorithm
parameterEquations, removedEquations, algorithmAndEquationAsserts, zeroCrossingsEquations, jacobianEquations, stateSets, constraints, classAttributes, zeroCrossings, relations, timeEvents, whenClauses,
discreteModelVars, extObjInfo, makefileParams, delayedExps, jacobianMatrixes, simulationSettingsOpt, fileNamePrefix, _, _, _, crefToSimVarHT, backendMapping) = simCode;

//get SCC to simEqSys-mappping
//----------------------------
(allComps,_) = HpcOmTaskGraph.getSystemComponents(inBackendDAE);
//print("All components size: " +& intString(listLength(allComps)) +& "\n");
highestSccIdx = findHighestSccIdxInMapping(equationSccMapping,-1);
compCountPlusDummy = listLength(allComps)+1;
equationSccMapping1 = removeDummyStateFromMapping(equationSccMapping);
//the mapping can contain a dummy state as first scc
equationSccMapping = Util.if_(intEq(highestSccIdx, compCountPlusDummy), equationSccMapping1, equationSccMapping);

sccSimEqMapping = convertToSccSimEqMapping(equationSccMapping, listLength(allComps));
simeqCompMapping = convertToSimeqCompMapping(equationSccMapping, lastEqMappingIdx);
simEqIdxSimEqMapping = getSimEqIdxSimEqMapping(allEquations, arrayLength(simeqCompMapping));

//dumpSimEqSCCMapping(simeqCompMapping);
SimCodeUtil.execStat("hpcom setup");

//dumpSccSimEqMapping(sccSimEqMapping);

//Create TaskGraph
//----------------
//Create TaskGraph for all strongly connected components
//------------------------------------------------------
(taskGraph,taskGraphData) = HpcOmTaskGraph.createTaskGraph(inBackendDAE,filenamePrefix);
SimCodeUtil.execStat("hpcom createTaskGraph");

//Create Costs
//------------
taskGraphData = HpcOmTaskGraph.createCosts(inBackendDAE, filenamePrefix +& "_eqs_prof" , simeqCompMapping, taskGraphData);
SimCodeUtil.execStat("hpcom create costs");

fileName = ("taskGraph"+&filenamePrefix+&".graphml");
schedulerInfo = arrayCreate(arrayLength(taskGraph), (-1,-1,-1.0));
HpcOmTaskGraph.dumpAsGraphMLSccLevel(taskGraph, taskGraphData,inBackendDAE, fileName, "", {}, {}, sccSimEqMapping ,schedulerInfo);
SimCodeUtil.execStat("hpcom dump TaskGraph");


//print("DAE_onlySCCs\n");
//HpcOmTaskGraph.printTaskGraph(taskGraph);
//HpcOmTaskGraph.printTaskGraphMeta(taskGraphData);

//Get complete DAE System
//-----------------------
taskGraphDAE = arrayCopy(taskGraph);
taskGraphDataDAE = HpcOmTaskGraph.copyTaskGraphMeta(taskGraphData);
(taskGraphDAE,taskGraphDataDAE) = HpcOmTaskGraph.appendRemovedEquations(inBackendDAE,taskGraphDAE,taskGraphDataDAE);

fileName = ("taskGraph"+&filenamePrefix+&"DAE.graphml");
daeSccMapping = listArray(List.map(SimCodeUtil.getRemovedEquationSimEqSysIdxes(simCode),List.create));
daeSccMapping = Util.arrayAppend(sccSimEqMapping,daeSccMapping);
schedulerInfo = arrayCreate(arrayLength(taskGraphDAE), (-1,-1,-1.0));
HpcOmTaskGraph.dumpAsGraphMLSccLevel(taskGraphDAE, taskGraphDataDAE,inBackendDAE, fileName, "", {}, {}, daeSccMapping ,schedulerInfo);

//print("DAE\n");
//HpcOmTaskGraph.printTaskGraph(taskGraphDAE);
//HpcOmTaskGraph.printTaskGraphMeta(taskGraphDataDAE);

//Get Event System
//----------------
taskGraphEvent = arrayCopy(taskGraph);
taskGraphDataEvent = HpcOmTaskGraph.copyTaskGraphMeta(taskGraphData);
(taskGraphEvent,taskGraphDataEvent) = HpcOmTaskGraph.getEventSystem(taskGraphEvent,taskGraphDataEvent,inBackendDAE, zeroCrossings, simeqCompMapping);
Expand All @@ -251,14 +268,15 @@ algorithm
taskGraphMetaMessage = Util.if_(taskGraphMetaValid, "TaskgraphMeta valid\n", "TaskgraphMeta invalid\n");
print(taskGraphMetaMessage);

//print("ODE\n");
//HpcOmTaskGraph.printTaskGraph(taskGraphOde);
//HpcOmTaskGraph.printTaskGraphMeta(taskGraphDataOde);

//Assign levels and get critcal path
//----------------------------------
((criticalPaths,cpCosts),(criticalPathsWoC,cpCostsWoC),_) = HpcOmTaskGraph.getCriticalPaths(taskGraphOde,taskGraphDataOde);
criticalPathInfo = HpcOmTaskGraph.dumpCriticalPathInfo((criticalPaths,cpCosts),(criticalPathsWoC,cpCostsWoC));
((graphOps,graphCosts)) = HpcOmTaskGraph.sumUpExecCosts(taskGraphDataOde);
((graphOps,graphCosts)) = HpcOmTaskGraph.sumUpExeCosts(taskGraphOde,taskGraphDataOde);
graphCosts = HpcOmTaskGraph.roundReal(graphCosts,2);
criticalPathInfo = criticalPathInfo +& " sum: (" +& realString(graphCosts) +& " ; " +& intString(graphOps) +& ")";
fileName = ("taskGraph"+&filenamePrefix+&"ODE.graphml");
Expand All @@ -268,9 +286,9 @@ algorithm
SimCodeUtil.execStat("hpcom dump ODE TaskGraph");

// Analyse Systems of Equations
//-------------
//-----------------------------
(scheduledTasks,scheduledDAENodes) = HpcOmEqSystems.parallelizeTornSystems(taskGraphOde,taskGraphDataOde,sccSimEqMapping,inBackendDAE);
HpcOmScheduler.printTaskList(scheduledTasks);
//HpcOmScheduler.printTaskList(scheduledTasks);

//Apply filters
//-------------
Expand Down

0 comments on commit d8d01ca

Please sign in to comment.