Skip to content

Commit

Permalink
- Propagated cache+env to BackendDAEUtil
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7834 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Feb 1, 2011
1 parent d44c008 commit 9dbc91d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
21 changes: 14 additions & 7 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -49,6 +49,7 @@ encapsulated package BackendDAEUtil

public import BackendDAE;
public import DAE;
public import Env;

protected import Absyn;
protected import BackendDump;
Expand All @@ -62,7 +63,6 @@ protected import DAEUtil;
protected import Derive;
protected import Debug;
protected import Error;
protected import Env;
protected import Expression;
protected import ExpressionSimplify;
protected import ExpressionDump;
Expand Down Expand Up @@ -928,10 +928,12 @@ end calculateVarSizes;
public function calculateValues "function: calculateValues
author: PA
This function calculates the values from the parameter binding expressions."
input Env.Cache cache;
input Env.Env env;
input BackendDAE.BackendDAE inBackendDAE;
output BackendDAE.BackendDAE outBackendDAE;
algorithm
outBackendDAE := match (inBackendDAE)
outBackendDAE := match (cache,env,inBackendDAE)
local
list<BackendDAE.Var> knvarlst;
BackendDAE.Variables knvars,vars,extVars;
Expand All @@ -941,11 +943,11 @@ algorithm
array<DAE.Algorithm> al;
BackendDAE.EventInfo wc;
BackendDAE.ExternalObjectClasses extObjCls;
case (BackendDAE.DAE(orderedVars = vars,knownVars = knvars,externalObjects=extVars,aliasVars = av,orderedEqs = eqns,
case (cache,env,BackendDAE.DAE(orderedVars = vars,knownVars = knvars,externalObjects=extVars,aliasVars = av,orderedEqs = eqns,
removedEqs = seqns,initialEqs = ie,arrayEqs = ae,algorithms = al,eventInfo = wc,extObjClasses=extObjCls))
equation
knvarlst = varList(knvars);
knvarlst = Util.listMap1(knvarlst, calculateValue, knvars);
knvarlst = Util.listMap3(knvarlst, calculateValue, cache, env, knvars);
knvars = listVar(knvarlst);
then
BackendDAE.DAE(vars,knvars,extVars,av,eqns,seqns,ie,ae,al,wc,extObjCls);
Expand All @@ -954,10 +956,12 @@ end calculateValues;

protected function calculateValue
input BackendDAE.Var inVar;
input Env.Cache cache;
input Env.Env env;
input BackendDAE.Variables vars;
output BackendDAE.Var outVar;
algorithm
outVar := matchcontinue(inVar, vars)
outVar := matchcontinue(inVar, cache, env, vars)
local
DAE.ComponentRef cr;
BackendDAE.VarKind vk;
Expand All @@ -974,13 +978,16 @@ algorithm
Values.Value v;
case (BackendDAE.VAR(varName = cr, varKind = vk, varDirection = vd, varType = ty,
bindExp = SOME(e), arryDim = dims, index = idx, source = src,
values = va, comment = c, flowPrefix = fp, streamPrefix = sp), _)
values = va, comment = c, flowPrefix = fp, streamPrefix = sp), cache, env, _)
equation
((e2, _)) = Expression.traverseExp(e, replaceCrefsWithValues, vars);
// Is this supposed to be Ceval with the cache+env
// (_, v, _) = Ceval.ceval(cache, env, e2, false,NONE(), NONE(), Ceval.MSG());
// Or should the error messages be disabled, i.e. Ceval.NO_MSG()
(_, v, _) = Ceval.ceval(Env.emptyCache(), Env.emptyEnv, e2, false,NONE(), NONE(), Ceval.MSG());
then
BackendDAE.VAR(cr, vk, vd, ty, SOME(e), SOME(v), dims, idx, src, va, c, fp, sp);
case (_, _) then inVar;
else inVar;
end matchcontinue;
end calculateValue;

Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackEnd/SimCode.mo
Expand Up @@ -935,7 +935,7 @@ algorithm
dlow_1 = Inline.inlineCalls(SOME(funcs),{DAE.NORM_INLINE(),DAE.AFTER_INDEX_RED_INLINE()},dlow_1);
(comps) = BackendDAETransform.strongComponents(m, mT, ass1, ass2);
indexed_dlow = BackendDAEUtil.translateDae(dlow_1,NONE());
indexed_dlow_1 = BackendDAEUtil.calculateValues(indexed_dlow);
indexed_dlow_1 = BackendDAEUtil.calculateValues(cache,env,indexed_dlow);
Debug.fprint("bltdump", "indexed DAE:\n");
Debug.fcall("bltdump", BackendDump.dumpIncidenceMatrix, m);
Debug.fcall("bltdump", BackendDump.dumpIncidenceMatrixT, mT);
Expand Down Expand Up @@ -1072,7 +1072,7 @@ algorithm
dlow_1 = Inline.inlineCalls(SOME(funcs),{DAE.NORM_INLINE(),DAE.AFTER_INDEX_RED_INLINE()},dlow_1);
(comps) = BackendDAETransform.strongComponents(m, mT, ass1, ass2);
indexed_dlow = BackendDAEUtil.translateDae(dlow_1,NONE());
indexed_dlow_1 = BackendDAEUtil.calculateValues(indexed_dlow);
indexed_dlow_1 = BackendDAEUtil.calculateValues(cache, env, indexed_dlow);
Debug.fprint("bltdump", "indexed DAE:\n");
Debug.fcall("bltdump", BackendDump.dumpIncidenceMatrix, m);
Debug.fcall("bltdump", BackendDump.dumpIncidenceMatrixT, mT);
Expand Down
17 changes: 9 additions & 8 deletions Compiler/Main/Main.mo
Expand Up @@ -806,7 +806,7 @@ algorithm
Debug.fcall("bltdump", BackendDump.dumpComponents, comps);
str = BackendDump.dumpComponentsGraphStr(BackendDAEUtil.systemSize(dlow_1),m,mT,v1,v2);
Debug.fcall("dumpcompgraph",print,str);
modpar(dlow_1, v1, v2, comps);
modpar(cache, env, dlow_1, v1, v2, comps);
Debug.fcall("execstat",print, "*** Main -> To simcodegen at time: " +& realString(clock()) +& "\n" );
simcodegen(cache,env,classname, p, ap, daeimpl, dlow_1, v1, v2, m, mT, comps);
then
Expand All @@ -827,30 +827,31 @@ end optimizeDae;
protected function modpar
"function: modpar
The automatic paralellzation module."
input Env.Cache cache;
input Env.Env env;
input BackendDAE.BackendDAE inBackendDAE1;
input array<Integer> inIntegerArray2;
input array<Integer> inIntegerArray3;
input list<list<Integer>> inIntegerLstLst4;
algorithm
_:=
matchcontinue (inBackendDAE1,inIntegerArray2,inIntegerArray3,inIntegerLstLst4)
_ := matchcontinue (cache,env,inBackendDAE1,inIntegerArray2,inIntegerArray3,inIntegerLstLst4)
local
Integer n,nx,ny,np;
BackendDAE.BackendDAE indexed_dae,indexed_dae_1,dae;
Real l,b,t1,t2,time;
String timestr,nps;
array<Integer> ass1,ass2;
list<list<Integer>> comps;
case (_,_,_,_)
case (_,_,_,_,_,_)
equation
n = RTOpts.noProc() "If modpar not enabled, nproc = 0, return" ;
(n == 0) = true;
then
();
case (dae,ass1,ass2,comps)
case (cache,env,dae,ass1,ass2,comps)
equation
indexed_dae = BackendDAEUtil.translateDae(dae,NONE());
indexed_dae_1 = BackendDAEUtil.calculateValues(indexed_dae);
indexed_dae_1 = BackendDAEUtil.calculateValues(cache,env,indexed_dae);
TaskGraph.buildTaskgraph(indexed_dae_1, ass1, ass2, comps);
TaskGraphExt.dumpGraph("model.viz");
l = RTOpts.latency();
Expand All @@ -875,7 +876,7 @@ algorithm
print("done\n");
then
();
case (_,_,_,_)
else
equation
Debug.fprint("failtrace", "-modpar failed\n");
then
Expand Down Expand Up @@ -926,7 +927,7 @@ algorithm
Print.clearBuf();
Debug.fcall("execstat",print, "*** Main -> simcodgen -> translateDae: " +& realString(clock()) +& "\n" );
indexed_dlow = BackendDAEUtil.translateDae(dlow,NONE());
indexed_dlow_1 = BackendDAEUtil.calculateValues(indexed_dlow);
indexed_dlow_1 = BackendDAEUtil.calculateValues(cache,env,indexed_dlow);
Debug.fcall("dumpindxdae", BackendDump.dump, indexed_dlow_1);
cname_str = Absyn.pathString(classname);
//filename = stringAppendList({cname_str,".cpp"});
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Script/CevalScript.mo
Expand Up @@ -4066,7 +4066,7 @@ algorithm
(ass1,ass2,dlow_1,m,mT) = BackendDAETransform.matchingAlgorithm(dlow, m, mT, (BackendDAE.INDEX_REDUCTION(),BackendDAE.EXACT(), BackendDAE.REMOVE_SIMPLE_EQN()),Env.getFunctionTree(cache));
(comps) = BackendDAETransform.strongComponents(m, mT, ass1, ass2);
indexed_dlow = BackendDAEUtil.translateDae(dlow_1,NONE());
indexed_dlow_1 = BackendDAEUtil.calculateValues(indexed_dlow);
indexed_dlow_1 = BackendDAEUtil.calculateValues(cache,env,indexed_dlow);
xml_filename = stringAppendList({filenameprefix,".xml"});
funcelems = DAEUtil.getFunctionList(Env.getFunctionTree(cache));
Print.clearBuf();
Expand Down
2 changes: 1 addition & 1 deletion Parser/Parser_omc.cpp
Expand Up @@ -39,7 +39,7 @@ void* Parser_parse(const char* filename)
void *res = parseFile(filename,PARSE_MODELICA);
if (res == NULL)
MMC_THROW();
printAny(res);
// printAny(res);
return res;
}

Expand Down

0 comments on commit 9dbc91d

Please sign in to comment.