Skip to content

Commit

Permalink
Merging r6331 through r6334
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Oct 11, 2010
2 parents 3769690 + bd2e2f8 commit f4c3698
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 40 deletions.
14 changes: 8 additions & 6 deletions Compiler/HashTable.mo
@@ -1,18 +1,20 @@
package HashTable "
This file is an extension to OpenModelica.
This file is an extension to OpenModelica.

Copyright (c) 2007 MathCore Engineering AB

All rights reserved.


This package contains implementation of hashtables, instead of the binary trees used in OpenModelica.
It is a generic implementation that can be used for any Key, Value datatypes. But the code must be copied
since MetaModelica is not powerful enough to handle general generics.

"


This HashTable is used in UnitChecking: UnitAbsyn.mo, UnitAbsynBuilder.mo, UnitChecker.mo, UnitParerExt.mo
RCS: $Id$
"

/* Below is the instance specific code. For each hashtable the user must define:
Key - The key used to uniquely define elements in a hashtable
Expand Down
15 changes: 8 additions & 7 deletions Compiler/HashTable2.mo
@@ -1,20 +1,21 @@
package HashTable2 "
This file is an extension to OpenModelica.
This file is an extension to OpenModelica.

Copyright (c) 2007 MathCore Engineering AB

All rights reserved.


Based on HashTable.mo but
Key = DAE.ComponentRef
Value = DAE.Exp
Based on HashTable.mo but
Key = DAE.ComponentRef
Value = DAE.Exp

Used by VarTransform.mo

"
Not used by OpenModelica!

RCS: $Id$

"

/* Below is the instance specific code. For each hashtable the user must define:
Key - The key used to uniquely define elements in a hashtable
Expand Down
9 changes: 6 additions & 3 deletions Compiler/HashTable3.mo
Expand Up @@ -6,11 +6,14 @@ package HashTable3 "
All rights reserved.


Based on HashTable.mo but
Key = DAE.ComponentRef
Value = list<DAE.ComponentRef>
Based on HashTable.mo but
Key = DAE.ComponentRef
Value = list<DAE.ComponentRef>

Used by VarTransform.mo
RCS: $Id$
"


Expand Down
4 changes: 4 additions & 0 deletions Compiler/HashTable4.mo
Expand Up @@ -10,6 +10,10 @@ package HashTable4 "
It is a generic implementation that can be used for any Key, Value datatypes. But the code must be copied
since MetaModelica is not powerful enough to handle general generics.

Not used by OpenModelica!

RCS: $Id$

"


Expand Down
5 changes: 4 additions & 1 deletion Compiler/HashTable5.mo
Expand Up @@ -10,9 +10,12 @@ package HashTable5 "
It is a generic implementation that can be used for any Key, Value datatypes. But the code must be copied
since MetaModelica is not powerful enough to handle general generics.

Used by Inst.mo and Env.mo.
RCS: $Id$
"


/* Below is the instance specific code. For each hashtable the user must define:
Key - The key used to uniquely define elements in a hashtable
Expand Down
7 changes: 6 additions & 1 deletion Compiler/HashTable6.mo
Expand Up @@ -9,7 +9,12 @@ package HashTable6 "
This package contains implementation of hashtables, instead of the binary trees used in OpenModelica.
It is a generic implementation that can be used for any Key, Value datatypes. But the code must be copied
since MetaModelica is not powerful enough to handle general generics.

Not used by OpenModelica!
RCS: $Id: HashTableStringToPath.mo 6234 2010-09-27 15:28:38Z adrpo $
"


Expand Down
12 changes: 7 additions & 5 deletions Compiler/HashTableCG.mo
Expand Up @@ -6,13 +6,15 @@ package HashTableCG "
All rights reserved.


Based on HashTable.mo but
Key = DAE.ComponentRef
Value = DAE.ComponentRef
Based on HashTable.mo but
Key = DAE.ComponentRef
Value = DAE.ComponentRef

Used by VarTransform.mo
Used by ConnectionGraph.mo
RCS: $Id$

"
"


/* Below is the instance specific code. For each hashtable the user must define:
Expand Down
16 changes: 10 additions & 6 deletions Compiler/HashTableStringToPath.mo
@@ -1,15 +1,19 @@
package HashTableStringToPath "
This file is an extension to OpenModelica.

This file is an extension to OpenModelica.
Copyright (c) 2007 MathCore Engineering AB

All rights reserved.


This package contains implementation of hashtables, instead of the binary trees used in OpenModelica.
It is a generic implementation that can be used for any Key, Value datatypes. But the code must be copied
since MetaModelica is not powerful enough to handle general generics.

Used by InstExtends.mo
RCS: $Id: HashTableStringToPath.mo 6234 2010-09-27 15:28:38Z adrpo $
"


Expand Down
64 changes: 60 additions & 4 deletions Compiler/System.mo
Expand Up @@ -732,13 +732,69 @@ function stopTimer
external "C";
end stopTimer;

function getTimerTime
function getTimerIntervalTime
"@autor: adrpo
this function will return the time that
passed between the last [startTimer,stopTimer] interval.
Notice that if start/stop are called recursively this
function will return the time passed between the
corresponding intervals.
Example:
(start1,
(start2,
(start3, stop3) call getTimerIntervalTime -> (stop3-start3)
stop2) call getTimerIntervalTime -> (stop2-start2)
stop1) call getTimerIntervalTime -> (stop1-start1)"
output Real timerIntervalTime;
external "C";
end getTimerIntervalTime;

function getTimerCummulatedTime
"@autor: adrpo
this function will return the cummulated time
between all calls to startTimer and stopTimer."
output Real timerTime;
by adding all the interval times [startTimer,stopTimer].
Note that if you have recursive calls to start/stop
this function will not return the *correct* time.
Example:
Recursive:
(start1, (start2, (start3, stop3) stop2) stop1)
getTimerCummulatedTime =
stop3-start3 + stop2-start2 + stop1-start1.
Serial:
(start1, stop1) (start2, stop2) (start3, stop3)
getTimerCummulatedTime =
stop3-start3 + stop2-start2 + stop1-start1."
output Real timerCummulatedTime;
external "C";
end getTimerCummulatedTime;

function getTimerElapsedTime
"@autor: adrpo
this function will return the time
passed since the first call to startTimeer
Example:
(start1, (start2, (start3, stop3), stop2) ...
getTimerSinceFirstStartTime = timeNow-start1."
output Real timerElapsedTime;
external "C";
end getTimerElapsedTime;

function getTimerStackIndex
"@autor: adrpo
this function will return number of
times start/stop was called recursively.
You can use this function for pretty printing.
Example:
index 0
(start1, index 1
(start2, index 2
(start3, index 3
stop3), index 2
stop2) index 1
stop1) index 0"
output Integer stackIndex;
external "C";
end getTimerTime;
end getTimerStackIndex;

function stringAppendList
"@autor: adrpo
Expand Down
77 changes: 70 additions & 7 deletions Compiler/runtime/systemimpl.c
Expand Up @@ -1430,7 +1430,6 @@ RML_BEGIN_LABEL(System__listAppendUnsafe)
}
RML_END_LABEL

char rml_external_roots_trail_names[1024][200];
void *rml_external_roots_trail[1024] = {0};
rml_uint_t rml_external_roots_trail_size = 1024;

Expand Down Expand Up @@ -3022,40 +3021,104 @@ RML_BEGIN_LABEL(System__realtimeTock)
}
RML_END_LABEL

#define TIMER_MAX_STACK 1000
double timerIntervalTime = 0;
double timerCummulatedTime = 0;
double timerTime = 0;
long int timerStackIdx = 0;
double timerStack[TIMER_MAX_STACK] = {0};

RML_BEGIN_LABEL(System__resetTimer)
{
/* reset the timer */
timerIntervalTime = 0;
timerCummulatedTime = 0;
timerTime = 0;
timerStackIdx = 0;
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

void pushTimerStack()
{
if (timerStackIdx < TIMER_MAX_STACK)
{
timerStack[timerStackIdx] = rt_tock(RT_CLOCK_SPECIAL_STOPWATCH);
/* increase the stack */
timerStackIdx++;
}
else
{
fprintf(stderr, "System.pushStartTime -> timerStack overflow %ld\n", timerStackIdx);
}
}

double popTimerStack()
{
if (timerStackIdx >= 1)
{
/* how much time passed since we last called startTime? */
timerIntervalTime = rt_tock(RT_CLOCK_SPECIAL_STOPWATCH) - timerStack[timerStackIdx-1];
timerCummulatedTime += timerIntervalTime;
/* decrease the stack */
timerStackIdx--;
}
else
{
fprintf(stderr, "System.popStartTime -> timerStack underflow %ld\n", timerStackIdx);
}
}

RML_BEGIN_LABEL(System__startTimer)
{
/* start the timer */
rt_tick(RT_CLOCK_SPECIAL_STOPWATCH);
/* start the timer if not already started */
if (!timerStackIdx)
{
rt_tick(RT_CLOCK_SPECIAL_STOPWATCH);
}
pushTimerStack();
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

RML_BEGIN_LABEL(System__stopTimer)
{
/* cummulate the timer time */
timerTime += rt_tock(RT_CLOCK_SPECIAL_STOPWATCH);
popTimerStack();
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

RML_BEGIN_LABEL(System__getTimerTime)
RML_BEGIN_LABEL(System__getTimerIntervalTime)
{
/* get the cummulated timer time */
rmlA0 = mk_rcon(timerTime);
rmlA0 = mk_rcon(timerIntervalTime);
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

RML_BEGIN_LABEL(System__getTimerCummulatedTime)
{
/* get the cummulated timer time */
rmlA0 = mk_rcon(timerCummulatedTime);
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

RML_BEGIN_LABEL(System__getTimerElapsedTime)
{
/* get the cummulated timer time */
rmlA0 = mk_rcon(rt_tock(RT_CLOCK_SPECIAL_STOPWATCH) - timerStack[0]);
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

RML_BEGIN_LABEL(System__getTimerStackIndex)
{
/* get the cummulated timer time */
rmlA0 = mk_icon(timerStackIdx);
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

/*
* adrpo: an implementation of stringAppendList in low level C
Expand Down
10 changes: 10 additions & 0 deletions Parser/Modelica.g
Expand Up @@ -767,6 +767,15 @@ algorithm_list returns [void* ast] :
| a=algorithm SEMICOLON as=algorithm_list {ast = mk_cons(a.ast,as);}
;

connect_clause returns [void* ast] :
CONNECT LPAR cr1=component_reference COMMA cr2=component_reference RPAR
{
ast = Absyn__EQ_5fCONNECT(cr1,cr2);
}
;

/* adrpo: 2010-10-11, replaced commented-out part with the rule above
which is conform to the grammar in the Modelica specification!
connect_clause returns [void* ast] :
CONNECT LPAR cr1=connector_ref COMMA cr2=connector_ref RPAR {ast = Absyn__EQ_5fCONNECT(cr1,cr2);}
;
Expand All @@ -784,6 +793,7 @@ connector_ref returns [void* ast] :
connector_ref_2 returns [void* ast] :
id=IDENT ( as=array_subscripts )? {ast = Absyn__CREF_5fIDENT(token_to_scon(id),or_nil(as));}
;
*/

/*
* 2.2.7 Expressions
Expand Down

0 comments on commit f4c3698

Please sign in to comment.