ROOT-Sim core  3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
Classes | Macros | Functions | Variables
stats.c File Reference

Statistics module. More...

#include <log/stats.h>
#include <arch/io.h>
#include <arch/mem.h>
#include <arch/timer.h>
#include <distributed/mpi.h>
#include <log/file.h>
#include <mm/mm.h>
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
Include dependency graph for stats.c:

Classes

struct  stats_thread
 A container for statistics in a logical time period. More...
 
struct  stats_node
 A container for node-wide statistics in a logical time period. More...
 
struct  stats_global
 A container for node-wide statistics relevant for the whole simulation run. More...
 

Macros

#define STATS_BUFFER_ENTRIES   (1024)
 The number of entries to keep in the stdio buffers before flushing a temporary statistics file to disk.
 

Functions

void stats_global_time_take (enum stats_global_type this_stat)
 Take a lifetime event time value. More...
 
void stats_global_init (void)
 Initializes the stats subsystem in the node.
 
void stats_init (void)
 Initializes the stats subsystem in the current thread.
 
static void stats_files_receive (FILE *out_f)
 Collect and dump the statistics from other nodes in the final binary file. More...
 
static void stats_files_send (void)
 Send the final statistics data of this node to the master node.
 
static void stats_file_final_write (FILE *out_f)
 Write the final statistic file, except for the data from other nodes. More...
 
void stats_global_fini (void)
 Finalizes the stats subsystem in the node. More...
 
void stats_take (enum stats_thread_type this_stat, uint_fast64_t c)
 Sum a sample to a statistics value. More...
 
void stats_on_gvt (simtime_t gvt)
 Perform GVT related activities for the statistics subsystem. More...
 
void stats_dump (void)
 Dump some final minimal statistics on screen.
 
uint64_t stats_retrieve (enum stats_thread_type this_stat)
 Retrieve the value of a metric of this thread. More...
 

Variables

const char *const stats_names []
 The statistics names, used to fill in the preamble of the final statistics binary file. More...
 
static timer_uint sim_start_ts
 The first timestamp ever collected for this simulation run.
 
static timer_uint sim_start_ts_hr
 The first high resolution timestamp of this simulation run: used to correlate high resolution and wall clock timers.
 
static struct stats_global stats_glob_cur
 The global stats.
 
static FILE * stats_node_tmp
 A pointer to the temporary file used to save stats_node structs produced during simulation.
 
static FILE ** stats_tmps
 An array of pointers to the temporary files used to save stats_thread structs produced by threads during simulation.
 
static __thread struct stats_thread stats_cur
 The current values of thread statistics for this logical time period (from the previous GVT to the next one)
 

Detailed Description

Statistics module.

All facilities to collect, gather, and dump statistics are implemented in this module.

Function Documentation

◆ stats_file_final_write()

static void stats_file_final_write ( FILE *  out_f)
static

Write the final statistic file, except for the data from other nodes.

Parameters
[out]out_fa pointer to the file to write

The following tables document the content of the final generated statistics file.

  • Rows are in order of appearance in the binary file
  • The binary file starts with a single Preamble
  • The Count column specifies how many repeated elements of that row are present
  • The Size column reports the size of a single row element in bytes
  • The Type column specifies the type of the field: uppercase types are further described in their own table
  • The Ref column assigns an identifier for values that are used later on to define counts of other rows
  • The Description column documents the purpose of the field

Preamble:

Count Size Type Ref Description
1 2 uint Magic number used to detect the endianness of the machine
1 8 int s_cnt Count of available thread metrics
s_cnt * Pascal string Names of the thread metrics
1 8 int n_cnt Count of MPI ranks (1 in the case of a single node run)
n_cnt * Node stats The statistics produced by the nodes

Pascal string:

Count Size Type Ref Description
1 1 uint p_len Size of the Pascal string (maximum 255, clearly)
p_len 1 char Content of the string

Node stats:

Count Size Type Ref Description
1 8 uint t_cnt Count of threads for the this node
1 8 uint Maximum resident set size of this node (in bytes)
6 8 uint Some timestamps in us (see enum stats_global_type)
1 8 uint High resolution time end to end value (see enum stats_global_type)
1 8 int n_siz Size of the node GVT stats array
n_siz / 16 16 Node GVT entry The node-wide statistics produced at each GVT by this node
t_cnt * Thread GVT stats The statistics produced by each thread on this node

Node GVT entry:

Count Size Type Ref Description
1 8 double Global virtual time value
1 8 uint Current resident set size of this node (in bytes)

Thread stats:

Count Size Type Ref Description
1 8 uint t_siz Size in bytes of this thread's GVT stats array
t_siz / (s_cnt * 8) s_cnt * 8 Thread GVT entry The statistics produced at each GVT by this thread

Thread GVT entry:

Count Size Typ Ref Description
s_cnt 8 uint The values of the stats described in the Preamble for this GVT and thread

In a correctly completed simulation n_siz / 16 == t_siz / (s_cnt * 8) for each node and thread (this is the number of committed GVTs). This function only writes the Node stats for the current node (the master node in a MPI run). The function stats_files_receive() deals with the other nodes. TODO add to the file other kind of statistics, for example ROOT-Sim config, machine hardware etc

◆ stats_files_receive()

static void stats_files_receive ( FILE *  out_f)
static

Collect and dump the statistics from other nodes in the final binary file.

Parameters
[out]out_fa pointer to the file to write. This can be NULL: the data from other nodes won't be saved

You may want to call this function with out_f set to NULL to flush the pending MPI communications. For details about the binary file format see stats_file_final_write().

◆ stats_global_fini()

void stats_global_fini ( void  )

Finalizes the stats subsystem in the node.

When finalizing this subsystem, the master node dumps his statistics from his temporary files onto the final binary file. Then, in a distributed setting, he receives the slaves temporary files, dumping their statistics as well.

◆ stats_global_time_take()

void stats_global_time_take ( enum stats_global_type  this_stat)

Take a lifetime event time value.

Parameters
this_statThe type of event just occurred

◆ stats_on_gvt()

void stats_on_gvt ( simtime_t  gvt)

Perform GVT related activities for the statistics subsystem.

Parameters
gvtthe time value of the current GVT

Dumps accumulated statistics to the file and resets the statistics buffer to ready up for the following processing phase

◆ stats_retrieve()

uint64_t stats_retrieve ( enum stats_thread_type  this_stat)

Retrieve the value of a metric of this thread.

This values are computed since the end of the last GVT.

◆ stats_take()

void stats_take ( enum stats_thread_type  this_stat,
uint_fast64_t  c 
)

Sum a sample to a statistics value.

Parameters
this_statthe statistics type to add the sample to
cthe sample to sum

Variable Documentation

◆ stats_names

const char* const stats_names[]
Initial value:
= {
[STATS_MSG_PROCESSED] = "processed messages",
[STATS_MSG_PROCESSED_TIME] = "processed messages time",
[STATS_ROLLBACK] = "rollbacks",
[STATS_RECOVERY_TIME] = "recovery time",
[STATS_MSG_ROLLBACK] = "rolled back messages",
[STATS_CKPT] = "checkpoints",
[STATS_CKPT_TIME] = "checkpoints time",
[STATS_CKPT_SIZE] = "checkpoints size",
[STATS_MSG_SILENT] = "silent messages",
[STATS_MSG_SILENT_TIME] = "silent messages time",
[STATS_MSG_ANTI] = "anti messages",
[STATS_REAL_TIME_GVT] = "gvt real time"
}
@ STATS_MSG_SILENT
The count of messages processed in coasting forward, i.e. silently executed messages.
Definition: stats.h:53
@ STATS_MSG_ANTI
The count of generated anti-messages.
Definition: stats.h:57
@ STATS_ROLLBACK
The count of rollbacks.
Definition: stats.h:41
@ STATS_MSG_SILENT_TIME
The time taken to carry out silent processing activities.
Definition: stats.h:55
@ STATS_CKPT_TIME
The time spent in checkpointing activities.
Definition: stats.h:49
@ STATS_MSG_PROCESSED_TIME
The time spent inside the model dispatcher function.
Definition: stats.h:39
@ STATS_MSG_PROCESSED
The count of processed messages.
Definition: stats.h:37
@ STATS_CKPT_SIZE
The size of LPs checkpoints.
Definition: stats.h:51
@ STATS_RECOVERY_TIME
The time spent for recovery from a rollback: checkpoint restore and anti-message sending activities.
Definition: stats.h:43
@ STATS_REAL_TIME_GVT
The real time elapsed since last GVT computation.
Definition: stats.h:59
@ STATS_CKPT
The count of taken checkpoints.
Definition: stats.h:47
@ STATS_MSG_ROLLBACK
The count of rollbacked message, i.e. the already processed messages whose effect has been invalidate...
Definition: stats.h:45

The statistics names, used to fill in the preamble of the final statistics binary file.