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

Commit

Permalink
some small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
hkiel authored and OpenModelica-Hudson committed Jun 28, 2017
1 parent dc91086 commit 0ecd8be
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
8 changes: 4 additions & 4 deletions Compiler/BackEnd/BackendDAECreate.mo
Original file line number Diff line number Diff line change
Expand Up @@ -595,20 +595,20 @@ algorithm
DAE.CallAttributes attr;

// delay [already in ht]
case (DAE.CALL(Absyn.IDENT("delay"), es, attr), (ht, iDelay, iSample, timeEvents)) equation
case (DAE.CALL(Absyn.IDENT("delay"), es, attr), (ht, _, _, _)) equation
i = BaseHashTable.get(inExp, ht);
then (DAE.CALL(Absyn.IDENT("delay"), DAE.ICONST(i)::es, attr), (ht, iDelay, iSample, timeEvents));
then (DAE.CALL(Absyn.IDENT("delay"), DAE.ICONST(i)::es, attr), inTuple);

// delay [not yet in ht]
case (DAE.CALL(Absyn.IDENT("delay"), es, attr), (ht, iDelay, iSample, timeEvents)) equation
ht = BaseHashTable.add((inExp, iDelay+1), ht);
then (DAE.CALL(Absyn.IDENT("delay"), DAE.ICONST(iDelay)::es, attr), (ht, iDelay+1, iSample, timeEvents));

// sample [already in ht]
case (DAE.CALL(Absyn.IDENT("sample"), es as {_, interval}, attr), (ht, iDelay, iSample, timeEvents))
case (DAE.CALL(Absyn.IDENT("sample"), es as {_, interval}, attr), (ht, _, _, _))
guard (not Types.isClockOrSubTypeClock(Expression.typeof(interval))) equation
i = BaseHashTable.get(inExp, ht);
then (DAE.CALL(Absyn.IDENT("sample"), DAE.ICONST(i)::es, attr), (ht, iDelay, iSample, timeEvents));
then (DAE.CALL(Absyn.IDENT("sample"), DAE.ICONST(i)::es, attr), inTuple);

// sample [not yet in ht]
case (DAE.CALL(Absyn.IDENT("sample"), es as {start, interval}, attr), (ht, iDelay, iSample, timeEvents))
Expand Down
23 changes: 10 additions & 13 deletions Compiler/BackEnd/BackendDAEUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3789,7 +3789,7 @@ public function getAdjacencyMatrixEnhancedScalar
output array<list<Integer>> outMapEqnIncRow;
output array<Integer> outMapIncRowEqn;
protected
list<list<tuple<Integer,list<Integer>>>> varsSolvedInWhenEqnsTupleList;
list<tuple<Integer,list<Integer>>> varsSolvedInWhenEqnsTupleList;
algorithm
(outIncidenceMatrix,outIncidenceMatrixT,outMapEqnIncRow,outMapIncRowEqn) :=
matchcontinue (syst, shared)
Expand Down Expand Up @@ -3823,7 +3823,7 @@ algorithm
fail();
end matchcontinue;

makeWhenEqnVarsUnsolvable(outIncidenceMatrix,outIncidenceMatrixT,List.flatten(varsSolvedInWhenEqnsTupleList));
makeWhenEqnVarsUnsolvable(outIncidenceMatrix,outIncidenceMatrixT,varsSolvedInWhenEqnsTupleList);
end getAdjacencyMatrixEnhancedScalar;


Expand Down Expand Up @@ -3895,7 +3895,7 @@ protected function adjacencyMatrixDispatchEnhancedScalar
input Boolean trytosolve;
output array<list<Integer>> omapEqnIncRow;
output array<Integer> omapIncRowEqn;
output list<list<tuple<Integer,list<Integer>>>> varsSolvedInWhenEqnsTupleListOut = {};
output list<tuple<Integer,list<Integer>>> varsSolvedInWhenEqnsTupleListOut = {};
protected
list<BackendDAE.AdjacencyMatrixElementEnhanced> inIncidenceArray = {};
list<list<Integer>> mapEqnIncRow = {};
Expand All @@ -3917,7 +3917,7 @@ algorithm
// put it in the arrays
inIncidenceArray := List.consN(size,row,inIncidenceArray);
incidenceArrayT := fillincAdjacencyMatrixTEnhanced(row,rowindxs,incidenceArrayT);
varsSolvedInWhenEqnsTupleListOut := varsSolvedInWhenEqnsTuple :: varsSolvedInWhenEqnsTupleListOut;
varsSolvedInWhenEqnsTupleListOut := listAppend(varsSolvedInWhenEqnsTuple, varsSolvedInWhenEqnsTupleListOut);
mapEqnIncRow := rowindxs::mapEqnIncRow;
end for;
outIncidenceArray := List.listArrayReverse(inIncidenceArray);
Expand Down Expand Up @@ -4041,9 +4041,9 @@ algorithm
equation
row = inIncidenceArrayT[v];
newrow = List.map2(eqnsindxs,Util.make3Tuple,solva,cons);
newrow = listAppend(newrow,row);
row = listAppend(newrow,row);
// put it in the array
mT = arrayUpdate(inIncidenceArrayT, v, newrow);
mT = arrayUpdate(inIncidenceArrayT, v, row);
then
fillincAdjacencyMatrixTEnhanced(rest, eqnsindxs, mT);

Expand All @@ -4054,8 +4054,8 @@ algorithm
eqnsindxs1 = List.map(eqnsindxs,intNeg);
newrow = List.map2(eqnsindxs1,Util.make3Tuple,solva,cons);
// put it in the array
newrow = listAppend(newrow,row);
mT = arrayUpdate(inIncidenceArrayT, vabs, newrow);
row = listAppend(newrow,row);
mT = arrayUpdate(inIncidenceArrayT, vabs, row);
then
fillincAdjacencyMatrixTEnhanced(rest, eqnsindxs, mT);

Expand Down Expand Up @@ -4339,7 +4339,7 @@ protected function adjacencyRowAlgorithmInputs1
input BackendDAE.AdjacencyMatrixElementEnhanced iRow;
output BackendDAE.AdjacencyMatrixElementEnhanced outRow;
algorithm
outRow := matchcontinue(vindx,mark,rowmark,iRow)
outRow := match(vindx,mark,rowmark,iRow)
local
Integer i;
list<Integer> rest;
Expand All @@ -4353,12 +4353,9 @@ algorithm
then
adjacencyRowAlgorithmInputs1(rest,mark,rowmark,(i,BackendDAE.SOLVABILITY_UNSOLVABLE(),{})::iRow);
case (i::rest,_,_,_)
guard
// already handled
intEq(intAbs(rowmark[i]),mark)
then
adjacencyRowAlgorithmInputs1(rest,mark,rowmark,iRow);
end matchcontinue;
end match;
end adjacencyRowAlgorithmInputs1;

protected function adjacencyRowWhenEnhanced
Expand Down
8 changes: 4 additions & 4 deletions Compiler/BackEnd/EvaluateFunctions.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2671,6 +2671,7 @@ algorithm
DAE.FunctionTree funcs;
list<BackendDAE.Equation> addEqs;
list<DAE.Statement> stmts,stmtsIn;
tuple<DAE.Exp, DAE.FunctionTree,Integer,list<DAE.Statement>> tpl;
case (DAE.CALL(),(lhs,funcs,idx,stmtsIn))
equation
((rhs,lhs,addEqs,funcs,idx,_,_)) = evaluateConstantFunction(inExp,lhs,funcs,idx,{});
Expand All @@ -2680,11 +2681,10 @@ algorithm

case (DAE.UNBOX(exp=rhs),_)
equation
(rhs,_,(lhs,funcs,idx,stmts)) = evaluateConstantFunctionWrapper(rhs,inTpl);
then (rhs,true,(lhs,funcs,idx,stmts));
(rhs,_,tpl) = evaluateConstantFunctionWrapper(rhs,inTpl);
then (rhs,true,tpl);

case (rhs,(_,_,_,_))
then (rhs,false,inTpl);
else (inExp,false,inTpl);
end matchcontinue;
end evaluateConstantFunctionWrapper;

Expand Down

0 comments on commit 0ecd8be

Please sign in to comment.