ROOT-Sim core
3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
|
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>
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) | |
Statistics module.
All facilities to collect, gather, and dump statistics are implemented in this module.
|
static |
Write the final statistic file, except for the data from other nodes.
[out] | out_f | a pointer to the file to write |
The following tables document the content of the final generated statistics file.
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
|
static |
Collect and dump the statistics from other nodes in the final binary file.
[out] | out_f | a 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().
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.
void stats_global_time_take | ( | enum stats_global_type | this_stat | ) |
Take a lifetime event time value.
this_stat | The type of event just occurred |
void stats_on_gvt | ( | simtime_t | gvt | ) |
Perform GVT related activities for the statistics subsystem.
gvt | the 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
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.
void stats_take | ( | enum stats_thread_type | this_stat, |
uint_fast64_t | c | ||
) |
Sum a sample to a statistics value.
this_stat | the statistics type to add the sample to |
c | the sample to sum |
const char* const stats_names[] |
The statistics names, used to fill in the preamble of the final statistics binary file.