Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 995c5ef

Browse files
Willi BraunOpenModelica-Hudson
authored andcommitted
move profiling function from BackendDAEUtil > Util
Belonging to [master]: - #2271
1 parent 09e106c commit 995c5ef

File tree

3 files changed

+119
-112
lines changed

3 files changed

+119
-112
lines changed

Compiler/BackEnd/BackendDAEUtil.mo

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -8051,87 +8051,6 @@ algorithm
80518051
end for;
80528052
end isInitOptModuleActivated;
80538053

8054-
/*************************************************
8055-
* profiler stuff
8056-
************************************************/
8057-
8058-
public function profilerinit
8059-
algorithm
8060-
setGlobalRoot(Global.profilerTime1Index, 0.0);
8061-
setGlobalRoot(Global.profilerTime2Index, 0.0);
8062-
System.realtimeTick(ClockIndexes.RT_PROFILER0);
8063-
end profilerinit;
8064-
8065-
public function profilerresults
8066-
protected
8067-
Real tg,t1,t2;
8068-
algorithm
8069-
tg := System.realtimeTock(ClockIndexes.RT_PROFILER0);
8070-
t1 := profilertime1();
8071-
t2 := profilertime2();
8072-
print("Time all: "); print(realString(tg)); print("\n");
8073-
print("Time t1: "); print(realString(t1)); print("\n");
8074-
print("Time t2: "); print(realString(t2)); print("\n");
8075-
print("Time all-t1-t2: "); print(realString(realSub(realSub(tg,t1),t2))); print("\n");
8076-
end profilerresults;
8077-
8078-
public function profilertime1
8079-
output Real t1;
8080-
algorithm
8081-
t1 := getGlobalRoot(Global.profilerTime1Index);
8082-
end profilertime1;
8083-
8084-
public function profilertime2
8085-
output Real t2;
8086-
algorithm
8087-
t2 := getGlobalRoot(Global.profilerTime2Index);
8088-
end profilertime2;
8089-
8090-
public function profilerstart1
8091-
algorithm
8092-
System.realtimeTick(ClockIndexes.RT_PROFILER1);
8093-
end profilerstart1;
8094-
8095-
public function profilerstart2
8096-
algorithm
8097-
System.realtimeTick(ClockIndexes.RT_PROFILER2);
8098-
end profilerstart2;
8099-
8100-
public function profilerstop1
8101-
protected
8102-
Real t;
8103-
algorithm
8104-
t := System.realtimeTock(ClockIndexes.RT_PROFILER1);
8105-
setGlobalRoot(Global.profilerTime1Index,
8106-
realAdd(getGlobalRoot(Global.profilerTime1Index),t));
8107-
end profilerstop1;
8108-
8109-
public function profilerstop2
8110-
protected
8111-
Real t;
8112-
algorithm
8113-
t := System.realtimeTock(ClockIndexes.RT_PROFILER2);
8114-
setGlobalRoot(Global.profilerTime2Index,
8115-
realAdd(getGlobalRoot(Global.profilerTime2Index),t));
8116-
end profilerstop2;
8117-
8118-
public function profilerreset1
8119-
algorithm
8120-
setGlobalRoot(Global.profilerTime1Index, 0.0);
8121-
end profilerreset1;
8122-
8123-
public function profilerreset2
8124-
algorithm
8125-
setGlobalRoot(Global.profilerTime2Index, 0.0);
8126-
end profilerreset2;
8127-
8128-
public function profilertock1
8129-
output Real t;
8130-
algorithm
8131-
t := System.realtimeTock(ClockIndexes.RT_PROFILER1);
8132-
end profilertock1;
8133-
8134-
81358054
/*************************************************
81368055
* traverse BackendDAE equation systems
81378056
************************************************/

Compiler/BackEnd/OnRelaxation.mo

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ algorithm
135135
(BackendDAE.EQUATIONSYSTEM(eqns=eindex, vars=vindx, jac=BackendDAE.FULL_JACOBIAN(SOME(jac)), jacType=BackendDAE.JAC_LINEAR()))::comps)
136136
equation
137137
print("try to relax\n");
138-
BackendDAEUtil.profilerinit();
139-
BackendDAEUtil.profilerstart2();
140-
BackendDAEUtil.profilerstart1();
138+
Util.profilerinit();
139+
Util.profilerstart2();
140+
Util.profilerstart1();
141141
size = listLength(vindx);
142142
esize = listLength(eindex);
143143
ass1 = arrayCreate(size, -1);
@@ -223,10 +223,10 @@ algorithm
223223
// DumpGraphML.dumpSystem(subsyst, shared, NONE(), intString(size) + "SystemOneFreeMatching.graphml");
224224

225225
// hier sollte zur vorsicht noch mal ein matching durchgefuehrt werden
226-
BackendDAEUtil.profilerstop1();
227-
print("Matching time: " + realString(BackendDAEUtil.profilertime1()) + "\n");
228-
BackendDAEUtil.profilerreset1();
229-
BackendDAEUtil.profilerstart1();
226+
Util.profilerstop1();
227+
print("Matching time: " + realString(Util.profilertime1()) + "\n");
228+
Util.profilerreset1();
229+
Util.profilerstart1();
230230
// collect tearing variables and residual equations
231231
vorphans = getOrphans(1, size, ass1, {});
232232
eorphans = getOrphans(1, size, ass2, {});
@@ -265,10 +265,10 @@ algorithm
265265
// BackendDump.debuglst((roots, intString, ", ", "\n"));
266266
// print("constraints:\n");
267267
// BackendDump.debuglst((constraints, intString, ", ", "\n"));
268-
BackendDAEUtil.profilerstop1();
269-
print("Identifikation time: " + realString(BackendDAEUtil.profilertime1()) + "\n");
270-
BackendDAEUtil.profilerreset1();
271-
BackendDAEUtil.profilerstart1();
268+
Util.profilerstop1();
269+
print("Identifikation time: " + realString(Util.profilertime1()) + "\n");
270+
Util.profilerreset1();
271+
Util.profilerstart1();
272272
// Order of orphans
273273
vorphansarray1 = arrayCreate(size, {});
274274
List.map2_0(roots, doMark, rowmarks, mark);
@@ -283,10 +283,10 @@ algorithm
283283
// BackendDump.dumpIncidenceMatrix(vorphansarray1);
284284

285285
(vorphans, mark) = getOrphansOrderEdvanced3(roots, otherorphans, constraints, vorphans, vorphansarray1, mark, rowmarks);
286-
BackendDAEUtil.profilerstop1();
287-
print("Reihenfolge time: " + realString(BackendDAEUtil.profilertime1()) + "\n");
288-
BackendDAEUtil.profilerreset1();
289-
BackendDAEUtil.profilerstart1();
286+
Util.profilerstop1();
287+
print("Reihenfolge time: " + realString(Util.profilertime1()) + "\n");
288+
Util.profilerreset1();
289+
Util.profilerstart1();
290290
List.map2_0(constraints, doMark, rowmarks, mark);
291291
otherorphans = List.select2(vorphans, unmarked, rowmarks, mark);
292292

@@ -303,10 +303,10 @@ algorithm
303303
// print("Matching with Orphans:\n");
304304
// BackendDump.dumpMatching(ass1);
305305
// BackendDump.dumpIncidenceMatrix(ass22);
306-
BackendDAEUtil.profilerstop1();
307-
print("Paarung time: " + realString(BackendDAEUtil.profilertime1()) + "\n");
308-
BackendDAEUtil.profilerreset1();
309-
BackendDAEUtil.profilerstart1();
306+
Util.profilerstop1();
307+
print("Paarung time: " + realString(Util.profilertime1()) + "\n");
308+
Util.profilerreset1();
309+
Util.profilerstart1();
310310
vec1 = arrayCreate(esize, {});
311311
vec2 = arrayCreate(esize, -1);
312312

@@ -321,10 +321,10 @@ algorithm
321321
// DumpGraphML.dumpSystem(subsyst, shared, SOME(vec3), "System.graphml");
322322

323323
((_, _, _, eqns, vars)) = Array.fold(vec2, getEqnsinOrder, (eqns, vars, ass22, BackendEquation.listEquation({}), BackendVariable.emptyVars()));
324-
BackendDAEUtil.profilerstop1();
325-
print("Indizierung time: " + realString(BackendDAEUtil.profilertime1()) + "\n");
326-
BackendDAEUtil.profilerreset1();
327-
BackendDAEUtil.profilerstart1();
324+
Util.profilerstop1();
325+
print("Indizierung time: " + realString(Util.profilertime1()) + "\n");
326+
Util.profilerreset1();
327+
Util.profilerstart1();
328328
// replace evaluated parametes
329329
//_ = BackendDAEUtil.traverseBackendDAEExpsEqnsWithUpdate(eqns, replaceFinalParameter, BackendVariable.daeGlobalKnownVars(shared));
330330

@@ -355,15 +355,15 @@ algorithm
355355
crefexplst = List.map(BackendVariable.varList(vars), makeCrefExps);
356356
crefexps = listArray(crefexplst);
357357
neweqns = makeGausElimination(1, size, matrix, crefexps, {});
358-
BackendDAEUtil.profilerstop1();
359-
print("Gaus Elimination time: " + realString(BackendDAEUtil.profilertime1()) + "\n");
360-
BackendDAEUtil.profilerreset1();
361-
BackendDAEUtil.profilerstart1();
358+
Util.profilerstop1();
359+
print("Gaus Elimination time: " + realString(Util.profilertime1()) + "\n");
360+
Util.profilerreset1();
361+
Util.profilerstart1();
362362
syst = replaceEquationsAddNew(eindex, neweqns, syst);
363-
BackendDAEUtil.profilerstop2();
364-
print("Gesamt time: " + realString(BackendDAEUtil.profilertime2()) + "\n");
365-
BackendDAEUtil.profilerreset1();
366-
BackendDAEUtil.profilerstart1();
363+
Util.profilerstop2();
364+
print("Gesamt time: " + realString(Util.profilertime2()) + "\n");
365+
Util.profilerreset1();
366+
Util.profilerstart1();
367367
/*
368368
vars = BackendVariable.addVars(var_lst, vars);
369369
eqns = BackendEquation.addList(neweqns, teqns);

Compiler/Util/Util.mo

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public uniontype DateTime
8484
end DATETIME;
8585
end DateTime;
8686

87+
protected import ClockIndexes;
8788
protected import Config;
8889
protected import Error;
8990
protected import Flags;
@@ -1805,5 +1806,92 @@ algorithm
18051806
end match;
18061807
end sourceInfoIsEqual;
18071808

1809+
/*************************************************
1810+
* profiler stuff
1811+
************************************************/
1812+
public
1813+
1814+
function profilerinit
1815+
algorithm
1816+
setGlobalRoot(Global.profilerTime1Index, 0.0);
1817+
setGlobalRoot(Global.profilerTime2Index, 0.0);
1818+
System.realtimeTick(ClockIndexes.RT_PROFILER0);
1819+
end profilerinit;
1820+
1821+
function profilerresults
1822+
protected
1823+
Real tg,t1,t2;
1824+
algorithm
1825+
tg := System.realtimeTock(ClockIndexes.RT_PROFILER0);
1826+
t1 := profilertime1();
1827+
t2 := profilertime2();
1828+
print("Time all: "); print(realString(tg)); print("\n");
1829+
print("Time t1: "); print(realString(t1)); print("\n");
1830+
print("Time t2: "); print(realString(t2)); print("\n");
1831+
print("Time all-t1-t2: "); print(realString(realSub(realSub(tg,t1),t2))); print("\n");
1832+
end profilerresults;
1833+
1834+
function profilertime1
1835+
output Real t1;
1836+
algorithm
1837+
t1 := getGlobalRoot(Global.profilerTime1Index);
1838+
end profilertime1;
1839+
1840+
function profilertime2
1841+
output Real t2;
1842+
algorithm
1843+
t2 := getGlobalRoot(Global.profilerTime2Index);
1844+
end profilertime2;
1845+
1846+
function profilerstart1
1847+
algorithm
1848+
System.realtimeTick(ClockIndexes.RT_PROFILER1);
1849+
end profilerstart1;
1850+
1851+
function profilerstart2
1852+
algorithm
1853+
System.realtimeTick(ClockIndexes.RT_PROFILER2);
1854+
end profilerstart2;
1855+
1856+
function profilerstop1
1857+
protected
1858+
Real t;
1859+
algorithm
1860+
t := System.realtimeTock(ClockIndexes.RT_PROFILER1);
1861+
setGlobalRoot(Global.profilerTime1Index,
1862+
realAdd(getGlobalRoot(Global.profilerTime1Index),t));
1863+
end profilerstop1;
1864+
1865+
function profilerstop2
1866+
protected
1867+
Real t;
1868+
algorithm
1869+
t := System.realtimeTock(ClockIndexes.RT_PROFILER2);
1870+
setGlobalRoot(Global.profilerTime2Index,
1871+
realAdd(getGlobalRoot(Global.profilerTime2Index),t));
1872+
end profilerstop2;
1873+
1874+
function profilerreset1
1875+
algorithm
1876+
setGlobalRoot(Global.profilerTime1Index, 0.0);
1877+
end profilerreset1;
1878+
1879+
function profilerreset2
1880+
algorithm
1881+
setGlobalRoot(Global.profilerTime2Index, 0.0);
1882+
end profilerreset2;
1883+
1884+
function profilertock1
1885+
output Real t;
1886+
algorithm
1887+
t := System.realtimeTock(ClockIndexes.RT_PROFILER1);
1888+
end profilertock1;
1889+
1890+
function profilertock2
1891+
output Real t;
1892+
algorithm
1893+
t := System.realtimeTock(ClockIndexes.RT_PROFILER2);
1894+
end profilertock2;
1895+
18081896
annotation(__OpenModelica_Interface="util");
18091897
end Util;

0 commit comments

Comments
 (0)