Skip to content

Commit

Permalink
Create package Util/ClockIndexes (used to be part of Script/GlobalScr…
Browse files Browse the repository at this point in the history
…ipt) in order to decouple susan from the front-end modules

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22846 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Oct 21, 2014
1 parent 48413dc commit 3356e5d
Show file tree
Hide file tree
Showing 18 changed files with 195 additions and 145 deletions.
24 changes: 12 additions & 12 deletions Compiler/BackEnd/BackendDAEOptimize.mo
Expand Up @@ -61,6 +61,7 @@ protected import BaseHashTable;
protected import Ceval;
protected import CheckModel;
protected import ClassInf;
protected import ClockIndexes;
protected import Config;
protected import ComponentReference;
protected import DAEUtil;
Expand All @@ -73,7 +74,6 @@ protected import ExpressionSimplify;
protected import Error;
protected import Flags;
protected import Global;
protected import GlobalScript;
protected import Graph;
protected import HashSet;
protected import HashTableExpToIndex;
Expand Down Expand Up @@ -2065,9 +2065,9 @@ algorithm
usedvar = arrayCreate(adjSizeT, 0);
usedvar = Util.arraySet(adjSizeT-(sizeN-1), adjSizeT, usedvar, 1);

//Debug.execStat("generateSparsePattern -> start ",GlobalScript.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
//Debug.execStat("generateSparsePattern -> start ",ClockIndexes.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
eqnSparse = getSparsePattern(comps, eqnSparse, varSparse, mark, usedvar, 1, adjMatrix, adjMatrixT);
//Debug.execStat("generateSparsePattern -> end ",GlobalScript.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
//Debug.execStat("generateSparsePattern -> end ",ClockIndexes.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
// debug dump
Debug.fcall(Flags.DUMP_SPARSE_VERBOSE,BackendDump.dumpSparsePatternArray,eqnSparse);
Debug.fcall(Flags.DUMP_SPARSE_VERBOSE,print, "analytical Jacobians[SPARSE] -> prepared arrayList for transpose list: " +& realString(clock()) +& "\n");
Expand All @@ -2077,20 +2077,20 @@ algorithm
sparsepattern = arrayList(sparseArray);
sparsepattern = List.map1List(sparsepattern, intSub, adjSizeT-sizeN);

//Debug.execStat("generateSparsePattern -> postProcess ",GlobalScript.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
//Debug.execStat("generateSparsePattern -> postProcess ",ClockIndexes.RT_CLOCK_EXECSTAT_BACKEND_MODULES);

// transpose the column-based pattern to row-based pattern
sparseArrayT = arrayCreate(sizeN,{});
sparseArrayT = transposeSparsePattern(sparsepattern, sparseArrayT, 1);
sparsepatternT = arrayList(sparseArrayT);
//Debug.execStat("generateSparsePattern -> postProcess2 " ,GlobalScript.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
//Debug.execStat("generateSparsePattern -> postProcess2 " ,ClockIndexes.RT_CLOCK_EXECSTAT_BACKEND_MODULES);

// dump statistics
nonZeroElements = List.lengthListElements(sparsepattern);
dumpSparsePatternStatistics(Flags.isSet(Flags.DUMP_SPARSE),nonZeroElements,sparsepatternT);
Debug.fcall(Flags.DUMP_SPARSE,BackendDump.dumpSparsePattern,sparsepattern);
Debug.fcall(Flags.DUMP_SPARSE,BackendDump.dumpSparsePattern,sparsepatternT);
//Debug.execStat("generateSparsePattern -> nonZeroElements: " +& intString(nonZeroElements) +& " " ,GlobalScript.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
//Debug.execStat("generateSparsePattern -> nonZeroElements: " +& intString(nonZeroElements) +& " " ,ClockIndexes.RT_CLOCK_EXECSTAT_BACKEND_MODULES);

// translated to DAE.ComRefs
translated = List.mapList1_1(sparsepattern, List.getIndexFirst, diffCompRefs);
Expand All @@ -2116,9 +2116,9 @@ algorithm
forbiddenColor = arrayCreate(sizeN,NONE());
colored = arrayCreate(sizeN,0);
arraysparseGraph = listArray(sparseGraph);
//Debug.execStat("generateSparsePattern -> coloring start " ,GlobalScript.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
//Debug.execStat("generateSparsePattern -> coloring start " ,ClockIndexes.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
colored1 = Graph.partialDistance2colorInt(sparseGraphT, forbiddenColor, nodesList, arraysparseGraph, colored);
//Debug.execStat("generateSparsePattern -> coloring end " ,GlobalScript.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
//Debug.execStat("generateSparsePattern -> coloring end " ,ClockIndexes.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
// get max color used
maxColor = Util.arrayFold(colored1, intMax, 0);

Expand Down Expand Up @@ -2923,15 +2923,15 @@ algorithm

case(_) equation
true = Flags.getConfigBool(Flags.GENERATE_SYMBOLIC_JACOBIAN);
System.realtimeTick(GlobalScript.RT_CLOCK_EXECSTAT_JACOBIANS);
System.realtimeTick(ClockIndexes.RT_CLOCK_EXECSTAT_JACOBIANS);
BackendDAE.DAE(eqs=eqs,shared=shared) = inBackendDAE;
(symJacA , sparsePattern, sparseColoring, funcs) = createSymbolicJacobianforStates(inBackendDAE);
shared = BackendDAEUtil.addBackendDAESharedJacobian(symJacA, sparsePattern, sparseColoring, shared);
functionTree = BackendDAEUtil.getFunctions(shared);
functionTree = DAEUtil.joinAvlTrees(functionTree, funcs);
shared = BackendDAEUtil.addFunctionTree(functionTree, shared);
outBackendDAE = BackendDAE.DAE(eqs,shared);
_ = System.realtimeTock(GlobalScript.RT_CLOCK_EXECSTAT_JACOBIANS);
_ = System.realtimeTock(ClockIndexes.RT_CLOCK_EXECSTAT_JACOBIANS);
then outBackendDAE;

else inBackendDAE;
Expand All @@ -2951,7 +2951,7 @@ algorithm
list< .DAE.Constraint> constraints;
case(_) equation
true = Flags.getConfigBool(Flags.GENERATE_SYMBOLIC_LINEARIZATION);
System.realtimeTick(GlobalScript.RT_CLOCK_EXECSTAT_JACOBIANS);
System.realtimeTick(ClockIndexes.RT_CLOCK_EXECSTAT_JACOBIANS);
BackendDAE.DAE(eqs=eqs,shared=shared) = inBackendDAE;
BackendDAE.SHARED(constraints=constraints) = shared;
(linearModelMatrixes, funcs) = createLinearModelMatrixes(inBackendDAE, Config.acceptOptimicaGrammar());
Expand All @@ -2960,7 +2960,7 @@ algorithm
functionTree = DAEUtil.joinAvlTrees(functionTree, funcs);
shared = BackendDAEUtil.addFunctionTree(functionTree, shared);
outBackendDAE = BackendDAE.DAE(eqs,shared);
_ = System.realtimeTock(GlobalScript.RT_CLOCK_EXECSTAT_JACOBIANS);
_ = System.realtimeTock(ClockIndexes.RT_CLOCK_EXECSTAT_JACOBIANS);
then outBackendDAE;

else inBackendDAE;
Expand Down
16 changes: 8 additions & 8 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -67,6 +67,7 @@ protected import Causalize;
protected import Ceval;
protected import CheckModel;
protected import ClassInf;
protected import ClockIndexes;
protected import ComponentReference;
protected import Config;
protected import DAEDump;
Expand All @@ -82,7 +83,6 @@ protected import ExpressionSimplify;
protected import FindZeroCrossings;
protected import Flags;
protected import Global;
protected import GlobalScript;
protected import HpcOmEqSystems;
protected import IndexReduction;
protected import InlineArrayEquations;
Expand Down Expand Up @@ -8948,14 +8948,14 @@ public function profilerinit
algorithm
setGlobalRoot(Global.profilerTime1Index, 0.0);
setGlobalRoot(Global.profilerTime2Index, 0.0);
System.realtimeTick(GlobalScript.RT_PROFILER0);
System.realtimeTick(ClockIndexes.RT_PROFILER0);
end profilerinit;

public function profilerresults
protected
Real tg,t1,t2;
algorithm
tg := System.realtimeTock(GlobalScript.RT_PROFILER0);
tg := System.realtimeTock(ClockIndexes.RT_PROFILER0);
t1 := getGlobalRoot(Global.profilerTime1Index);
t2 := getGlobalRoot(Global.profilerTime2Index);
print("Time all: "); print(realString(tg)); print("\n");
Expand All @@ -8978,19 +8978,19 @@ end profilertime2;

public function profilerstart1
algorithm
System.realtimeTick(GlobalScript.RT_PROFILER1);
System.realtimeTick(ClockIndexes.RT_PROFILER1);
end profilerstart1;

public function profilerstart2
algorithm
System.realtimeTick(GlobalScript.RT_PROFILER2);
System.realtimeTick(ClockIndexes.RT_PROFILER2);
end profilerstart2;

public function profilerstop1
protected
Real t;
algorithm
t := System.realtimeTock(GlobalScript.RT_PROFILER1);
t := System.realtimeTock(ClockIndexes.RT_PROFILER1);
setGlobalRoot(Global.profilerTime1Index,
realAdd(getGlobalRoot(Global.profilerTime1Index),t));
end profilerstop1;
Expand All @@ -8999,7 +8999,7 @@ public function profilerstop2
protected
Real t;
algorithm
t := System.realtimeTock(GlobalScript.RT_PROFILER2);
t := System.realtimeTock(ClockIndexes.RT_PROFILER2);
setGlobalRoot(Global.profilerTime2Index,
realAdd(getGlobalRoot(Global.profilerTime2Index),t));
end profilerstop2;
Expand All @@ -9017,7 +9017,7 @@ end profilerreset2;
public function profilertock1
output Real t;
algorithm
t := System.realtimeTock(GlobalScript.RT_PROFILER1);
t := System.realtimeTock(ClockIndexes.RT_PROFILER1);
end profilertock1;


Expand Down
18 changes: 9 additions & 9 deletions Compiler/BackEnd/Matching.mo
Expand Up @@ -47,12 +47,12 @@ protected import BackendDAEUtil;
protected import BackendDump;
protected import BackendEquation;
protected import BackendVariable;
protected import ClockIndexes;
protected import Config;
protected import DAEUtil;
protected import Debug;
protected import Error;
protected import Flags;
protected import GlobalScript;
protected import IndexReduction;
protected import List;
protected import Util;
Expand Down Expand Up @@ -5955,11 +5955,11 @@ algorithm
syst := randSortSystem(isyst,ishared);
testMatchingAlgorithms1(matchingAlgorithms,syst,ishared,inMatchingOptions);

System.realtimeTick(GlobalScript.RT_PROFILER0);
System.realtimeTick(ClockIndexes.RT_PROFILER0);
(_,m,_) := BackendDAEUtil.getIncidenceMatrixfromOption(syst,BackendDAE.NORMAL(),NONE());
matchingExternalsetIncidenceMatrix(nv,ne,m);
cheapID := 3;
t := System.realtimeTock(GlobalScript.RT_PROFILER0);
t := System.realtimeTock(ClockIndexes.RT_PROFILER0);
print("SetMEXT: " +& realString(t) +& "\n");
extmatchingAlgorithms := {("DFSEXT: ",1),
("BFSEXT: ",2),
Expand All @@ -5971,12 +5971,12 @@ algorithm
("ABMPEXT ",8),
("PREXT: ",10)};
testExternMatchingAlgorithms1(extmatchingAlgorithms,cheapID,nv,ne);
System.realtimeTick(GlobalScript.RT_PROFILER0);
System.realtimeTick(ClockIndexes.RT_PROFILER0);
vec1 := arrayCreate(ne,-1);
vec2 := arrayCreate(nv,-1);
BackendDAEEXT.getAssignment(vec1,vec2);
print("GetAssEXT: " +& realString(t) +& "\n");
System.realtimeTick(GlobalScript.RT_PROFILER0);
System.realtimeTick(ClockIndexes.RT_PROFILER0);
//unassigned := checkAssignment(1,ne,vec1,vec2,{});
//print("Unnasigned: " +& intString(listLength(unassigned)) +& "\n");
//print("Unassigned:\n");
Expand All @@ -6003,9 +6003,9 @@ algorithm
then ();
case ((str,matchingAlgorithm)::rest,_,_,_)
equation
System.realtimeTick(GlobalScript.RT_PROFILER0);
System.realtimeTick(ClockIndexes.RT_PROFILER0);
testMatchingAlgorithm(10,matchingAlgorithm,isyst,ishared,inMatchingOptions);
t = System.realtimeTock(GlobalScript.RT_PROFILER0);
t = System.realtimeTock(ClockIndexes.RT_PROFILER0);
print(str +& realString(realDiv(t,10.0)) +& "\n");
testMatchingAlgorithms1(rest,isyst,ishared,inMatchingOptions);
then
Expand Down Expand Up @@ -6063,9 +6063,9 @@ algorithm
then ();
case ((str,matchingAlgorithm)::rest,_,_,_)
equation
System.realtimeTick(GlobalScript.RT_PROFILER0);
System.realtimeTick(ClockIndexes.RT_PROFILER0);
testExternMatchingAlgorithm(10,matchingAlgorithm,cheapId,nv,ne);
t = System.realtimeTock(GlobalScript.RT_PROFILER0);
t = System.realtimeTock(ClockIndexes.RT_PROFILER0);
print(str +& realString(realDiv(t,10.0)) +& "\n");
testExternMatchingAlgorithms1(rest,cheapId,nv,ne);
then
Expand Down
3 changes: 2 additions & 1 deletion Compiler/BackEnd/OpenTURNS.mo
Expand Up @@ -51,6 +51,7 @@ import BackendDAEOptimize;
import BackendDAEUtil;
import BackendEquation;
import BackendVariable;
import ClockIndexes;
import CevalScript;
import ComponentReference;
import DAEUtil;
Expand Down Expand Up @@ -113,7 +114,7 @@ algorithm

//print("strippedDae :");
//BackendDump.dump(strippedDae);
_ := System.realtimeTock(GlobalScript.RT_CLOCK_BACKEND); // Is this necessary?
_ := System.realtimeTock(ClockIndexes.RT_CLOCK_BACKEND); // Is this necessary?
(_,libs,fileDir,_,_) := SimCodeMain.generateModelCode(strippedDae,inProgram,inDAElist,inPath,cname_str,SOME(simSettings),Absyn.FUNCTIONARGS({},{}));

//print("..compiling, fileNamePrefix = "+&fileNamePrefix+&"\n");
Expand Down
7 changes: 4 additions & 3 deletions Compiler/BackEnd/Uncertainties.mo
Expand Up @@ -42,6 +42,7 @@ public import Values;

protected import Algorithm;
protected import BackendVariable;
protected import ClockIndexes;
protected import List;
protected import SCode;
protected import Flags;
Expand Down Expand Up @@ -651,11 +652,11 @@ algorithm
FCore.Cache cache;
case(_,_,_)
equation
System.realtimeTick(GlobalScript.RT_CLOCK_UNCERTAINTIES);
System.realtimeTick(ClockIndexes.RT_CLOCK_UNCERTAINTIES);
p_1 = SCodeUtil.translateAbsyn2SCode(p);
(cache,graph,_,dae) = Inst.instantiateClass(icache,InnerOuter.emptyInstHierarchy,p_1,className);
_ = System.realtimeTock(GlobalScript.RT_CLOCK_UNCERTAINTIES);
System.realtimeTick(GlobalScript.RT_CLOCK_BACKEND);
_ = System.realtimeTock(ClockIndexes.RT_CLOCK_UNCERTAINTIES);
System.realtimeTick(ClockIndexes.RT_CLOCK_BACKEND);
dae = DAEUtil.transformationsBeforeBackend(cache,graph,dae);
then (dae,cache,graph);
else
Expand Down
30 changes: 15 additions & 15 deletions Compiler/FFrontEnd/FInst.mo
Expand Up @@ -46,6 +46,7 @@ import DAE;
import FCore;

protected
import ClockIndexes;
import FBuiltin;
import FGraph;
import FExpand;
Expand All @@ -55,7 +56,6 @@ import System;
import InstUtil;
import Flags;
import List;
import GlobalScript;
import FNode;

public
Expand Down Expand Up @@ -98,31 +98,31 @@ algorithm

lst = {};

System.realtimeTick(GlobalScript.RT_CLOCK_FINST);
System.realtimeTick(ClockIndexes.RT_CLOCK_FINST);
(_, g) = FBuiltin.initialGraph(FCore.emptyCache());
g = FGraphBuild.mkProgramGraph(
p,
FCore.USERDEFINED(),
g);
lst = List.consr(lst, System.realtimeTock(GlobalScript.RT_CLOCK_FINST));
lst = List.consr(lst, System.realtimeTock(ClockIndexes.RT_CLOCK_FINST));
print("SCode->FGraph: " +& realString(List.first(lst)) +& "\n");
//print("FGraph nodes: " +& intString(listLength(FNode.dfs(FGraph.top(g)))) +& "\n");
//print("FGraph refs: " +& intString(listLength(FNode.dfs_filter(FGraph.top(g), FNode.isRefReference))) +& "\n");

System.realtimeTick(GlobalScript.RT_CLOCK_FINST);
System.realtimeTick(ClockIndexes.RT_CLOCK_FINST);
// resolve all
g = FExpand.all(g);
lst = List.consr(lst, System.realtimeTock(GlobalScript.RT_CLOCK_FINST));
lst = List.consr(lst, System.realtimeTock(ClockIndexes.RT_CLOCK_FINST));

//print("FGraph nodes: " +& intString(listLength(FNode.dfs(FGraph.top(g)))) +& "\n");
//print("FGraph refs: " +& intString(listLength(FNode.dfs_filter(FGraph.top(g), FNode.isRefReference))) +& "\n");
print("Total time: " +& realString(List.fold(lst, realAdd, 0.0)) +& "\n");

FGraphDump.dumpGraph(g, "F:\\dev\\" +& Absyn.pathString(inPath) +& ".graph.graphml");

System.realtimeTick(GlobalScript.RT_CLOCK_FINST);
System.realtimeTick(ClockIndexes.RT_CLOCK_FINST);
gclone = FGraph.clone(g);
lst = List.consr(lst, System.realtimeTock(GlobalScript.RT_CLOCK_FINST));
lst = List.consr(lst, System.realtimeTock(ClockIndexes.RT_CLOCK_FINST));
print("FGraph->clone: " +& realString(List.first(lst)) +& "\n");

// FGraphDump.dumpGraph(gclone, "F:\\dev\\" +& Absyn.pathString(inPath) +& ".graph.clone.graphml");
Expand Down Expand Up @@ -158,28 +158,28 @@ algorithm
equation
lst = {};

System.realtimeTick(GlobalScript.RT_CLOCK_FINST);
System.realtimeTick(ClockIndexes.RT_CLOCK_FINST);
p = doSCodeDep(inProgram, inPath);
lst = List.consr(lst, System.realtimeTock(GlobalScript.RT_CLOCK_FINST));
lst = List.consr(lst, System.realtimeTock(ClockIndexes.RT_CLOCK_FINST));
print("SCode depend: " +& realString(List.first(lst)) +& "\n");

System.realtimeTick(GlobalScript.RT_CLOCK_FINST);
System.realtimeTick(ClockIndexes.RT_CLOCK_FINST);
(_, g) = FBuiltin.initialGraph(FCore.emptyCache());
lst = List.consr(lst, System.realtimeTock(GlobalScript.RT_CLOCK_FINST));
lst = List.consr(lst, System.realtimeTock(ClockIndexes.RT_CLOCK_FINST));
print("Initial graph: " +& realString(List.first(lst)) +& "\n");

System.realtimeTick(GlobalScript.RT_CLOCK_FINST);
System.realtimeTick(ClockIndexes.RT_CLOCK_FINST);
g = FGraphBuild.mkProgramGraph(
p,
FCore.USERDEFINED(),
g);
lst = List.consr(lst, System.realtimeTock(GlobalScript.RT_CLOCK_FINST));
lst = List.consr(lst, System.realtimeTock(ClockIndexes.RT_CLOCK_FINST));
print("SCode->FGraph: " +& realString(List.first(lst)) +& "\n");

System.realtimeTick(GlobalScript.RT_CLOCK_FINST);
System.realtimeTick(ClockIndexes.RT_CLOCK_FINST);
// resolve all references on path
(g, r) = FExpand.path(g, inPath);
lst = List.consr(lst, System.realtimeTock(GlobalScript.RT_CLOCK_FINST));
lst = List.consr(lst, System.realtimeTock(ClockIndexes.RT_CLOCK_FINST));
print("FExpand.path: " +& realString(List.first(lst)) +& "\n");

print("FGraph nodes: " +& intString(FGraph.lastId(g)) +& "\n");
Expand Down

0 comments on commit 3356e5d

Please sign in to comment.