Skip to content

Commit

Permalink
Add times for reading init.xml and info.xml to the stats
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19964 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Apr 3, 2014
1 parent a5046fd commit d9e8715
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
4 changes: 4 additions & 0 deletions SimulationRuntime/c/simulation/simulation_runtime.cpp
Expand Up @@ -467,7 +467,9 @@ int startNonInteractiveSimulation(int argc, char**argv, DATA* data)

if(measure_time_flag)
{
rt_tick(SIM_TIMER_INFO_XML);
modelInfoXmlInit(&data->modelData.modelDataXml);
rt_accumulate(SIM_TIMER_INFO_XML);
//std::cerr << "ModelData with " << data->modelData.modelDataXml.nFunctions << " functions and " << data->modelData.modelDataXml.nEquations << " equations and " << data->modelData.modelDataXml.nProfileBlocks << " profileBlocks\n" << std::endl;
rt_init(SIM_TIMER_FIRST_FUNCTION + data->modelData.modelDataXml.nFunctions + data->modelData.modelDataXml.nEquations + data->modelData.modelDataXml.nProfileBlocks + 4 /* sentinel */);
rt_tick(SIM_TIMER_TOTAL);
Expand Down Expand Up @@ -786,7 +788,9 @@ int initRuntimeAndSimulation(int argc, char**argv, DATA *data)
data->simulationInfo.nlsMethod = getNonlinearSolverMethod(argc, argv);
data->simulationInfo.lsMethod = getlinearSolverMethod(argc, argv);

rt_tick(SIM_TIMER_INIT_XML);
read_input_xml(&(data->modelData), &(data->simulationInfo));
rt_accumulate(SIM_TIMER_INIT_XML);

/* allocate memory for mixed system solvers */
allocatemixedSystem(data);
Expand Down
5 changes: 4 additions & 1 deletion SimulationRuntime/c/simulation/solver/solver_main.c
Expand Up @@ -232,6 +232,7 @@ int initializeSolverData(DATA* data, SOLVER_INFO* solverInfo)
{
rt_accumulate(SIM_TIMER_PREINIT);
rt_tick(SIM_TIMER_INIT);
rt_tick(SIM_TIMER_TOTAL);
}

return retValue;
Expand Down Expand Up @@ -440,7 +441,9 @@ int finishSimulation(DATA* data, SOLVER_INFO* solverInfo, const char* outputVari
infoStreamPrint(LOG_STATS, 0, "### STATISTICS ###");

infoStreamPrint(LOG_STATS, 1, "timer");
infoStreamPrint(LOG_STATS, 0, "%12gs [%5.1f%%] pre-initialization", rt_accumulated(SIM_TIMER_PREINIT), rt_accumulated(SIM_TIMER_PREINIT)/rt_accumulated(SIM_TIMER_TOTAL)*100.0);
infoStreamPrint(LOG_STATS, 0, "%12gs reading init.xml", rt_accumulated(SIM_TIMER_INIT_XML));
infoStreamPrint(LOG_STATS, 0, "%12gs reading info.xml", rt_accumulated(SIM_TIMER_INFO_XML));
infoStreamPrint(LOG_STATS, 0, "%12gs pre-initialization", rt_accumulated(SIM_TIMER_PREINIT));
infoStreamPrint(LOG_STATS, 0, "%12gs [%5.1f%%] initialization", rt_accumulated(SIM_TIMER_INIT), rt_accumulated(SIM_TIMER_INIT)/rt_accumulated(SIM_TIMER_TOTAL)*100.0);
infoStreamPrint(LOG_STATS, 0, "%12gs [%5.1f%%] steps", rt_accumulated(SIM_TIMER_STEP), rt_accumulated(SIM_TIMER_STEP)/rt_accumulated(SIM_TIMER_TOTAL)*100.0);
infoStreamPrint(LOG_STATS, 0, "%12gs [%5.1f%%] creating output-file", rt_accumulated(SIM_TIMER_OUTPUT), rt_accumulated(SIM_TIMER_OUTPUT)/rt_accumulated(SIM_TIMER_TOTAL)*100.0);
Expand Down
35 changes: 18 additions & 17 deletions SimulationRuntime/c/util/rtclock.c
Expand Up @@ -33,6 +33,7 @@
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <gc.h>

#if defined(__MINGW32__) || defined(_MSC_VER)
#include <windows.h>
Expand Down Expand Up @@ -378,24 +379,24 @@ int rtclock_compare(rtclock_t t1, rtclock_t t2) {

#endif

static inline void alloc_and_copy(void **ptr, size_t n, size_t sz)
{
void *newmemory = GC_malloc(n*sz);
assert(newmemory != 0);
memcpy(newmemory,*ptr,NUM_RT_CLOCKS*sz);
*ptr = newmemory;
}

void rt_init(int numTimers) {
if (numTimers < NUM_RT_CLOCKS)
return; /* We already have more than we need statically allocated */
acc_tp = calloc(numTimers, sizeof(rtclock_t));
max_tp = calloc(numTimers, sizeof(rtclock_t));
total_tp = calloc(numTimers, sizeof(rtclock_t));
tick_tp = calloc(numTimers, sizeof(rtclock_t));
rt_clock_ncall = calloc(numTimers, sizeof(unsigned long));
rt_clock_ncall_total = calloc(numTimers, sizeof(unsigned long));
rt_clock_ncall_min = malloc(numTimers * sizeof(unsigned long));
rt_clock_ncall_max = calloc(numTimers, sizeof(unsigned long));
memset(rt_clock_ncall_min, 0xFF, numTimers * sizeof(unsigned long));
assert(acc_tp != 0);
assert(max_tp != 0);
assert(total_tp != 0);
assert(tick_tp != 0);
assert(rt_clock_ncall != 0);
assert(rt_clock_ncall_min != 0);
assert(rt_clock_ncall_max != 0);
assert(rt_clock_ncall_total != 0);
alloc_and_copy((void**)&acc_tp,numTimers,sizeof(rtclock_t));
alloc_and_copy((void**)&max_tp,numTimers,sizeof(rtclock_t));
alloc_and_copy((void**)&total_tp,numTimers,sizeof(rtclock_t));
alloc_and_copy((void**)&tick_tp,numTimers,sizeof(rtclock_t));
alloc_and_copy((void**)&rt_clock_ncall,numTimers,sizeof(unsigned long));
alloc_and_copy((void**)&rt_clock_ncall_total,numTimers,sizeof(unsigned long));
alloc_and_copy((void**)&rt_clock_ncall_min,numTimers,sizeof(unsigned long));
alloc_and_copy((void**)&rt_clock_ncall_max,numTimers,sizeof(unsigned long));
memset(rt_clock_ncall_min + NUM_RT_CLOCKS*sizeof(unsigned long), 0xFF, (numTimers-NUM_RT_CLOCKS) * sizeof(unsigned long));
}
4 changes: 3 additions & 1 deletion SimulationRuntime/c/util/rtclock.h
Expand Up @@ -49,7 +49,9 @@ extern "C" {
#define SIM_TIMER_PREINIT 6
#define SIM_TIMER_OVERHEAD 7
#define SIM_TIMER_FUNCTION_ODE 8
#define SIM_TIMER_FIRST_FUNCTION 9
#define SIM_TIMER_INIT_XML 9
#define SIM_TIMER_INFO_XML 10
#define SIM_TIMER_FIRST_FUNCTION 11

#define SIM_PROF_TICK_FN(ix) rt_tick(ix+SIM_TIMER_FIRST_FUNCTION)
#define SIM_PROF_ACC_FN(ix) rt_accumulate(ix+SIM_TIMER_FIRST_FUNCTION)
Expand Down

0 comments on commit d9e8715

Please sign in to comment.