Changeset 13837


Ignore:
Timestamp:
Oct 24, 2019 12:41:16 PM (3 weeks ago)
Author:
Jonathan Kämpe
Message:

#5864 Disabled partial variability propagation for equations in temp assignments.

Location:
branches/dev-jk-2619/Compiler/ModelicaMiddleEnd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-jk-2619/Compiler/ModelicaMiddleEnd/src/jastadd/optimizations/VariabilityPropagation.jrag

    r12119 r13837  
    2222     */
    2323    syn boolean FAbstractEquation.canPropagate(FClass.VariabilityPropagator propagator) =
    24             canPropagateContext(propagator) && !containsActiveAnnotations();
     24            canPropagateContext(propagator, false) && !containsActiveAnnotations();
    2525    eq FEquation.canPropagate(FClass.VariabilityPropagator propagator) =
    2626            super.canPropagate(propagator) && propagator.canPropagate(this);
     
    2929        return super.canPropagate(propagator) && propagator.variables(this).size() > 0 && numScalarEquations() > 0 &&
    3030                ((propagator.variables(this).size() == numScalarEquations() && getCall().variability().parameterOrLess())
    31                         || potentialPartialVariability().knownParameterOrLess());
     31                        || (potentialPartialVariability().knownParameterOrLess() && canPropagateContext(propagator, true)));
    3232    }
    3333    eq FAlgorithm.canPropagate(FClass.VariabilityPropagator propagator) =
     
    3636            propagator.variables(this).size() == numScalarEquations() && variabilityRHS().parameterOrLess();
    3737
    38     inh boolean FAbstractEquation   .canPropagateContext(FClass.VariabilityPropagator propagator);
    39     eq Root  .getChild()            .canPropagateContext(FClass.VariabilityPropagator propagator) = false;
    40     eq FClass.getFAbstractEquation().canPropagateContext(FClass.VariabilityPropagator propagator) = true;
    41     eq FClass.getFInitialEquation() .canPropagateContext(FClass.VariabilityPropagator propagator) =
     38    inh boolean FAbstractEquation   .canPropagateContext(FClass.VariabilityPropagator propagator, boolean partial);
     39    eq Root  .getChild()            .canPropagateContext(FClass.VariabilityPropagator propagator, boolean partial) = false;
     40    eq FClass.getFAbstractEquation().canPropagateContext(FClass.VariabilityPropagator propagator, boolean partial) = true;
     41    eq FClass.getFInitialEquation() .canPropagateContext(FClass.VariabilityPropagator propagator, boolean partial) =
    4242            propagator.propagateInitial();
    43     eq FIfWhenElseEquation.getChild().canPropagateContext(FClass.VariabilityPropagator propagator) =
    44             isTempAssign() && canPropagateContext(propagator);
     43    eq FIfWhenElseEquation.getChild().canPropagateContext(FClass.VariabilityPropagator propagator, boolean partial) =
     44            isTempAssign() && !partial && canPropagateContext(propagator, partial);
    4545
    4646    /**
  • branches/dev-jk-2619/Compiler/ModelicaMiddleEnd/test/modelica/VariabilityPropagationPartialTests.mo

    r12716 r13837  
    10131013    end PartiallyKnownDiscrete1;
    10141014
     1015    model PartiallyKnownTempAssign1
     1016        record R
     1017            Real x1;
     1018            Real x2;
     1019        end R;
     1020        function f
     1021            input Real x1;
     1022            input Real x2;
     1023            output R r = R(x1,x2);
     1024        algorithm
     1025            annotation(Inline=false);
     1026        end f;
     1027       
     1028       
     1029        R r = if time > 1 then f(c,time) else f(time,c);
     1030        Real c = 1;
     1031
     1032    annotation(__JModelica(UnitTesting(tests={
     1033        TransformCanonicalTestCase(
     1034            name="PartiallyKnownTempAssign1",
     1035            description="Partial evaluation of if equation assigning temporaries",
     1036            flatModel="
     1037fclass VariabilityPropagationPartialTests.PartiallyKnownTempAssign1
     1038 Real r.x1;
     1039 Real r.x2;
     1040 constant Real c = 1;
     1041 Real temp_1.x1;
     1042 Real temp_1.x2;
     1043 Real temp_2.x1;
     1044 Real temp_2.x2;
     1045equation
     1046 if time > 1 then
     1047  (VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.R(temp_1.x1, temp_1.x2)) = VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.f(1.0, time);
     1048 else
     1049  temp_1.x1 = 0.0;
     1050  temp_1.x2 = 0.0;
     1051 end if;
     1052 if not time > 1 then
     1053  (VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.R(temp_2.x1, temp_2.x2)) = VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.f(time, 1.0);
     1054 else
     1055  temp_2.x1 = 0.0;
     1056  temp_2.x2 = 0.0;
     1057 end if;
     1058 r.x1 = if time > 1 then temp_1.x1 else temp_2.x1;
     1059 r.x2 = if time > 1 then temp_1.x2 else temp_2.x2;
     1060
     1061public
     1062 function VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.f
     1063  input Real x1;
     1064  input Real x2;
     1065  output VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.R r;
     1066 algorithm
     1067  r.x1 := x1;
     1068  r.x2 := x2;
     1069  return;
     1070 annotation(Inline = false);
     1071 end VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.f;
     1072
     1073 record VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.R
     1074  Real x1;
     1075  Real x2;
     1076 end VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.R;
     1077
     1078end VariabilityPropagationPartialTests.PartiallyKnownTempAssign1;
     1079")})));
     1080    end PartiallyKnownTempAssign1;
     1081
    10151082
    10161083end VariabilityPropagationPartialTests;
Note: See TracChangeset for help on using the changeset viewer.