Changeset 13856


Ignore:
Timestamp:
Oct 25, 2019 12:57:54 PM (4 weeks ago)
Author:
Jonathan Kämpe
Message:

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

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/CHANGELOG.txt

    r13846 r13856  
    11================= Unreleased ==================
     2# Fixed ; Minor ; Compiler; #5864
     3Fixed bug where partial variability propagation lead to unbalanced equation systems.
     4
    25# Fixed ; Minor ; Compiler ; #5862
    36Fixed bug where empty array subscripts added during scalarization lead to c-compilation error.
  • trunk/Compiler/ModelicaMiddleEnd/src/jastadd/optimizations/VariabilityPropagation.jrag

    r12119 r13856  
    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    /**
  • trunk/Compiler/ModelicaMiddleEnd/test/modelica/VariabilityPropagationPartialTests.mo

    r12716 r13856  
    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(1,time) else f(time,1);
     1030
     1031    annotation(__JModelica(UnitTesting(tests={
     1032        TransformCanonicalTestCase(
     1033            name="PartiallyKnownTempAssign1",
     1034            description="Partial evaluation of if equation assigning temporaries",
     1035            flatModel="
     1036fclass VariabilityPropagationPartialTests.PartiallyKnownTempAssign1
     1037 Real r.x1;
     1038 Real r.x2;
     1039 Real temp_1.x1;
     1040 Real temp_1.x2;
     1041 Real temp_2.x1;
     1042 Real temp_2.x2;
     1043equation
     1044 if time > 1 then
     1045  (VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.R(temp_1.x1, temp_1.x2)) = VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.f(1, time);
     1046 else
     1047  temp_1.x1 = 0.0;
     1048  temp_1.x2 = 0.0;
     1049 end if;
     1050 if not time > 1 then
     1051  (VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.R(temp_2.x1, temp_2.x2)) = VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.f(time, 1);
     1052 else
     1053  temp_2.x1 = 0.0;
     1054  temp_2.x2 = 0.0;
     1055 end if;
     1056 r.x1 = if time > 1 then temp_1.x1 else temp_2.x1;
     1057 r.x2 = if time > 1 then temp_1.x2 else temp_2.x2;
     1058
     1059public
     1060 function VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.f
     1061  input Real x1;
     1062  input Real x2;
     1063  output VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.R r;
     1064 algorithm
     1065  r.x1 := x1;
     1066  r.x2 := x2;
     1067  return;
     1068 annotation(Inline = false);
     1069 end VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.f;
     1070
     1071 record VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.R
     1072  Real x1;
     1073  Real x2;
     1074 end VariabilityPropagationPartialTests.PartiallyKnownTempAssign1.R;
     1075
     1076end VariabilityPropagationPartialTests.PartiallyKnownTempAssign1;
     1077")})));
     1078    end PartiallyKnownTempAssign1;
     1079
    10151080
    10161081end VariabilityPropagationPartialTests;
Note: See TracChangeset for help on using the changeset viewer.