The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
statistics.c File Reference

Statistics module. More...

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <math.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <arch/thread.h>
#include <arch/memusage.h>
#include <scheduler/process.h>
#include <scheduler/scheduler.h>
#include <gvt/gvt.h>
#include <statistics/statistics.h>
#include <queues/queues.h>
#include <mm/state.h>
#include <mm/mm.h>
#include <core/core.h>
#include <core/init.h>
#include <core/timer.h>
#include <communication/mpi.h>
+ Include dependency graph for statistics.c:

Go to the source code of this file.

Data Structures

struct  _gvt_buffer
 
struct  _gvt_buffer::_gvt_buffer_row_t
 

Macros

#define GVT_BUFF_ROWS   50
 
#define safe_asprintf(ret_addr, format, ...)
 
#define HEADER_STR   "------------------------------------------------------------"
 
#define assign_new_file(destination, format, ...)
 

Functions

static void _rmdir (const char *path)
 
void _mkdir (const char *path)
 
static void print_config_to_file (FILE *f)
 
void print_config (void)
 
void statistics_start (void)
 
static char * format_size (double size)
 
static void print_header (FILE *f, const char *title)
 
static void print_timer_stats (FILE *f, timer *start_timer, timer *stop_timer, double total_time)
 
static void print_common_stats (FILE *f, struct stat_t *stats_p, bool want_thread_stats, bool want_local_stats)
 
static void print_termination_status (FILE *f, int exit_code)
 
void print_gvt_stats_file (void)
 
void statistics_stop (int exit_code)
 
void statistics_on_gvt (double gvt)
 
void statistics_on_gvt_serial (double gvt)
 
void statistics_init (void)
 
void statistics_fini (void)
 
void statistics_post_data_serial (enum stat_msg_t type, double data)
 
void statistics_post_data (struct lp_struct *lp, enum stat_msg_t type, double data)
 
double statistics_get_lp_data (struct lp_struct *lp, unsigned int type)
 

Variables

static __thread struct _gvt_buffer gvt_buf = {0}
 This structure is used to buffer statistics gathered on GVT computation.
 
static FILE ** thread_blob_files = {0}
 Pointers to the files used as binary buffer for the GVT statistics.
 
static FILE * unique_files [NUM_STAT_FILE_U] = {0}
 Pointers to unique files.
 
static FILE ** thread_files [NUM_STAT_FILE_T] = {0}
 Pointers to per-thread files.
 
static timer simulation_timer
 This is a timer that start during the initialization of statistics subsystem and can be used to know the total simulation time.
 
static struct stat_tlp_stats
 Keeps statistics on a per-LP basis.
 
static struct stat_tlp_stats_gvt
 Keeps statistics on a per-LP basis in a GVT phase.
 
static struct stat_tthread_stats
 Keeps statistics on a per-thread basis.
 
static struct stat_t system_wide_stats = {.gvt_round_time_min = INFTY}
 Keeps global statistics.
 
struct stat_t global_stats = {.gvt_round_time_min = INFTY}
 Keep statistics reduced globally across MPI ranks.
 

Detailed Description

Statistics module.

All facitilies to collect, gather, and dump statistics are implemented in this module. The statistics subsystem relies on the struct stat_t type to keep the relevant fields. Every statistic variable must be a double, because the aggregation functions are type-agnostic and consider every value to be a double. This allows to speedup some aggregations by relying on vectorized instructions.

There are two main entry points in this module:

  • statistics_post_data() can be called anywhere in the runtime library, allowing to specify a numerical code which identifies some statistic information. A value can be also passed, which is handled depending on the type of statistics managed. This function allows to update statistics values for each LP of the system.
  • statistics_get_lp_data() can be called to retrieve current per-LP statistical values. This is useful to implement autonomic policies which self-tune the behaviour of the runtime depending on, e.g., workload factors.

At the end of the simulation (or if the simulation is stopped), this module implements a coordination protocol to reduce all values, both at a machine level, and among distributed processes (using MPI).

This file is part of ROOT-Sim (ROme OpTimistic Simulator).

ROOT-Sim is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; only version 3 of the License applies.

ROOT-Sim is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ROOT-Sim; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Author
Andrea Piccione
Alessandro Pellegrini
Tommaso Tocci
Roberto Vitali

Definition in file statistics.c.

Macro Definition Documentation

#define assign_new_file (   destination,
  format,
  ... 
)
Value:
do {\
safe_asprintf(&name_buf, "%s/" format, rootsim_config.output_dir, ##__VA_ARGS__);\
if (((destination) = fopen(name_buf, "w+")) == NULL)\
rootsim_error(true, "Cannot open %s\n", name_buf);\
rsfree(name_buf);\
} while(0)
char * output_dir
Destination Directory of output files.
Definition: init.h:58
#define safe_asprintf(ret_addr, format,...)
Definition: statistics.c:136
simulation_configuration rootsim_config
This global variable holds the configuration for the current simulation.
Definition: core.c:70

Definition at line 647 of file statistics.c.

#define safe_asprintf (   ret_addr,
  format,
  ... 
)
Value:
({ \
char *__pstr = NULL; \
int __ret = snprintf(0, 0, format, ##__VA_ARGS__); \
if(__ret < 0) \
rootsim_error(true, "Error in snprintf()!"); \
__pstr = rsalloc(__ret + 1); \
__ret = snprintf(__pstr, __ret + 1, format, ##__VA_ARGS__); \
if(__ret < 0) \
rootsim_error(true, "Error in snprintf()!"); \
*(ret_addr) = __pstr; \
})

This is a pseudo asprintf() implementation needed in order to stop GCC 8 from complaining

Parameters
ret_addrA char ** pointer where the function stores the address of a large-enough string to hold the output
formatThe format string as in the real asprintf()
...The arguments list as in the real asprintf()
Returns
a malloc'd string containing the snprintf()-processed string

Definition at line 136 of file statistics.c.

Function Documentation

void _mkdir ( const char *  path)

This is an helper-function to allow the statistics subsystem create a new directory

Author
Alessandro Pellegrini
Parameters
pathThe path of the new directory to create

Definition at line 198 of file statistics.c.

+ Here is the caller graph for this function:

static void _rmdir ( const char *  path)
static

This is an helper-function to recursively delete the whole content of a folder

Parameters
pathThe path of the directory to purge

Definition at line 154 of file statistics.c.

static char* format_size ( double  size)
static

Nicely print a size

Parameters
sizeThe size in byte
Returns
A pointer to a per-thread buffer keeping the size.

Definition at line 298 of file statistics.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void statistics_fini ( void  )

This function finalize the Statistics subsystem

Author
Alessandro Pellegrini

Definition at line 736 of file statistics.c.

+ Here is the caller graph for this function:

void statistics_init ( void  )

This function initializes the Statistics subsystem

Author
Alessandro Pellegrini

Definition at line 660 of file statistics.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void statistics_start ( void  )

This function registers when the actual simulation is starting.

Definition at line 286 of file statistics.c.

+ Here is the caller graph for this function:

void statistics_stop ( int  exit_code)

This function print in the output file all the statistics associated with the simulation

Author
Francesco Quaglia
Roberto Vitali
Alessandro Pellegrini
Parameters
exit_codeThe exit code of the simulator, used to display a happy or sad termination message

Definition at line 442 of file statistics.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function: