Skip to content

Commit

Permalink
solver clocks do connect base partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
vwaurich authored and OpenModelica-Hudson committed Jun 15, 2017
1 parent 4a475ac commit 6a81761
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
7 changes: 6 additions & 1 deletion Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -2760,6 +2760,11 @@ algorithm
(_, outTpl) = Expression.traverseExpTopDown(e, traversingIncidenceRowExpFinderBaseClock, inTpl);
then (inExp, false, outTpl);

case (DAE.CLKCONST(DAE.SOLVER_CLOCK(e)), _)
algorithm
(_, outTpl) := Expression.traverseExpTopDown(e, traversingIncidenceRowExpFinderBaseClock, inTpl);
then (inExp, true, outTpl);

case (DAE.CLKCONST(DAE.BOOLEAN_CLOCK()), _)
then (inExp, false, inTpl);

Expand Down Expand Up @@ -7553,7 +7558,7 @@ protected function allInitOptimizationModules
(BackendDAEOptimize.inlineHomotopy, "inlineHomotopy"),
(BackendDAEOptimize.inlineFunctionInLoops, "forceInlineFunctionInLoops"), // before simplifyComplexFunction
(BackendDAEOptimize.simplifyComplexFunction, "simplifyComplexFunction"),
(CommonSubExpression.wrapFunctionCalls, "wrapFunctionCalls"),
(CommonSubExpression.wrapFunctionCalls, "wrapFunctionCalls"),
(DynamicOptimization.reduceDynamicOptimization, "reduceDynamicOptimization"), // before tearing
(Tearing.tearingSystem, "tearingSystem"),
(BackendDAEOptimize.simplifyLoops, "simplifyLoops"),
Expand Down
49 changes: 44 additions & 5 deletions Compiler/BackEnd/SynchronousFeatures.mo
Expand Up @@ -804,10 +804,12 @@ algorithm
local
MMath.Rational f1,f2;
MMath.Rational s1,s2;
Option<String> solver;
case(BackendDAE.SUBCLOCK(f1,s1,solver),BackendDAE.SUBCLOCK(f2,s2,_))
then BackendDAE.SUBCLOCK(MMath.divRational(f1, f2), MMath.addRational(s1, s2), solver);
case(BackendDAE.SUBCLOCK(f1,s1,solver),BackendDAE.INFERED_SUBCLOCK())
Option<String> solver1,solver2;
case(BackendDAE.SUBCLOCK(f1,s1,solver1),BackendDAE.SUBCLOCK(f2,s2,solver2))
algorithm
solver1 := mergeSolver(solver1,solver2);
then BackendDAE.SUBCLOCK(MMath.divRational(f1, f2), MMath.addRational(s1, s2), solver1);
case(BackendDAE.SUBCLOCK(f1,s1,solver1),BackendDAE.INFERED_SUBCLOCK())
then subSeqClock;
else
algorithm
Expand All @@ -816,6 +818,27 @@ algorithm
end match;
end computeAbsoluteSubClock;

protected function mergeSolver
input Option<String> solver1;
input Option<String> solver2;
output Option<String> sOut;
algorithm
sOut := match(solver1,solver2)
local
String s1,s2;
case(NONE(),SOME(s2))
then SOME(s2);
case(SOME(s1),NONE())
then SOME(s1);
case(SOME(s1),SOME(s2))
algorithm
if not stringEq(s1,s2) then Error.addCompilerNotification("Infered sub clock partitions have different solvers:"+s1+" <->"+s2+".\n"); end if;
then SOME(s1);
else
then NONE();
end match;
end mergeSolver;

protected function addPartAdjacencyEdge
input Integer part1;
input BackendDAE.SubClock sub1;
Expand Down Expand Up @@ -950,6 +973,7 @@ algorithm
local
Integer v1,v2,p1,p2;
Integer factor,counter,resolution;
String solver;
DAE.ComponentRef cref1,cref2;
case(BackendDAE.EQUATION(exp=DAE.CREF(componentRef=cref1), scalar=DAE.CALL(path=Absyn.IDENT("superSample"),expLst={DAE.CREF(componentRef=cref2),DAE.ICONST(factor)})))
algorithm
Expand Down Expand Up @@ -999,6 +1023,16 @@ algorithm
sub1 := setSubClockShift(sub1, MMath.RATIONAL(counter,resolution));
sub2 := setSubClockShift(sub2, MMath.subRational(MMath.RAT0, MMath.RATIONAL(counter, resolution)));
then (p1,v1,p2,v2);
case(BackendDAE.EQUATION(exp=DAE.CREF(componentRef=cref1), scalar=DAE.CLKCONST(clk= DAE.SOLVER_CLOCK(c=DAE.CREF(componentRef=cref2), solverMethod= DAE.SCONST(solver)))))
algorithm
(_,{v1}) := BackendVariable.getVar(cref1,vars);
p1 := varPartMap[v1];
(_,{v2}) := BackendVariable.getVar(cref2,vars);
p2 := varPartMap[v2];
sub1 := setSubClockSolver(sub1, SOME(solver));
sub2 := setSubClockSolver(sub2, SOME(solver));
then (p1,v1,p2,v2);

else
then (-1,-1,-1,-1);
end match;
Expand Down Expand Up @@ -1151,7 +1185,12 @@ algorithm
algorithm
then (eqIdx::clockEqsIn, subClockInterfaceEqIdxsIn,subClockInterfaceEqsIn);

case(BackendDAE.EQUATION(scalar=DAE.CLKCONST(clk=DAE.SOLVER_CLOCK(_))))
//solver clocks can act as subpartitioninterfaces since they assign a solver to another clock
case(BackendDAE.EQUATION(scalar=DAE.CLKCONST(clk=DAE.SOLVER_CLOCK(DAE.CREF(_),_))))
algorithm
then (clockEqsIn, eqIdx::subClockInterfaceEqIdxsIn, eq::subClockInterfaceEqsIn);

case(BackendDAE.EQUATION(scalar=DAE.CLKCONST(clk=DAE.SOLVER_CLOCK(DAE.CLKCONST(_),_))))
algorithm
then (eqIdx::clockEqsIn, subClockInterfaceEqIdxsIn,subClockInterfaceEqsIn);

Expand Down

0 comments on commit 6a81761

Please sign in to comment.