Skip to content

Commit

Permalink
Do not reset matching on no change
Browse files Browse the repository at this point in the history
For wrapFunctionCall, do not reset the matching unless the module
actually added an equation or variable.
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Mar 31, 2016
1 parent 09afcd1 commit 971d7f1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
12 changes: 9 additions & 3 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -6741,19 +6741,22 @@ protected
BackendDAE.Shared shared;
list<Option<BackendDAE.StructurallySingularSystemHandlerArg>> args;
Boolean causalized;
constant Boolean debug = false;
algorithm
BackendDAE.DAE(systs,shared) := inDAE;
// reduce index
(systs,shared,args,causalized) := mapCausalizeDAE(systs,shared,inMatchingOptions,matchingAlgorithm,stateDeselection,{},{},false);
execStat("causalizeDAE -> matching");
if debug then execStat("causalizeDAE -> matching"); end if;
// do late inline
outDAE := if dolateinline then BackendInline.lateInlineFunction(BackendDAE.DAE(systs,shared)) else BackendDAE.DAE(systs,shared);
if debug and dolateinline then execStat("causalizeDAE -> lateInlineFunction"); end if;
// do state selection
BackendDAE.DAE(systs,shared) := stateDeselectionDAE(causalized,outDAE,args,stateDeselection);
if debug then execStat("causalizeDAE -> state selection"); end if;
// sort assigned equations to blt form
systs := mapSortEqnsDAE(systs,shared,{});
if debug then execStat("causalizeDAE -> sort equations"); end if;
outDAE := BackendDAE.DAE(systs,shared);
execStat("causalizeDAE -> state selection");
end causalizeDAE;

protected function mapCausalizeDAE "
Expand Down Expand Up @@ -6959,6 +6962,7 @@ protected
String moduleStr;
BackendDAE.EqSystems systs;
BackendDAE.Shared shared;
constant Boolean debug = false;
algorithm
execStat("prepare postOptimizeDAE");
for postOptModule in inPostOptModules loop
Expand All @@ -6968,8 +6972,9 @@ algorithm
BackendDAE.DAE(systs, shared) := optModule(outDAE);
(systs, shared) := filterEmptySystems(systs, shared);
outDAE := BackendDAE.DAE(systs, shared);
if debug then execStat("postOpt " + moduleStr); end if;
outDAE := causalizeDAE(outDAE, NONE(), inMatchingAlgorithm, inDAEHandler, false);
execStat("postOpt " + moduleStr);
execStat("postOpt " + (if debug then "causalize " else "") + moduleStr);
if Flags.isSet(Flags.OPT_DAE_DUMP) then
print("\npost-optimization module " + moduleStr + ":\n\n");
BackendDump.printBackendDAE(outDAE);
Expand Down Expand Up @@ -7011,6 +7016,7 @@ algorithm

// transformation phase (matching and sorting using a index reduction method
dae := causalizeDAE(dae, NONE(), matchingAlgorithm, daeHandler, true);
execStat("causalizeDAE (first run)");
//fcall(Flags.DUMP_DAE_LOW, BackendDump.bltdump, ("bltdump", dae));

// post-optimization phase
Expand Down
20 changes: 11 additions & 9 deletions Compiler/BackEnd/CommonSubExpression.mo
Expand Up @@ -75,7 +75,7 @@ protected
BackendDAE.Variables orderedVars;
DAE.FunctionTree functionTree;
HashTableExpToExp.HashTable HT;
Integer index=System.tmpTickIndex(Global.backendDAE_cseIndex);
Integer index=System.tmpTickIndex(Global.backendDAE_cseIndex), index2;
list<BackendDAE.Equation> eqList;
list<BackendDAE.Var> varList;
algorithm
Expand All @@ -98,15 +98,17 @@ algorithm
BaseHashTable.dumpHashTable(HT);
end if;

syst.orderedEqs := BackendEquation.addEquations(eqList, orderedEqs);
syst.orderedVars := BackendVariable.addVars(varList, orderedVars);
syst.m := NONE();
syst.mT := NONE();
syst.matching := BackendDAE.NO_MATCHING();
if not listEmpty(eqList) or not listEmpty(varList) then
syst.orderedEqs := BackendEquation.addEquations(eqList, orderedEqs);
syst.orderedVars := BackendVariable.addVars(varList, orderedVars);
syst.m := NONE();
syst.mT := NONE();
syst.matching := BackendDAE.NO_MATCHING();

if Flags.isSet(Flags.DUMP_CSE) or Flags.isSet(Flags.DUMP_CSE_VERBOSE) then
BackendDump.dumpVariables(syst.orderedVars, "########### Updated Variable List ###########");
BackendDump.dumpEquationArray(syst.orderedEqs, "########### Updated Equation List ###########");
if Flags.isSet(Flags.DUMP_CSE) or Flags.isSet(Flags.DUMP_CSE_VERBOSE) then
BackendDump.dumpVariables(syst.orderedVars, "########### Updated Variable List ###########");
BackendDump.dumpEquationArray(syst.orderedEqs, "########### Updated Equation List ###########");
end if;
end if;

eqs := syst::eqs;
Expand Down

0 comments on commit 971d7f1

Please sign in to comment.