diff --git a/Compiler/BackEnd/BackendDAEUtil.mo b/Compiler/BackEnd/BackendDAEUtil.mo index 26e41f9834a..319b0c40dd3 100644 --- a/Compiler/BackEnd/BackendDAEUtil.mo +++ b/Compiler/BackEnd/BackendDAEUtil.mo @@ -49,6 +49,7 @@ encapsulated package BackendDAEUtil public import BackendDAE; public import DAE; +public import Env; protected import Absyn; protected import BackendDump; @@ -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; @@ -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 knvarlst; BackendDAE.Variables knvars,vars,extVars; @@ -941,11 +943,11 @@ algorithm array 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); @@ -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; @@ -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; diff --git a/Compiler/BackEnd/SimCode.mo b/Compiler/BackEnd/SimCode.mo index 7fa337d2812..a4d3a511fb1 100644 --- a/Compiler/BackEnd/SimCode.mo +++ b/Compiler/BackEnd/SimCode.mo @@ -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); @@ -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); diff --git a/Compiler/Main/Main.mo b/Compiler/Main/Main.mo index 4a04728ac5d..98c24183094 100644 --- a/Compiler/Main/Main.mo +++ b/Compiler/Main/Main.mo @@ -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 @@ -827,13 +827,14 @@ 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 inIntegerArray2; input array inIntegerArray3; input list> 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; @@ -841,16 +842,16 @@ algorithm String timestr,nps; array ass1,ass2; list> 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(); @@ -875,7 +876,7 @@ algorithm print("done\n"); then (); - case (_,_,_,_) + else equation Debug.fprint("failtrace", "-modpar failed\n"); then @@ -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"}); diff --git a/Compiler/Script/CevalScript.mo b/Compiler/Script/CevalScript.mo index c4bed8caf0f..45c73244512 100644 --- a/Compiler/Script/CevalScript.mo +++ b/Compiler/Script/CevalScript.mo @@ -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(); diff --git a/Parser/Parser_omc.cpp b/Parser/Parser_omc.cpp index d10f0b1b996..b443a3d959d 100644 --- a/Parser/Parser_omc.cpp +++ b/Parser/Parser_omc.cpp @@ -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; }