Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
niklwors committed Jul 2, 2015
2 parents dba5362 + 471efb2 commit 1b61666
Show file tree
Hide file tree
Showing 77 changed files with 4,597 additions and 4,318 deletions.
4 changes: 2 additions & 2 deletions Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -68,7 +68,7 @@ protected import HashTable;
protected import HashTableCrToExpSourceTpl;
protected import Inline;
protected import List;
protected import SimCodeUtil;
protected import SimCodeFunctionUtil;
protected import SCode;
protected import System;
protected import Types;
Expand Down Expand Up @@ -154,7 +154,7 @@ algorithm
neqStr := intString(BackendDAEUtil.equationSize(eqnarr));
nvarStr := intString(BackendVariable.varsSize(vars_1));
Error.assertionOrAddSourceMessage(not Flags.isSet(Flags.DUMP_BACKENDDAE_INFO),Error.BACKENDDAEINFO_LOWER,{neqStr,nvarStr},Absyn.dummyInfo);
SimCodeUtil.execStat("Generate backend data structure");
SimCodeFunctionUtil.execStat("Generate backend data structure");
end lower;

protected function lower2
Expand Down
56 changes: 14 additions & 42 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -100,7 +100,7 @@ protected import OnRelaxation;
protected import RemoveSimpleEquations;
protected import ResolveLoops;
protected import SCode;
protected import SimCodeUtil;
protected import SimCodeFunctionUtil;
protected import StateMachineFeatures;
protected import SymbolicJacobian;
protected import SynchronousFeatures;
Expand Down Expand Up @@ -6591,34 +6591,6 @@ algorithm
end match;
end traverseBackendDAEExpsOptEqnWithUpdate;

public function traverseAlgorithmExps "
This function goes through the Algorithm structure and finds all the
expressions and performs the function on them
"
replaceable type Type_a subtypeof Any;
input DAE.Algorithm inAlgorithm;
input FuncExpType func;
input Type_a inTypeA;
output Type_a outTypeA;
partial function FuncExpType
input DAE.Exp inExp;
input Type_a inTypeA;
output DAE.Exp outExp;
output Type_a outA;
end FuncExpType;
algorithm
outTypeA := match (inAlgorithm,func,inTypeA)
local
list<DAE.Statement> stmts;
Type_a ext_arg_1;
case (DAE.ALGORITHM_STMTS(statementLst = stmts),_,_)
equation
(_,ext_arg_1) = DAEUtil.traverseDAEEquationsStmts(stmts,func,inTypeA);
then
ext_arg_1;
end match;
end traverseAlgorithmExps;

public function traverseAlgorithmExpsWithUpdate "
This function goes through the Algorithm structure and finds all the
expressions and performs the function on them
Expand Down Expand Up @@ -6749,7 +6721,7 @@ algorithm

// transformation phase (matching and sorting using index reduction method)
sode := causalizeDAE(optdae, NONE(), matchingAlgorithm, daeHandler, true);
SimCodeUtil.execStat("matching and sorting");
SimCodeFunctionUtil.execStat("matching and sorting");

if Flags.isSet(Flags.GRAPHML) then
HpcOmTaskGraph.dumpBipartiteGraph(sode, fileNamePrefix);
Expand All @@ -6763,13 +6735,13 @@ algorithm
(optsode, Util.SUCCESS()) := postOptimizeDAE(sode, postOptModules, matchingAlgorithm, daeHandler);

sode1 := FindZeroCrossings.findZeroCrossings(optsode);
SimCodeUtil.execStat("findZeroCrossings");
SimCodeFunctionUtil.execStat("findZeroCrossings");

_ := traverseBackendDAEExpsNoCopyWithUpdate(sode1, ExpressionSimplify.simplifyTraverseHelper, 0) "simplify all expressions";
SimCodeUtil.execStat("SimplifyAllExp");
SimCodeFunctionUtil.execStat("SimplifyAllExp");

outSODE := calculateValues(sode1);
SimCodeUtil.execStat("calculateValue");
SimCodeFunctionUtil.execStat("calculateValue");

if Flags.isSet(Flags.DUMP_INDX_DAE) then
BackendDump.dumpBackendDAE(outSODE, "dumpindxdae");
Expand Down Expand Up @@ -6830,7 +6802,7 @@ algorithm
BackendDAE.DAE(systs, shared) = optModule(inDAE);
systs = filterEmptySystems(systs);
dae = BackendDAE.DAE(systs, shared);
SimCodeUtil.execStat("preOpt " + moduleStr);
SimCodeFunctionUtil.execStat("preOpt " + moduleStr);
if Flags.isSet(Flags.OPT_DAE_DUMP) then
print(stringAppendList({"\npre-optimization module ", moduleStr, ":\n\n"}));
BackendDump.printBackendDAE(dae);
Expand All @@ -6839,7 +6811,7 @@ algorithm
then (dae1, status);

case (_, (_, moduleStr, b)::rest) equation
SimCodeUtil.execStat("<failed> preOpt " + moduleStr);
SimCodeFunctionUtil.execStat("<failed> preOpt " + moduleStr);
str = stringAppendList({"pre-optimization module ", moduleStr, " failed."});
Error.addMessage(Error.INTERNAL_ERROR, {str});
(dae,status) = preOptimizeDAE(inDAE,rest);
Expand Down Expand Up @@ -6881,15 +6853,15 @@ algorithm
BackendDAE.DAE(systs,shared) := inDAE;
// reduce index
(systs,shared,args,causalized) := mapCausalizeDAE(systs,shared,inMatchingOptions,matchingAlgorithm,stateDeselection,{},{},false);
//SimCodeUtil.execStat("matching");
//SimCodeFunctionUtil.execStat("matching");
// do late inline
outDAE := if dolateinline then BackendInline.lateInlineFunction(BackendDAE.DAE(systs,shared)) else BackendDAE.DAE(systs,shared);
// do state selection
BackendDAE.DAE(systs,shared) := stateDeselectionDAE(causalized,outDAE,args,stateDeselection);
// sort assigned equations to blt form
systs := mapSortEqnsDAE(systs,shared,{});
outDAE := BackendDAE.DAE(systs,shared);
//SimCodeUtil.execStat("sorting");
//SimCodeFunctionUtil.execStat("sorting");
end causalizeDAE;

protected function mapCausalizeDAE "
Expand Down Expand Up @@ -6971,10 +6943,10 @@ algorithm
nvars = BackendVariable.daenumVariables(syst);
neqns = systemSize(syst);
syst = Causalize.singularSystemCheck(nvars,neqns,syst,match_opts,matchingAlgorithm,arg,ishared);
// SimCodeUtil.execStat("transformDAE -> singularSystemCheck " + mAmethodstr);
// SimCodeFunctionUtil.execStat("transformDAE -> singularSystemCheck " + mAmethodstr);
// match the system and reduce index if neccessary
(syst,shared,arg) = matchingAlgorithmfunc(syst, ishared, false, match_opts, sssHandler, arg);
// SimCodeUtil.execStat("transformDAE -> matchingAlgorithm " + mAmethodstr + " index Reduction Method " + str1);
// SimCodeFunctionUtil.execStat("transformDAE -> matchingAlgorithm " + mAmethodstr + " index Reduction Method " + str1);
then (syst,shared,SOME(arg),true);

case (_,_,_,(_,mAmethodstr),(_,str1,_,_),_)
Expand Down Expand Up @@ -7009,7 +6981,7 @@ algorithm
equation
// do state selection
outDAE = sDfunc(BackendDAE.DAE(systs,shared),args);
//SimCodeUtil.execStat("transformDAE -> state selection " + methodstr);
//SimCodeFunctionUtil.execStat("transformDAE -> state selection " + methodstr);
then
outDAE;
else inDAE;
Expand Down Expand Up @@ -7120,7 +7092,7 @@ algorithm
BackendDAE.DAE(systs, shared) = optModule(inDAE);
systs = filterEmptySystems(systs);
dae = BackendDAE.DAE(systs, shared);
SimCodeUtil.execStat("postOpt " + moduleStr);
SimCodeFunctionUtil.execStat("postOpt " + moduleStr);
if Flags.isSet(Flags.OPT_DAE_DUMP) then
print(stringAppendList({"\npost-optimization module ", moduleStr, ":\n\n"}));
BackendDump.printBackendDAE(dae);
Expand All @@ -7131,7 +7103,7 @@ algorithm

case (_, (_, moduleStr, b)::rest, _, _)
equation
SimCodeUtil.execStat("postOpt <failed> " + moduleStr);
SimCodeFunctionUtil.execStat("postOpt <failed> " + moduleStr);
str = stringAppendList({"post-optimization module ", moduleStr, " failed."});
Error.addMessage(Error.INTERNAL_ERROR, {str});
(dae,status) = postOptimizeDAE(inDAE,rest,matchingAlgorithm,daeHandler);
Expand Down
10 changes: 5 additions & 5 deletions Compiler/BackEnd/BackendQSS.mo
Expand Up @@ -55,7 +55,7 @@ protected import BackendVariable;
protected import ComponentReference;
protected import HpcOmSimCode;
protected import List;
protected import SimCodeUtil;
protected import SimCodeFunctionUtil;

public
uniontype QSSinfo "- equation indices in static blocks and DEVS structure"
Expand Down Expand Up @@ -614,7 +614,7 @@ end generateHandler;
// then computeAlgs(tail,states,listAppend(i_algs,{cref}));
// case ((SimCode.SES_LINEAR(vars=vars)) :: tail,_,_)
// equation
// vars_cref = List.map(vars,SimCodeUtil.varName);
// vars_cref = List.map(vars,SimCodeFunctionUtil.varName);
// then computeAlgs(tail,states,listAppend(i_algs,vars_cref));
// case ({},_,_)
// equation
Expand Down Expand Up @@ -802,9 +802,9 @@ algorithm
case (SimCode.SES_SIMPLE_ASSIGN(cref=cref,exp=exp),
SimCodeVar.SIMVARS(paramVars=paramVars,intParamVars=intParamVars,boolParamVars=boolParamVars))
equation
failure(_ = List.position(cref,List.map(paramVars,SimCodeUtil.varName)));
failure(_ = List.position(cref,List.map(intParamVars,SimCodeUtil.varName)));
failure(_ = List.position(cref,List.map(boolParamVars,SimCodeUtil.varName)));
failure(_ = List.position(cref,List.map(paramVars,SimCodeFunctionUtil.varName)));
failure(_ = List.position(cref,List.map(intParamVars,SimCodeFunctionUtil.varName)));
failure(_ = List.position(cref,List.map(boolParamVars,SimCodeFunctionUtil.varName)));
t = stringAppend("parameter Real ",System.stringReplace(replaceCref(cref,{},{},{}),".","_"));
t = stringAppend(t," = ");
t = stringAppend(t,ExpressionDump.printExpStr(replaceVars(exp,{},{},{})));
Expand Down
55 changes: 29 additions & 26 deletions Compiler/BackEnd/HpcOmMemory.mo
Expand Up @@ -30,31 +30,34 @@
*/
encapsulated package HpcOmMemory

public import BackendDAE;
public import DAE;
public import HashTableCrILst;
public import HpcOmSimCode;
public import HpcOmTaskGraph;
public import SimCode;
public import SimCodeVar;

protected import Array;
protected import BackendDAEUtil;
protected import BackendDump;
protected import BackendEquation;
protected import BackendVariable;
protected import BaseHashTable;
protected import ComponentReference;
protected import Config;
protected import Debug;
protected import Error;
protected import Expression;
protected import Flags;
protected import GraphML;
protected import HpcOmScheduler;
protected import List;
protected import SimCodeUtil;
protected import Util;
import BackendDAE;
import DAE;
import HashTableCrILst;
import HpcOmSimCode;
import HpcOmTaskGraph;
import SimCode;
import SimCodeVar;

protected

import Array;
import BackendDAEUtil;
import BackendDump;
import BackendEquation;
import BackendVariable;
import BaseHashTable;
import ComponentReference;
import Config;
import Debug;
import Error;
import Expression;
import Flags;
import GraphML;
import HpcOmScheduler;
import List;
import SimCodeUtil;
import SimCodeFunctionUtil;
import Util;

// -------------------------------------------
// STRUCTURES
Expand Down Expand Up @@ -2867,7 +2870,7 @@ encapsulated package HpcOmMemory
threadText := "Th -1";
if(Util.isSome(simVarOpt)) then
simVar := Util.getOption(simVarOpt);
varCompRef := SimCodeUtil.varName(simVar);
varCompRef := SimCodeFunctionUtil.varName(simVar);
description := ComponentReference.printComponentRefStr(varCompRef);
isValidVar := BaseHashTable.hasKey(varCompRef, iVarNameSCVarIdxMapping);

Expand Down
44 changes: 23 additions & 21 deletions Compiler/BackEnd/HpcOmScheduler.mo
Expand Up @@ -42,22 +42,24 @@ public import HpcOmSimCode;
public import SimCode;
public import SimCodeVar;

protected import Absyn;
protected import Array;
protected import BackendDAEUtil;
protected import BackendVarTransform;
protected import ComponentReference;
protected import DAE;
protected import Debug;
protected import Error;
protected import Expression;
protected import Flags;
protected import HpcOmSchedulerExt;
protected import HpcOmSimCodeMain;
protected import List;
protected import SimCodeUtil;
protected import System;
protected import Util;
protected
import Absyn;
import Array;
import BackendDAEUtil;
import BackendVarTransform;
import ComponentReference;
import DAE;
import Debug;
import Error;
import Expression;
import Flags;
import HpcOmSchedulerExt;
import HpcOmSimCodeMain;
import List;
import SimCodeUtil;
import SimCodeFunctionUtil;
import System;
import Util;

public type TaskAssignment = array<Integer>; //the information which node <idx> is assigned to which processor <value>

Expand Down Expand Up @@ -3296,7 +3298,7 @@ algorithm
threadIdx = 1;
compIdx = arrayLength(iSccSimEqMapping)+1; // the next available component index
taskIdx = arrayLength(iTaskGraph)+1;
simVarIdx = List.fold(List.map(algVars,SimCodeUtil.varIndex),intMax,0)+1;// the next available simVar index
simVarIdx = List.fold(List.map(algVars,SimCodeFunctionUtil.varIndex),intMax,0)+1;// the next available simVar index
simEqSysIdx = SimCodeUtil.getMaxSimEqSystemIndex(iSimCode)+1;// the next available simEqSys index
lsIdx = List.fold(List.map(List.flatten(odes),SimCodeUtil.getLSindex),intMax,0)+1;// the next available linear system index
nlsIdx = List.fold(List.map(List.flatten(odes),SimCodeUtil.getNLSindex),intMax,0)+1;// the next available nonlinear system index
Expand Down Expand Up @@ -3993,7 +3995,7 @@ algorithm
crefLst := List.map1(simEqSysIdcs,SimCodeUtil.getAssignedCrefsOfSimEq,simCodeIn);
crefs := List.flatten(crefLst);
//print("crefs :\n"+stringDelimitList(List.map(crefs,ComponentReference.debugPrintComponentRefTypeStr),"\n")+"\n");
simVarLst := List.map1(crefs,SimCodeUtil.get,ht);
simVarLst := List.map1(crefs,SimCodeFunctionUtil.get,ht);

// build the new crefs, new simVars
numVars := listLength(simVarLst);
Expand Down Expand Up @@ -6502,7 +6504,7 @@ end revertTaskList;
//----------------

protected function setScheduleLockIds "Function creates unique Ids for every tuple of out and ingoing locks
author: mhartung"
author: mhartung"
input HpcOmSimCode.Schedule iSchedule;
output HpcOmSimCode.Schedule oSchedule;
protected
Expand Down Expand Up @@ -6572,7 +6574,7 @@ algorithm
end replaceDepTasksInListByLockIds;


protected function findTaskWithLockId "Function returns a DepTask with the id regarding lockIds or the identity of the given task"
protected function findTaskWithLockId "Function returns a DepTask with the id regarding lockIds or the identity of the given task"
input array<list<tuple<Integer,Integer>>> lockIds;
input HpcOmSimCode.Task iTask;
output HpcOmSimCode.Task oTask;
Expand Down Expand Up @@ -6708,4 +6710,4 @@ end intListListString;


annotation(__OpenModelica_Interface="backend");
end HpcOmScheduler;
end HpcOmScheduler;
6 changes: 3 additions & 3 deletions Compiler/BackEnd/Initialization.mo
Expand Up @@ -66,8 +66,8 @@ protected import ExpressionSimplify;
protected import Flags;
protected import List;
protected import Matching;
protected import SimCodeUtil;
protected import Sorting;
protected import SimCodeFunctionUtil;

// =============================================================================
// section for all public functions
Expand Down Expand Up @@ -172,7 +172,7 @@ algorithm
// generate initial system and pre-balance it
initsyst := BackendDAEUtil.createEqSystem(vars, eqns);
(initsyst, dumpVars) := preBalanceInitialSystem(initsyst);
SimCodeUtil.execStat("created initial system");
SimCodeFunctionUtil.execStat("created initial system");

// split the initial system into independend subsystems
initdae := BackendDAE.DAE({initsyst}, shared);
Expand All @@ -183,7 +183,7 @@ algorithm

(systs, shared) := BackendDAEOptimize.partitionIndependentBlocksHelper(initsyst, shared, Error.getNumErrorMessages(), true);
initdae := BackendDAE.DAE(systs, shared);
SimCodeUtil.execStat("partitioned initial system");
SimCodeFunctionUtil.execStat("partitioned initial system");

if Flags.isSet(Flags.OPT_DAE_DUMP) then
print(stringAppendList({"\npartitioned initial system:\n\n"}));
Expand Down

0 comments on commit 1b61666

Please sign in to comment.