Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
niklwors committed Oct 19, 2015
2 parents f4f5eb0 + 137767a commit 3f4cc57
Show file tree
Hide file tree
Showing 7 changed files with 433 additions and 441 deletions.
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -6521,7 +6521,7 @@ algorithm
SimCodeFunctionUtil.execStat("remove unused functions");

if Flags.isSet(Flags.GRAPHML) then
HpcOmTaskGraph.dumpBipartiteGraph(dae, fileNamePrefix);
BackendDump.dumpBipartiteGraphDAE(dae, fileNamePrefix);
end if;

if Flags.isSet(Flags.BLT_DUMP) then
Expand Down
396 changes: 396 additions & 0 deletions Compiler/BackEnd/BackendDump.mo

Large diffs are not rendered by default.

413 changes: 14 additions & 399 deletions Compiler/BackEnd/HpcOmEqSystems.mo

Large diffs are not rendered by default.

25 changes: 0 additions & 25 deletions Compiler/BackEnd/HpcOmTaskGraph.mo
Expand Up @@ -2672,31 +2672,6 @@ algorithm
HpcOmTaskGraph.dumpAsGraphMLSccLevel(taskGraph, taskGraphData, name, "", {}, {}, sccSimEqMapping, schedulerInfo, HpcOmTaskGraph.GRAPHDUMPOPTIONS(false,false,true,true));
end dumpTaskGraph;

public function dumpBipartiteGraph
input BackendDAE.BackendDAE dae;
input String fileName;
protected
BackendDAE.Variables vars;
BackendDAE.EquationArray eqs;
BackendDAE.EqSystems eqSysts;
BackendDAE.IncidenceMatrix m,mT;
list<BackendDAE.Equation> eqLst;
list<BackendDAE.Var> varLst;
list<tuple<Boolean,String>> varAtts,eqAtts;
algorithm
BackendDAE.DAE(eqs=eqSysts) := dae;
eqLst := List.flatten(List.map(List.map(eqSysts,BackendEquation.getEqnsFromEqSystem),BackendEquation.equationList));
varLst := List.flatten(List.map(List.map(eqSysts,BackendVariable.daeVars),BackendVariable.varList));
vars := BackendVariable.listVar1(varLst);
eqs := BackendEquation.listEquation(eqLst);
// build the incidence matrix for the whole System
(m,mT) := BackendDAEUtil.incidenceMatrixDispatch(vars,eqs, BackendDAE.NORMAL());
m := Array.map(m,function List.filter1OnTrue(inFilterFunc=intGt,inArg1=0));
varAtts := List.threadMap(List.fill(false,listLength(varLst)),List.fill("",listLength(varLst)),Util.makeTuple);
eqAtts := List.threadMap(List.fill(false,listLength(eqLst)),List.fill("",listLength(eqLst)),Util.makeTuple);
HpcOmEqSystems.dumpEquationSystemBipartiteGraph2(vars,eqs,m,varAtts,eqAtts,"BipartiteGraph_"+fileName);
end dumpBipartiteGraph;

public function dumpAsGraphMLSccLevel "author: marcusw, waurich
Write out the given graph as a graphml file."
input TaskGraph iGraph;
Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackEnd/IndexReduction.mo
Expand Up @@ -88,7 +88,7 @@ protected import ValuesUtil;

public function pantelidesIndexReduction "author: Frenkel TUD 2012-04
Index Reduction algorithm to get a index 1 or 0 system."
input list<list<Integer>> inEqns;
input list<list<Integer>> inEqns; // the MSSS
input Integer inActualEqn;
input BackendDAE.EqSystem inSystem;
input BackendDAE.Shared inShared;
Expand Down Expand Up @@ -731,9 +731,9 @@ algorithm
case (e::es,_,_,_,_)
equation
eqn = BackendEquation.equationNth1(eqns, e);
// fcall(Flags.BLT_DUMP, print, "differentiate equation " + intString(e) + " " + BackendDump.equationString(eqn) + "\n");
//if Flags.isSet(Flags.BLT_DUMP) then print("differentiate equation " + intString(e) + " " + BackendDump.equationString(eqn) + "\n"); end if;
(eqn_1, shared) = Differentiate.differentiateEquationTime(eqn, vars, inShared);
// fcall(Flags.BLT_DUMP, print, "differentiated equation " + intString(e) + " " + BackendDump.equationString(eqn_1) + "\n");
//if Flags.isSet(Flags.BLT_DUMP) then print("differentiated equation " + intString(e) + " " + BackendDump.equationString(eqn_1) + "\n"); end if;
eqn = BackendEquation.markDifferentiated(eqn);
(eqntpl, shared) = differentiateEqnsLst(es,vars,eqns,shared,(e,SOME(eqn_1),eqn)::inEqnTpl);
then
Expand Down
25 changes: 12 additions & 13 deletions Compiler/BackEnd/ResolveLoops.mo
Expand Up @@ -82,7 +82,7 @@ protected function resolveLoops_main "author: Waurich TUD 2014-01
eqSystem can be output. All variables and equations which do not belong to a
loop will be removed. the loops will be analysed and resolved"
input BackendDAE.EqSystem inEqSys;
input BackendDAE.Shared inShared "unused";
input BackendDAE.Shared inShared "unused, just for dumping graphml";
input Integer inSysIdx;
output BackendDAE.EqSystem outEqSys;
output BackendDAE.Shared outShared = inShared "unused";
Expand Down Expand Up @@ -111,13 +111,10 @@ algorithm
varLst = BackendVariable.varList(vars);

// build the incidence matrix for the whole System
numSimpEqs = listLength(eqLst);
numVars = listLength(varLst);
(m,mT) = BackendDAEUtil.incidenceMatrixDispatch(vars,eqs, BackendDAE.ABSOLUTE());

varAtts = List.threadMap(List.fill(false,listLength(varLst)),List.fill("",listLength(varLst)),Util.makeTuple);
eqAtts = List.threadMap(List.fill(false,listLength(eqLst)),List.fill("",listLength(eqLst)),Util.makeTuple);
HpcOmEqSystems.dumpEquationSystemBipartiteGraph2(vars,eqs,m,varAtts,eqAtts,"whole System_"+intString(inSysIdx));
//numSimpEqs = listLength(eqLst);
//numVars = listLength(varLst);
//(m,mT) = BackendDAEUtil.incidenceMatrixDispatch(vars,eqs, BackendDAE.ABSOLUTE());
BackendDump.dumpBipartiteGraphEqSystem(syst,inShared, "whole System_"+intString(inSysIdx));
//BackendDump.dumpEquationArray(eqs,"the complete DAE");

// get the linear equations and their vars
Expand All @@ -135,7 +132,7 @@ algorithm

varAtts = List.threadMap(List.fill(false,numVars),List.fill("",numVars),Util.makeTuple);
eqAtts = List.threadMap(List.fill(false,numSimpEqs),List.fill("",numSimpEqs),Util.makeTuple);
HpcOmEqSystems.dumpEquationSystemBipartiteGraph2(simpVars,simpEqs,m,varAtts,eqAtts,"rL_simpEqs_"+intString(inSysIdx));
BackendDump.dumpBipartiteGraphStrongComponent2(simpVars,simpEqs,m,varAtts,eqAtts,"rL_simpEqs_"+intString(inSysIdx));

//partition graph
partitions = arrayList(partitionBipartiteGraph(m,mT));
Expand All @@ -149,7 +146,7 @@ algorithm

varAtts = List.threadMap(List.fill(false,numVars),List.fill("",numVars),Util.makeTuple);
eqAtts = List.threadMap(List.fill(false,numSimpEqs),List.fill("",numSimpEqs),Util.makeTuple);
HpcOmEqSystems.dumpEquationSystemBipartiteGraph2(simpVars,simpEqs,m_cut,varAtts,eqAtts,"rL_loops_"+intString(inSysIdx));
BackendDump.dumpBipartiteGraphStrongComponent2(simpVars,simpEqs,m_cut,varAtts,eqAtts,"rL_loops_"+intString(inSysIdx));

// handle the partitions separately, resolve the loops in the partitions, insert the resolved equation
eqLst = resolveLoops_resolvePartitions(partitions,m_cut,mT_cut,m,mT,eqMapping,varMapping,eqLst,varLst,nonLoopEqIdcs);
Expand All @@ -165,7 +162,7 @@ algorithm

varAtts = List.threadMap(List.fill(false,numVars),List.fill("",numVars),Util.makeTuple);
eqAtts = List.threadMap(List.fill(false,numSimpEqs),List.fill("",numSimpEqs),Util.makeTuple);
HpcOmEqSystems.dumpEquationSystemBipartiteGraph2(simpVars,simpEqs,m_after,varAtts,eqAtts,"rL_after_"+intString(inSysIdx));
BackendDump.dumpBipartiteGraphStrongComponent2(simpVars,simpEqs,m_after,varAtts,eqAtts,"rL_after_"+intString(inSysIdx));

eqSys = BackendDAEUtil.clearEqSyst(syst);
then (eqSys, inSysIdx+1);
Expand Down Expand Up @@ -1788,6 +1785,7 @@ protected
BackendDAE.Variables vars, daeVars;
BackendDAE.EqSystem subSys;
BackendDAE.AdjacencyMatrixEnhanced me, me2, meT;
BackendDAE.IncidenceMatrix m;
DAE.FunctionTree funcs;
list<BackendDAE.Equation> eqLst,eqsInLst;
list<BackendDAE.Var> varLst;
Expand All @@ -1802,13 +1800,14 @@ algorithm
vars := BackendVariable.listVar1(varLst);
subSys := BackendDAEUtil.createEqSystem(vars, eqs);
(me,meT,_,_) := BackendDAEUtil.getAdjacencyMatrixEnhancedScalar(subSys,shared,false);
(_,m,_,_,_) := BackendDAEUtil.getIncidenceMatrixScalar(subSys,BackendDAE.SOLVABLE(),SOME(BackendDAEUtil.getFunctions(shared)));
ass1 := arrayCreate(size,-1);
ass2 := arrayCreate(size,-1);

// dump system as graphML
varAtts := List.threadMap(List.fill(false,listLength(varLst)),List.map(eqIdcs,intString),Util.makeTuple);
eqAtts := List.threadMap(List.fill(false,listLength(eqLst)),List.map(varIdcs,intString),Util.makeTuple);
HpcOmEqSystems.dumpEquationSystemBipartiteGraphSolve2(vars,eqs,me,varAtts,eqAtts,"shuffle_pre");
BackendDump.dumpBipartiteGraphStrongComponent2(vars,eqs,m,varAtts,eqAtts,"shuffle_pre");

//start reshuffling
resEqs := reshuffling_post3_selectShuffleEqs(me,meT);
Expand All @@ -1819,7 +1818,7 @@ algorithm
// dump system as graphML
//subSys := BackendDAEUtil.createEqSystem(vars, replEqs);
//(me2,_,_,_) := BackendDAEUtil.getAdjacencyMatrixEnhancedScalar(subSys,shared,false);
//HpcOmEqSystems.dumpEquationSystemBipartiteGraphSolve2(vars,replEqs,me2,varAtts,eqAtts,"shuffle_post");
//BackendDump.dumpBipartiteGraphStrongComponentSolvable(vars,replEqs,me2,varAtts,eqAtts,"shuffle_post");

// the new eqSystem
daeEqs := List.threadFold(eqIdcs,eqsInLst,BackendEquation.setAtIndexFirst,daeEqs);
Expand Down
7 changes: 7 additions & 0 deletions Compiler/Util/Util.mo
Expand Up @@ -1716,5 +1716,12 @@ algorithm
else stringAppendList({pwd,pd,inFileName});
end absoluteOrRelative;

public function intLstString
input list<Integer> lst;
output String s;
algorithm
s := stringDelimitList(List.map(lst,intString),", ");
end intLstString;

annotation(__OpenModelica_Interface="util");
end Util;

0 comments on commit 3f4cc57

Please sign in to comment.