Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
RuedKamp committed Sep 3, 2015
2 parents 5490591 + 20a6b17 commit 19b35e1
Show file tree
Hide file tree
Showing 10 changed files with 406 additions and 383 deletions.
12 changes: 6 additions & 6 deletions Compiler/BackEnd/HpcOmEqSystems.mo
Expand Up @@ -85,7 +85,7 @@ end EqSys;
//-------------------------------------------------//

public function partitionLinearTornSystem"checks the EqSystem for tornSystems in order to dissassemble them into various SingleEquation and a reduced EquationSystem.
This is useful in order to reduce the execution costs of the equationsystem and generate a bunch of parallel singleEquations. use +d=doLienarTearing,partlintornsystem to activate it.
This is useful in order to reduce the execution costs of the equationsystem and generate a bunch of parallel singleEquations. use +d=doLienarTearing +partlintorn=x to activate it.
Remark: this is still under development

idea:
Expand All @@ -105,7 +105,7 @@ algorithm
BackendDAE.Shared shared;
case(BackendDAE.DAE(eqs=eqs,shared=shared))
equation
true = Flags.isSet(Flags.PARTLINTORNSYSTEM);
true = intGt(Flags.getConfigInt(Flags.PARTLINTORN),0);
(eqs,_) = List.map1Fold(eqs,reduceLinearTornSystem,shared,1);
then BackendDAE.DAE(eqs,shared);
else daeIn;
Expand All @@ -114,7 +114,7 @@ end partitionLinearTornSystem;


public function reduceLinearTornSystem "checks the EqSystem for tornSystems in order to dissassemble them into various SingleEquation and a reduced EquationSystem.
This is useful in order to reduce the execution costs of the equationsystem and generate a bunch of parallel singleEquations. use +d=doLienarTearing,partlintornsystem to activate it.
This is useful in order to reduce the execution costs of the equationsystem and generate a bunch of parallel singleEquations. use +d=doLienarTearing +partlintorn=x to activate it.
Remark: this is still under development
author:Waurich TUD 2013-09"
input BackendDAE.EqSystem systIn;
Expand Down Expand Up @@ -196,9 +196,9 @@ algorithm
comp = listGet(compsIn,compIdx);
BackendDAE.TORNSYSTEM(BackendDAE.TEARINGSET(tearingvars = tvarIdcs, residualequations = resEqIdcs, otherEqnVarTpl = otherEqnVarTpl), linear = linear) = comp;
true = linear;
true = intLe(listLength(tvarIdcs),3);
true = intLe(listLength(tvarIdcs),Flags.getConfigInt(Flags.PARTLINTORN));
//print("LINEAR TORN SYSTEM OF SIZE "+intString(listLength(tvarIdcs))+"\n");
false = compHasDummyState(comp,systIn);
//false = compHasDummyState(comp,systIn);
// build the new components, the new variables and the new equations
(varsNew,eqsNew,_,resEqs,matchingNew) = reduceLinearTornSystem2(systIn,sharedIn,tvarIdcs,resEqIdcs,otherEqnVarTpl,tornSysIdxIn);

Expand Down Expand Up @@ -243,7 +243,7 @@ algorithm
true = listLength(compsIn) >= compIdx;
comp = listGet(compsIn,compIdx);
BackendDAE.EQUATIONSYSTEM(vars = varIdcs, eqns = eqIdcs) = comp;
true = intLe(listLength(varIdcs),3);
true = intLe(listLength(varIdcs),2);
//false = compHasDummyState(comp,systIn);

//print("EQUATION SYSTEM OF SIZE "+intString(listLength(varIdcs))+"\n");
Expand Down
23 changes: 23 additions & 0 deletions Compiler/FrontEnd/Lookup.mo
Expand Up @@ -1333,6 +1333,8 @@ algorithm
then ();
end match;
(cache,p_env,attr,ty,bind,cnstForRange,splicedExpData,componentEnv,name) = lookupVarInPackages(cache,env5,cref,prevFrames,inState);
// Add the class name to the spliced exp so that the name is correct.
splicedExpData = prefixSplicedExp(ComponentReference.crefFirstCref(inComponentRef), splicedExpData);
then
(cache,p_env,attr,ty,bind,cnstForRange,splicedExpData,componentEnv,name);

Expand Down Expand Up @@ -3197,5 +3199,26 @@ algorithm
end matchcontinue;
end isFunctionCallViaComponent;

protected function prefixSplicedExp
"Prefixes a spliced exp that contains a cref with another cref."
input DAE.ComponentRef inCref;
input InstTypes.SplicedExpData inSplicedExp;
output InstTypes.SplicedExpData outSplicedExp;
algorithm
outSplicedExp := match inSplicedExp
local
DAE.Type ety, ty;
DAE.ComponentRef cref;

case InstTypes.SPLICEDEXPDATA(SOME(DAE.CREF(cref, ety)), ty)
algorithm
cref := ComponentReference.joinCrefs(inCref, cref);
then
InstTypes.SPLICEDEXPDATA(SOME(DAE.CREF(cref, ety)), ty);

else inSplicedExp;
end match;
end prefixSplicedExp;

annotation(__OpenModelica_Interface="frontend");
end Lookup;
443 changes: 137 additions & 306 deletions Compiler/FrontEnd/Static.mo

Large diffs are not rendered by default.

19 changes: 17 additions & 2 deletions Compiler/Lexers/LexerModelicaDiff.mo
Expand Up @@ -1368,6 +1368,17 @@ algorithm
end match;
end modelicaDiffTokenEq;

function modelicaDiffTokenWhitespace
import LexerModelicaDiff.{Token,TokenId,tokenContent};
input Token t;
output Boolean b;
protected
LexerModelicaDiff.TokenId id;
algorithm
LexerModelicaDiff.TOKEN(id=id) := t;
b := id==TokenId.BLOCK_COMMENT or id==TokenId.LINE_COMMENT or id==TokenId.WHITESPACE or id==TokenId.NEWLINE;
end modelicaDiffTokenWhitespace;

function filterModelicaDiff
import LexerModelicaDiff.{Token,TokenId,tokenContent,TOKEN};
import DiffAlgorithm.Diff;
Expand Down Expand Up @@ -1428,8 +1439,12 @@ algorithm
while not listEmpty(simpleDiff) loop
(lastIsNewline,simpleDiff,tmp) := match simpleDiff
local
tuple<Diff, Token> e;
Token t;
tuple<Diff, Token> e,e1,e2;
Token t,t1,t2;
// Do not delete whitespace in-between two tokens
case (e1 as (Diff.Equal,_))::(Diff.Delete,t1 as TOKEN(id=TokenId.NEWLINE))::(Diff.Delete,t2 as TOKEN(id=TokenId.WHITESPACE))::(e2 as (Diff.Equal,_))::rest then (false,e1::(Diff.Equal,t1)::(Diff.Equal,t2)::e2::rest,tmp);
case (e1 as (Diff.Equal,_))::(Diff.Delete,t as TOKEN(id=TokenId.WHITESPACE))::(e2 as (Diff.Equal,_))::rest then (false,e1::(Diff.Equal,t)::e2::rest,tmp);

case (Diff.Add,TOKEN(id=TokenId.NEWLINE))::(Diff.Add,TOKEN(id=TokenId.WHITESPACE))::(rest as (_,TOKEN(id=TokenId.NEWLINE))::_)
then (false,rest,tmp);
case (Diff.Add,TOKEN(id=TokenId.NEWLINE))::(rest as (_,TOKEN(id=TokenId.NEWLINE))::_)
Expand Down
6 changes: 4 additions & 2 deletions Compiler/Lexers/Makefile.in
@@ -1,4 +1,4 @@
.PHONY: nothing OMCC
.PHONY: nothing OMCC flex

nothing:

Expand All @@ -11,6 +11,8 @@ OMCC/OMCC:
test -e OMCC/.git || git clone https://github.com/OpenModelica/OpenModelica-OMCC OMCC
cd OMCC && git fetch && git pull --ff-only
$(MAKE) -C OMCC omcc OMC="@OMBUILDDIR@/bin/omc"

flex:
$(MAKE) -C ../../3rdParty/flex-2.5.35
cp ../../3rdParty/flex-2.5.35/flex "@OMBUILDDIR@/bin/flex"
Makefile: Makefile.in
cd @top_builddir@ && ./config.status
19 changes: 17 additions & 2 deletions Compiler/Lexers/lexerModelicaDiff.l
Expand Up @@ -202,6 +202,17 @@ algorithm
end match;
end modelicaDiffTokenEq;

function modelicaDiffTokenWhitespace
import LexerModelicaDiff.{Token,TokenId,tokenContent};
input Token t;
output Boolean b;
protected
LexerModelicaDiff.TokenId id;
algorithm
LexerModelicaDiff.TOKEN(id=id) := t;
b := id==TokenId.BLOCK_COMMENT or id==TokenId.LINE_COMMENT or id==TokenId.WHITESPACE or id==TokenId.NEWLINE;
end modelicaDiffTokenWhitespace;

function filterModelicaDiff
import LexerModelicaDiff.{Token,TokenId,tokenContent,TOKEN};
import DiffAlgorithm.Diff;
Expand Down Expand Up @@ -262,8 +273,12 @@ algorithm
while not listEmpty(simpleDiff) loop
(lastIsNewline,simpleDiff,tmp) := match simpleDiff
local
tuple<Diff, Token> e;
Token t;
tuple<Diff, Token> e,e1,e2;
Token t,t1,t2;
// Do not delete whitespace in-between two tokens
case (e1 as (Diff.Equal,_))::(Diff.Delete,t1 as TOKEN(id=TokenId.NEWLINE))::(Diff.Delete,t2 as TOKEN(id=TokenId.WHITESPACE))::(e2 as (Diff.Equal,_))::rest then (false,e1::(Diff.Equal,t1)::(Diff.Equal,t2)::e2::rest,tmp);
case (e1 as (Diff.Equal,_))::(Diff.Delete,t as TOKEN(id=TokenId.WHITESPACE))::(e2 as (Diff.Equal,_))::rest then (false,e1::(Diff.Equal,t)::e2::rest,tmp);

case (Diff.Add,TOKEN(id=TokenId.NEWLINE))::(Diff.Add,TOKEN(id=TokenId.WHITESPACE))::(rest as (_,TOKEN(id=TokenId.NEWLINE))::_)
then (false,rest,tmp);
case (Diff.Add,TOKEN(id=TokenId.NEWLINE))::(rest as (_,TOKEN(id=TokenId.NEWLINE))::_)
Expand Down
12 changes: 7 additions & 5 deletions Compiler/Script/CevalScriptBackend.mo
Expand Up @@ -659,7 +659,7 @@ public function cevalInteractiveFunctions3
output Values.Value outValue;
output GlobalScript.SymbolTable outInteractiveSymbolTable;
protected
import LexerModelicaDiff.{Token,TokenId,tokenContent,scanString,filterModelicaDiff,modelicaDiffTokenEq};
import LexerModelicaDiff.{Token,TokenId,tokenContent,scanString,filterModelicaDiff,modelicaDiffTokenEq,modelicaDiffTokenWhitespace};
import DiffAlgorithm.{Diff,diff,printActual,printDiffTerminalColor,printDiffXml};
algorithm
(outCache,outValue,outInteractiveSymbolTable) := matchcontinue (inCache,inEnv,inFunctionName,inVals,inSt,msg)
Expand Down Expand Up @@ -829,14 +829,14 @@ algorithm
algorithm
tokens1 := scanString(s1);
tokens2 := scanString(s2);
diffs := diff(tokens1, tokens2, modelicaDiffTokenEq);
diffs := diff(tokens1, tokens2, modelicaDiffTokenEq, modelicaDiffTokenWhitespace, tokenContent);
// print("Before filtering:\n"+printDiffTerminalColor(diffs, tokenContent)+"\n");
diffs := filterModelicaDiff(diffs,removeWhitespace=false);
// Scan a second time, with comments filtered into place
str := printActual(diffs, tokenContent);
// print("Intermediate string:\n"+printDiffTerminalColor(diffs, tokenContent)+"\n");
tokens2 := scanString(str);
diffs := diff(tokens1, tokens2, modelicaDiffTokenEq);
diffs := diff(tokens1, tokens2, modelicaDiffTokenEq, modelicaDiffTokenWhitespace, tokenContent);
// print("Before filtering (2):\n"+printDiffTerminalColor(diffs, tokenContent)+"\n");
diffs := filterModelicaDiff(diffs);
str := match Absyn.pathLastIdent(path)
Expand Down Expand Up @@ -2168,8 +2168,6 @@ algorithm
},
st,_)
equation
// get the variables
str = ValuesUtil.printCodeVariableName(cvar) + "\" \"" + ValuesUtil.printCodeVariableName(cvar2);
// get OPENMODELICAHOME
omhome = Settings.getInstallationDirectoryPath();
// get the simulation filename
Expand All @@ -2182,13 +2180,17 @@ algorithm
// check if plot callback is defined
b = System.plotCallBackDefined();
if boolOr(forceOMPlot, boolNot(b)) then
// get the variables
str = ValuesUtil.printCodeVariableName(cvar) + "\" \"" + ValuesUtil.printCodeVariableName(cvar2);
// create the path till OMPlot
str2 = stringAppendList({omhome,pd,"bin",pd,"OMPlot",s1});
// create the list of arguments for OMPlot
str3 = "--filename=\"" + filename + "\" --title=\"" + title + "\" --grid=" + gridStr + " --plotParametric --logx=" + boolString(logX) + " --logy=" + boolString(logY) + " --xlabel=\"" + xLabel + "\" --ylabel=\"" + yLabel + "\" --xrange=" + realString(x1) + ":" + realString(x2) + " --yrange=" + realString(y1) + ":" + realString(y2) + " --new-window=" + boolString(externalWindow) + " --curve-width=" + realString(curveWidth) + " --curve-style=" + intString(curveStyle) + " --legend-position=\"" + legendPosition + "\" --footer=\"" + footer + "\" --auto-scale=" + boolString(autoScale) + " \"" + str + "\"";
call = stringAppendList({"\"",str2,"\""," ",str3});
0 = System.spawnCall(str2, call);
elseif b then
// get the variables
str = ValuesUtil.printCodeVariableName(cvar) + " " + ValuesUtil.printCodeVariableName(cvar2);
logXStr = boolString(logX);
logYStr = boolString(logY);
x1Str = realString(x1);
Expand Down

0 comments on commit 19b35e1

Please sign in to comment.