ROSS
tw-stats.c
Go to the documentation of this file.
1#include <ross.h>
2#include<sys/stat.h>
3
4#ifndef ROSS_DO_NOT_PRINT
5static void
6show_lld(const char *name, tw_stat v)
7{
8 printf("\t%-50s %11lld\n", name, v);
9 fprintf(g_tw_csv, ",%lld", v);
10}
11
12static void
13show_2f(const char *name, double v)
14{
15 printf("\t%-50s %11.2f %%\n", name, v);
16 fprintf(g_tw_csv, ",%.2f", v);
17}
18
19static void
20show_1f(const char *name, double v)
21{
22 printf("\t%-50s %11.1f\n", name, v);
23 fprintf(g_tw_csv, ",%.2f", v);
24}
25
26static void
27show_4f(const char *name, double v)
28{
29 printf("\t%-50s %11.4lf\n", name, v);
30 fprintf(g_tw_csv, ",%.4lf", v);
31}
32
33#endif
34
35void
37{
38 tw_kp *kp;
39
40 unsigned int i;
41
42 if (pe != g_tw_pe)
43 return;
44
45 if (0 == g_tw_sim_started)
46 return;
47
48 tw_wtime rt;
49
50 tw_wall_sub(&rt, &pe->end_time, &pe->start_time);
51
53 s->s_nevent_abort += pe->stats.s_nevent_abort;
54 s->s_pq_qsize += tw_pq_get_size(pe->pq);
55
56 s->s_nsend_net_remote += pe->stats.s_nsend_net_remote;
57 s->s_nsend_loc_remote += pe->stats.s_nsend_loc_remote;
58
59 s->s_nsend_network += pe->stats.s_nsend_network;
60 s->s_nread_network += pe->stats.s_nread_network;
61 s->s_nsend_remote_rb += pe->stats.s_nsend_remote_rb;
62
63 s->s_total += pe->stats.s_total;
64 s->s_init += pe->stats.s_init;
65 s->s_net_read += pe->stats.s_net_read;
66 s->s_net_other += pe->stats.s_net_other;
67 s->s_gvt += pe->stats.s_gvt;
68 s->s_fossil_collect += pe->stats.s_fossil_collect;
69 s->s_event_abort += pe->stats.s_event_abort;
70 s->s_event_process += pe->stats.s_event_process;
71 s->s_pq += pe->stats.s_pq;
72 s->s_rollback += pe->stats.s_rollback;
73 s->s_cancel_q += pe->stats.s_cancel_q;
74 s->s_pe_event_ties += pe->stats.s_pe_event_ties;
76 s->s_avl += pe->stats.s_avl;
77 s->s_buddy += pe->stats.s_buddy;
78 s->s_lz4 += pe->stats.s_lz4;
79 s->s_stat_comp += pe->stats.s_stat_comp;
80 s->s_stat_write += pe->stats.s_stat_write;
81 s->s_events_past_end += pe->stats.s_events_past_end;
82#ifdef USE_RIO
83 s->s_rio_load += pe->stats.s_rio_load;
84 s->s_rio_lp_init += pe->stats.s_rio_lp_init;
85#endif
86 s->s_alp_nevent_processed = pe->stats.s_alp_nevent_processed;
87 s->s_alp_e_rbs = pe->stats.s_alp_e_rbs;
88
89 for(i = 0; i < g_tw_nkp; i++)
90 {
91 kp = tw_getkp(i);
93 s->s_e_rbs += kp->s_e_rbs;
94 s->s_rb_total += kp->s_rb_total;
96 }
97
98
102}
103
105{
107 tw_stat model_e_rbs = s->s_e_rbs - s->s_alp_e_rbs;
108 tw_stat model_net = model_nevent - model_e_rbs;
109 tw_stat analysis_net = s->s_alp_nevent_processed - s->s_alp_e_rbs;
110
111 printf("\nSeparate Statistics for Model and Analysis LPs\n");
112 printf("Model LPs:\n");
113 show_lld("Total Events Processed", model_nevent);
114 show_lld("Events Rolled Back", model_e_rbs);
115 show_lld("Net Events Processed", model_net);
116 show_2f("Efficiency", 100.0 * (1.0 - ((double) model_e_rbs / (double) model_net)));
117
118 printf("\nAnalysis LPs:\n");
119 show_lld("Total Events Processed", s->s_alp_nevent_processed);
120 show_lld("Events Rolled Back", s->s_alp_e_rbs);
121 show_lld("Net Events Processed", analysis_net);
122 show_2f("Efficiency", 100.0 * (1.0 - ((double) s->s_alp_e_rbs / (double) analysis_net)));
123}
124
125void
127{
129 bzero(&s, sizeof(s));
130 size_t m_alloc, m_waste;
131 tw_calloc_stats(&m_alloc, &m_waste);
132 tw_lp *lp = NULL;
133 unsigned int i;
134 for(i = 0; i < g_tw_nlp + g_st_analysis_nlp; i++)
135 {
136 lp = tw_getlp(i);
137 if (lp->type->final)
138 (*lp->type->final) (lp->cur_state, lp);
139 }
140 tw_get_stats(me, &s);
141 s = *(tw_net_statistics(me, &s));
142
143 if (!tw_ismaster())
144 return;
145
146#ifndef ROSS_DO_NOT_PRINT
147 printf("\n\t: Running Time = %.4f seconds\n", s.s_max_run_time);
148 fprintf(g_tw_csv, "%.4f", s.s_max_run_time);
149
150 printf("\nTW Library Statistics:\n");
151 show_lld("Total Events Processed", s.s_nevent_processed);
152 show_lld("Events Aborted (part of RBs)", s.s_nevent_abort);
153 show_lld("Events Rolled Back", s.s_e_rbs);
154 show_lld("Event Ties Detected in PE Queues", s.s_pe_event_ties);
156 printf("\t%-50s %11.9lf\n",
157 "Minimum TS Offset Detected in Conservative Mode",
158 (double) s.s_min_detected_offset);
159 show_2f("Efficiency", 100.0 * (1.0 - ((double) s.s_e_rbs / (double) s.s_net_events)));
160 show_lld("Total Remote (shared mem) Events Processed", s.s_nsend_loc_remote);
161
162 show_2f(
163 "Percent Remote Events",
164 ( (double)s.s_nsend_loc_remote
165 / (double)s.s_net_events)
166 * 100.0
167 );
168
169 show_lld("Total Remote (network) Events Processed", s.s_nsend_net_remote);
170 show_2f(
171 "Percent Remote Events",
172 ( (double)s.s_nsend_net_remote
173 / (double)s.s_net_events)
174 * 100.0
175 );
176
177 printf("\n");
178 show_lld("Total Roll Backs ", s.s_rb_total);
179 show_lld("Primary Roll Backs ", s.s_rb_primary);
180 show_lld("Secondary Roll Backs ", s.s_rb_secondary);
181 show_lld("Fossil Collect Attempts", s.s_fc_attempts);
182 show_lld("Total GVT Computations", g_tw_gvt_done);
183
184 printf("\n");
185 show_lld("Net Events Processed", s.s_net_events);
186 show_1f(
187 "Event Rate (events/sec)",
188 ((double)s.s_net_events / s.s_max_run_time)
189 );
190
191 show_lld("Total Events Scheduled Past End Time", s.s_events_past_end);
192
193 printf("\nTW Memory Statistics:\n");
194 show_lld("Events Allocated", 1 + g_tw_events_per_pe + g_tw_events_per_pe_extra);
195 show_lld("Memory Allocated", m_alloc / 1024);
196 show_lld("Memory Wasted", m_waste / 1024);
197
198 if (tw_nnodes() > 1) {
199 printf("\n");
200 printf("TW Network Statistics:\n");
201 show_lld("Remote sends", s.s_nsend_network);
202 show_lld("Remote recvs", s.s_nread_network);
203 }
204
205 printf("\nTW Data Structure sizes in bytes (sizeof):\n");
206 show_lld("PE struct", sizeof(tw_pe));
207 show_lld("KP struct", sizeof(tw_kp));
208 show_lld("LP struct", sizeof(tw_lp));
209 show_lld("LP Model struct", lp->type->state_sz);
210 show_lld("LP RNGs", sizeof(*lp->rng));
211 show_lld("Total LP", sizeof(tw_lp) + lp->type->state_sz + sizeof(*lp->rng));
212 show_lld("Event struct", sizeof(tw_event));
213 show_lld("Event struct with Model", sizeof(tw_event) + g_tw_msg_sz);
214
215#ifdef ROSS_timing
216 printf("\nTW Clock Cycle Statistics (MAX values in secs at %1.4lf GHz):\n", g_tw_clock_rate / 1000000000.0);
217 show_4f("Initialization", (double) s.s_init / g_tw_clock_rate);
218 show_4f("Priority Queue (enq/deq)", (double) s.s_pq / g_tw_clock_rate);
219 show_4f("AVL Tree (insert/delete)", (double) s.s_avl / g_tw_clock_rate);
220 show_4f("LZ4 (de)compression", (double) s.s_lz4 / g_tw_clock_rate);
221 show_4f("Buddy system", (double) s.s_buddy / g_tw_clock_rate);
222#ifdef USE_RIO
223 show_4f("RIO Loading", (double) s.s_rio_load / g_tw_clock_rate);
224 show_4f("RIO LP Init", (double) s.s_rio_lp_init / g_tw_clock_rate);
225#endif
226 show_4f("Event Processing", (double) s.s_event_process / g_tw_clock_rate);
227 show_4f("Event Cancel", (double) s.s_cancel_q / g_tw_clock_rate);
228 show_4f("Event Abort", (double) s.s_event_abort / g_tw_clock_rate);
229 printf("\n");
230 show_4f("GVT", (double) s.s_gvt / g_tw_clock_rate);
231 show_4f("Fossil Collect", (double) s.s_fossil_collect / g_tw_clock_rate);
232 show_4f("Primary Rollbacks", (double) s.s_rollback / g_tw_clock_rate);
233 show_4f("Network Read", (double) s.s_net_read / g_tw_clock_rate);
234 show_4f("Other Network", (double) s.s_net_other / g_tw_clock_rate);
235 show_4f("Instrumentation (computation)", (double) s.s_stat_comp / g_tw_clock_rate);
236 show_4f("Instrumentation (write)", (double) s.s_stat_write / g_tw_clock_rate);
237 show_4f("Total Time (Note: Using Running Time above for Speedup)", (double) s.s_total / g_tw_clock_rate);
238#endif
239
240 tw_gvt_stats(stdout);
241
244#endif
245}
246
247void
249{
250 if(me->id==0) {
251 mkdir("ross_all_lp_stats", 0777);
252 }
254
255 char pe_log_file_path[40];
256 snprintf(pe_log_file_path, 40, "ross_all_lp_stats/pe_%lu.txt", me->id);
257 FILE* pe_log_file = fopen(pe_log_file_path, "w");
258
259 fprintf(pe_log_file, "Time spent processing events for each LP:\n");
260
261 for(unsigned int i = 0; i < g_tw_nlp + g_st_analysis_nlp; i++)
262 {
263 tw_lp *lp = tw_getlp(i);
264 fprintf(pe_log_file, "LPID: %lu\t- Processing time: %e\t- Events processed: %u\n",
265 lp->gid,
268 }
269}
tw_pe * pe
Definition avl_tree.c:10
tw_lpid g_st_analysis_nlp
int g_st_use_analysis_lps
tw_statistics * tw_net_statistics(tw_pe *, tw_statistics *)
Function to reduce all the statistics for output.
unsigned tw_nnodes(void)
void tw_net_barrier(void)
unsigned int tw_pq_get_size(tw_pq *)
Definition splay.c:418
double g_tw_min_detected_offset
Definition ross-global.c:59
unsigned int g_tw_events_per_pe_extra
Definition ross-global.c:82
tw_pe * g_tw_pe
Definition ross-global.c:79
unsigned long long g_tw_clock_rate
void tw_wall_sub(tw_wtime *r, tw_wtime *a, tw_wtime *b)
Definition tw-timing.c:14
tw_kpid g_tw_nkp
Definition ross-global.c:27
unsigned int g_tw_events_per_pe
Definition ross-global.c:80
FILE * g_tw_csv
Definition ross-global.c:95
size_t g_tw_msg_sz
Definition ross-global.c:37
unsigned int g_tw_gvt_done
Definition ross-global.c:85
void tw_calloc_stats(size_t *alloc, size_t *waste)
Definition tw-util.c:123
tw_lpid g_tw_nlp
Definition ross-global.c:24
unsigned int g_tw_sim_started
Definition ross-global.c:36
double tw_wall_to_double(tw_wtime *t)
Definition tw-timing.c:27
tw_synch g_tw_synchronization_protocol
Definition ross-global.c:19
int g_tw_fossil_attempts
Definition ross-global.c:30
void tw_gvt_stats(FILE *F)
static int tw_ismaster(void)
static tw_lp * tw_getlp(tw_lpid id)
static tw_kp * tw_getkp(tw_kpid id)
#define ROSS_MAX(a, b)
unsigned long long tw_stat
Definition ross-types.h:58
@ CONSERVATIVE
Definition ross-types.h:38
struct timeval tw_wtime
Definition tw-timing.h:4
tw_clock s_process_event
unsigned int s_nevent_processed
Event Stucture.
Definition ross-types.h:277
long s_e_rbs
Number of events rolled back by this LP.
Definition ross-types.h:404
long s_rb_secondary
Number of secondary rollbacks by this LP.
Definition ross-types.h:406
tw_stat s_nevent_processed
Number of events processed.
Definition ross-types.h:402
long s_rb_total
Number of total rollbacks by this LP.
Definition ross-types.h:405
LP State Structure.
Definition ross-types.h:336
tw_rng_stream * rng
RNG stream array for this LP.
Definition ross-types.h:349
tw_lpid gid
global LP id
Definition ross-types.h:338
tw_lptype * type
Type of this LP, including service callbacks.
Definition ross-types.h:348
struct st_lp_stats * lp_stats
Definition ross-types.h:356
void * cur_state
Current application LP data.
Definition ross-types.h:347
size_t state_sz
Number of bytes that SV is for the LP.
Definition ross-types.h:105
final_f final
Final handler routine.
Definition ross-types.h:103
Holds the entire PE state.
Definition ross-types.h:416
tw_peid id
Definition ross-types.h:417
Statistics tallied over the duration of the simulation.
Definition ross-types.h:117
double s_min_detected_offset
Definition ross-types.h:142
tw_clock s_buddy
Definition ross-types.h:159
tw_stat s_nsend_remote_rb
Definition ross-types.h:133
tw_clock s_net_read
Definition ross-types.h:146
tw_stat s_alp_nevent_processed
Definition ross-types.h:166
tw_clock s_gvt
Definition ross-types.h:148
tw_stat s_nsend_loc_remote
Definition ross-types.h:135
tw_clock s_stat_write
Definition ross-types.h:162
tw_clock s_cancel_q
Definition ross-types.h:156
tw_clock s_fossil_collect
Definition ross-types.h:149
tw_clock s_lz4
Definition ross-types.h:160
tw_clock s_avl
Definition ross-types.h:158
tw_stat s_pe_event_ties
Definition ross-types.h:140
tw_clock s_pq
Definition ross-types.h:153
tw_stat s_nread_network
Definition ross-types.h:132
tw_stat s_pq_qsize
Definition ross-types.h:130
tw_clock s_total
Definition ross-types.h:144
tw_stat s_nevent_abort
Definition ross-types.h:122
tw_stat s_nevent_processed
Definition ross-types.h:121
tw_stat s_net_events
Definition ross-types.h:120
tw_clock s_rollback
Definition ross-types.h:154
tw_stat s_nsend_network
Definition ross-types.h:131
tw_stat s_e_rbs
Definition ross-types.h:123
tw_clock s_net_other
Definition ross-types.h:147
tw_stat s_rb_primary
Definition ross-types.h:126
tw_stat s_rb_secondary
Definition ross-types.h:127
double s_max_run_time
Definition ross-types.h:118
tw_stat s_nsend_net_remote
Definition ross-types.h:136
tw_stat s_events_past_end
Definition ross-types.h:164
tw_clock s_event_abort
Definition ross-types.h:151
tw_stat s_alp_e_rbs
Definition ross-types.h:167
tw_clock s_init
Definition ross-types.h:145
tw_stat s_rb_total
Definition ross-types.h:125
tw_clock s_stat_comp
Definition ross-types.h:161
tw_clock s_event_process
Definition ross-types.h:152
tw_stat s_fc_attempts
Definition ross-types.h:128
void tw_stats(tw_pe *me)
Definition tw-stats.c:126
static void show_1f(const char *name, double v)
Definition tw-stats.c:20
static void show_2f(const char *name, double v)
Definition tw-stats.c:13
static void show_lld(const char *name, tw_stat v)
Definition tw-stats.c:6
void tw_get_stats(tw_pe *pe, tw_statistics *s)
Definition tw-stats.c:36
static void show_4f(const char *name, double v)
Definition tw-stats.c:27
void tw_all_lp_stats(tw_pe *me)
Definition tw-stats.c:248
void st_print_analysis_LP_stats(tw_statistics *s)
Definition tw-stats.c:104