Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 6a81761

Browse files
vwaurichOpenModelica-Hudson
authored andcommitted
solver clocks do connect base partitions
1 parent 4a475ac commit 6a81761

File tree

2 files changed

+50
-6
lines changed

2 files changed

+50
-6
lines changed

Compiler/BackEnd/BackendDAEUtil.mo

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2760,6 +2760,11 @@ algorithm
27602760
(_, outTpl) = Expression.traverseExpTopDown(e, traversingIncidenceRowExpFinderBaseClock, inTpl);
27612761
then (inExp, false, outTpl);
27622762

2763+
case (DAE.CLKCONST(DAE.SOLVER_CLOCK(e)), _)
2764+
algorithm
2765+
(_, outTpl) := Expression.traverseExpTopDown(e, traversingIncidenceRowExpFinderBaseClock, inTpl);
2766+
then (inExp, true, outTpl);
2767+
27632768
case (DAE.CLKCONST(DAE.BOOLEAN_CLOCK()), _)
27642769
then (inExp, false, inTpl);
27652770

@@ -7553,7 +7558,7 @@ protected function allInitOptimizationModules
75537558
(BackendDAEOptimize.inlineHomotopy, "inlineHomotopy"),
75547559
(BackendDAEOptimize.inlineFunctionInLoops, "forceInlineFunctionInLoops"), // before simplifyComplexFunction
75557560
(BackendDAEOptimize.simplifyComplexFunction, "simplifyComplexFunction"),
7556-
(CommonSubExpression.wrapFunctionCalls, "wrapFunctionCalls"),
7561+
(CommonSubExpression.wrapFunctionCalls, "wrapFunctionCalls"),
75577562
(DynamicOptimization.reduceDynamicOptimization, "reduceDynamicOptimization"), // before tearing
75587563
(Tearing.tearingSystem, "tearingSystem"),
75597564
(BackendDAEOptimize.simplifyLoops, "simplifyLoops"),

Compiler/BackEnd/SynchronousFeatures.mo

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,12 @@ algorithm
804804
local
805805
MMath.Rational f1,f2;
806806
MMath.Rational s1,s2;
807-
Option<String> solver;
808-
case(BackendDAE.SUBCLOCK(f1,s1,solver),BackendDAE.SUBCLOCK(f2,s2,_))
809-
then BackendDAE.SUBCLOCK(MMath.divRational(f1, f2), MMath.addRational(s1, s2), solver);
810-
case(BackendDAE.SUBCLOCK(f1,s1,solver),BackendDAE.INFERED_SUBCLOCK())
807+
Option<String> solver1,solver2;
808+
case(BackendDAE.SUBCLOCK(f1,s1,solver1),BackendDAE.SUBCLOCK(f2,s2,solver2))
809+
algorithm
810+
solver1 := mergeSolver(solver1,solver2);
811+
then BackendDAE.SUBCLOCK(MMath.divRational(f1, f2), MMath.addRational(s1, s2), solver1);
812+
case(BackendDAE.SUBCLOCK(f1,s1,solver1),BackendDAE.INFERED_SUBCLOCK())
811813
then subSeqClock;
812814
else
813815
algorithm
@@ -816,6 +818,27 @@ algorithm
816818
end match;
817819
end computeAbsoluteSubClock;
818820

821+
protected function mergeSolver
822+
input Option<String> solver1;
823+
input Option<String> solver2;
824+
output Option<String> sOut;
825+
algorithm
826+
sOut := match(solver1,solver2)
827+
local
828+
String s1,s2;
829+
case(NONE(),SOME(s2))
830+
then SOME(s2);
831+
case(SOME(s1),NONE())
832+
then SOME(s1);
833+
case(SOME(s1),SOME(s2))
834+
algorithm
835+
if not stringEq(s1,s2) then Error.addCompilerNotification("Infered sub clock partitions have different solvers:"+s1+" <->"+s2+".\n"); end if;
836+
then SOME(s1);
837+
else
838+
then NONE();
839+
end match;
840+
end mergeSolver;
841+
819842
protected function addPartAdjacencyEdge
820843
input Integer part1;
821844
input BackendDAE.SubClock sub1;
@@ -950,6 +973,7 @@ algorithm
950973
local
951974
Integer v1,v2,p1,p2;
952975
Integer factor,counter,resolution;
976+
String solver;
953977
DAE.ComponentRef cref1,cref2;
954978
case(BackendDAE.EQUATION(exp=DAE.CREF(componentRef=cref1), scalar=DAE.CALL(path=Absyn.IDENT("superSample"),expLst={DAE.CREF(componentRef=cref2),DAE.ICONST(factor)})))
955979
algorithm
@@ -999,6 +1023,16 @@ algorithm
9991023
sub1 := setSubClockShift(sub1, MMath.RATIONAL(counter,resolution));
10001024
sub2 := setSubClockShift(sub2, MMath.subRational(MMath.RAT0, MMath.RATIONAL(counter, resolution)));
10011025
then (p1,v1,p2,v2);
1026+
case(BackendDAE.EQUATION(exp=DAE.CREF(componentRef=cref1), scalar=DAE.CLKCONST(clk= DAE.SOLVER_CLOCK(c=DAE.CREF(componentRef=cref2), solverMethod= DAE.SCONST(solver)))))
1027+
algorithm
1028+
(_,{v1}) := BackendVariable.getVar(cref1,vars);
1029+
p1 := varPartMap[v1];
1030+
(_,{v2}) := BackendVariable.getVar(cref2,vars);
1031+
p2 := varPartMap[v2];
1032+
sub1 := setSubClockSolver(sub1, SOME(solver));
1033+
sub2 := setSubClockSolver(sub2, SOME(solver));
1034+
then (p1,v1,p2,v2);
1035+
10021036
else
10031037
then (-1,-1,-1,-1);
10041038
end match;
@@ -1151,7 +1185,12 @@ algorithm
11511185
algorithm
11521186
then (eqIdx::clockEqsIn, subClockInterfaceEqIdxsIn,subClockInterfaceEqsIn);
11531187

1154-
case(BackendDAE.EQUATION(scalar=DAE.CLKCONST(clk=DAE.SOLVER_CLOCK(_))))
1188+
//solver clocks can act as subpartitioninterfaces since they assign a solver to another clock
1189+
case(BackendDAE.EQUATION(scalar=DAE.CLKCONST(clk=DAE.SOLVER_CLOCK(DAE.CREF(_),_))))
1190+
algorithm
1191+
then (clockEqsIn, eqIdx::subClockInterfaceEqIdxsIn, eq::subClockInterfaceEqsIn);
1192+
1193+
case(BackendDAE.EQUATION(scalar=DAE.CLKCONST(clk=DAE.SOLVER_CLOCK(DAE.CLKCONST(_),_))))
11551194
algorithm
11561195
then (eqIdx::clockEqsIn, subClockInterfaceEqIdxsIn,subClockInterfaceEqsIn);
11571196

0 commit comments

Comments
 (0)