Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Free some memory during initialisation instead of increasing the size of the memory pool


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16209 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jun 4, 2013
1 parent 67c8c8e commit 3f3ec02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
12 changes: 8 additions & 4 deletions Compiler/Template/CodegenC.tpl
Expand Up @@ -1215,7 +1215,10 @@ template functionUpdateBoundParameters(list<SimEqSystem> parameterEquations)
* currently it only possible to call it with discontinuities
*/
let body = (parameterEquations |> eq =>
equation_(eq, contextSimulationDiscrete, &varDecls /*BUFD*/, &tmp)
<<
<%equation_(eq, contextSimulationDiscrete, &varDecls /*BUFD*/, &tmp)%>
restore_memory_state(mem_state);
>>
;separator="\n")
<<
<%&tmp%>
Expand All @@ -1225,7 +1228,6 @@ template functionUpdateBoundParameters(list<SimEqSystem> parameterEquations)
<%varDecls%>
mem_state = get_memory_state();
<%body%>
restore_memory_state(mem_state);
return 0;
}
Expand Down Expand Up @@ -1309,7 +1311,10 @@ template functionInitialEquations(Boolean useSymbolicInitialization, list<SimEqS
let &varDecls = buffer "" /*BUFD*/
let &tmp = buffer ""
let body = (initalEquations |> eq =>
equation_(eq, contextSimulationDiscrete, &varDecls /*BUFD*/, &tmp)
<<
<%equation_(eq, contextSimulationDiscrete, &varDecls /*BUFD*/, &tmp)%>
restore_memory_state(mem_state);
>>
;separator="\n")
let info = match useSymbolicInitialization
case true then
Expand All @@ -1334,7 +1339,6 @@ template functionInitialEquations(Boolean useSymbolicInitialization, list<SimEqS
data->simulationInfo.discreteCall = 1;
<%body%>
data->simulationInfo.discreteCall = 0;
restore_memory_state(mem_state);
return 0;
}
Expand Down
8 changes: 0 additions & 8 deletions SimulationRuntime/c/util/memory_pool.h
Expand Up @@ -35,14 +35,6 @@
#include <stdlib.h>
#include "openmodelica.h"

#define NR_REAL_ELEMENTS 1000000
#define NR_INTEGER_ELEMENTS 1000000
#define NR_STRING_ELEMENTS 10000
#define NR_BOOLEAN_ELEMENTS 10000
#define NR_SIZE_ELEMENTS 1000000
#define NR_INDEX_ELEMENTS 1000000
#define NR_CHAR_ELEMENTS 10000

extern int (*get_thread_index)(void); /* Implemented by generated code; different for each thread implementation */
extern state get_memory_state(void);
extern void restore_memory_state(state restore_state);
Expand Down

0 comments on commit 3f3ec02

Please sign in to comment.