SST/macro
packet_flow_stats.h
Go to the documentation of this file.
1 #ifndef PACKET_FLOW_STATS_H
2 #define PACKET_FLOW_STATS_H
3 
13 #include <vector>
14 
15 namespace sstmac {
16 namespace hw {
17 
19 {
20  double incoming_bw;
21  double outgoing_bw;
26  packet_flow_payload* pkt;
29 };
30 
33 {
34  public:
35  virtual ~packet_sent_stats(){}
36 
37  virtual void
38  collect_single_event(const packet_stats_st& st);
39 
40  virtual void
41  collect_final_event(packet_flow_payload* pkt);
42 
43  virtual void
44  set_event_manager(event_manager* ev_mgr) = 0;
45 
46  virtual void
47  init_factory_params(sprockit::sim_parameters *params);
48 
49  /**
50  * @brief id
51  * Either a node or switch id, depending on the device
52  * @return
53  */
54  int id() const {
55  return id_;
56  }
57 
58  private:
59  int id_;
60 
61 };
62 
64 
65 class congestion_spyplot :
66  virtual public packet_sent_stats
67 {
68  public:
69  virtual ~congestion_spyplot();
70 
71  virtual void
72  collect_single_event(const packet_stats_st& st);
73 
74  virtual void
75  collect_final_event(packet_flow_payload* pkt);
76 
77  virtual void
78  init_factory_params(sprockit::sim_parameters* params);
79 
80  virtual void
81  set_event_manager(event_manager* ev_mgr);
82 
83  protected:
84  void collect(double delay_us, packet_flow_payload* pkt);
85 
86  private:
87  stat_spyplot* congestion_spyplot_;
88 };
89 
91  virtual public packet_sent_stats
92 {
93  public:
94  virtual ~delay_histogram();
95 
96  virtual void
97  collect_final_event(packet_flow_payload* pkt);
98 
99  virtual void
100  collect_single_event(const packet_stats_st& st);
101 
102  virtual void
103  init_factory_params(sprockit::sim_parameters* params);
104 
105  virtual void
106  set_event_manager(event_manager* ev_mgr);
107 
108  private:
110 };
111 
113  virtual public packet_sent_stats
114 {
115  public:
116  virtual void
117  collect_single_event(const packet_stats_st& st);
118 
119  virtual void
121 
122  protected:
123  void collect(double delay_us, packet_flow_payload* pkt);
124 
125 };
126 
128 {
129  public:
130  virtual void
132 
133  virtual void
134  collect_final_event(packet_flow_payload *pkt){}
135 
136  virtual void
138 
139 };
140 
142  virtual public packet_sent_stats
143 {
144  public:
146  byte_hops_(nullptr){}
147 
148  virtual ~byte_hop_collector();
149 
150  virtual void
151  collect_single_event(const packet_stats_st& st);
152 
153  virtual void
154  init_factory_params(sprockit::sim_parameters* params);
155 
156  virtual void
157  set_event_manager(event_manager* ev_mgr);
158 
159  private:
161 };
162 
164  public congestion_spyplot,
165  public packet_delay_stats
166 {
167  public:
168  virtual void
169  collect_single_event(const packet_stats_st& st);
170 
171  virtual void
172  init_factory_params(sprockit::sim_parameters* params);
173 
174  virtual void
176  congestion_spyplot::set_event_manager(ev_mgr);
177  }
178 };
179 
181  public stat_collector
182 {
184 
185  public:
187  top_(0),
188  local_aggregation_(nullptr)
189  {
190  }
191 
192  virtual ~stat_bytes_sent();
193 
194  void
195  record(int port, long bytes){
196  port_map_[port] += bytes;
197  }
198 
199  void
201  top_ = top;
202  }
203 
204  void
205  init_factory_params(sprockit::sim_parameters *params);
206 
207  void
208  simulation_finished(timestamp end);
209 
210  void
211  dump_local_data();
212 
213  void
214  dump_global_data();
215 
216  void
217  global_reduce(parallel_runtime *rt);
218 
219  void
220  reduce(stat_collector *coll);
221 
223  clone() const {
224  stat_bytes_sent* cln = new stat_bytes_sent;
225  clone_into(cln);
226  return cln;
227  }
228 
229  void
230  clear(){}
231 
232  private:
233  void
234  global_reduce_non_root(parallel_runtime* rt, int root, char* buffer, int buffer_size);
235 
236  void
237  collect_buffer_at_root(char* buffer, int buffer_size);
238 
239  void
240  output_switch(int sid, std::fstream& data_str, structured_topology* top);
241 
244  };
245 
246  void
247  collect_counts_at_root(parallel_runtime* rt, int src, global_gather_stats_t stats);
248 
249  void
250  global_reduce_root(parallel_runtime* rt, global_gather_stats_t* stats, char* my_buffer, int my_buffer_size);
251 
252  protected:
253  void
254  clone_into(stat_bytes_sent* cln) const;
255 
256  private:
258 
259  typedef std::map<int, long> port_map;
260  port_map port_map_;
261 
263  {
264  friend class stat_bytes_sent;
265  public:
266  struct entry
267  {
268  port_map pmap;
269  int sid;
270 
271  void
272  serialize_order(serializer& ser);
273  };
274 
275  private:
276  std::list<entry> entries_;
277  int max_sid_;
279 
280  public:
281  aggregation() : max_sid_(0), num_counts_(0) {}
282 
283  void
284  append(int sid, const port_map& pmap){
285  entry e;
286  e.pmap = pmap;
287  e.sid = sid;
288  entries_.push_back(e);
289  max_sid_ = std::max(max_sid_, sid);
290  num_counts_ += pmap.size();
291  }
292 
293  int
294  num_counts() const {
295  return num_counts_;
296  }
297 
298  int
299  num_entries() const {
300  return entries_.size();
301  }
302 
303  int
304  ser_size() const {
305  int entry_size = sizeof(int) + sizeof(size_t); //sid + map size
306  int count_size = sizeof(int) + sizeof(long); //port + num bytes
307  return num_entries() * entry_size + num_counts_ * count_size + sizeof(size_t);
308  }
309 
310  int
311  max_sid() const {
312  return max_sid_;
313  }
314 
315  const std::list<entry>&
316  entries() const {
317  return entries_;
318  }
319 
320  };
321 
323  std::vector<port_map> global_aggregation_;
324 
325 };
326 
328  virtual public packet_sent_stats
329 {
330  public:
332  bytes_sent_(nullptr)
333  {
334  }
335 
336  virtual ~bytes_sent_collector();
337 
338  virtual void
339  collect_single_event(const packet_stats_st &st);
340 
341  virtual void
342  init_factory_params(sprockit::sim_parameters* params);
343 
344  virtual void
345  set_event_manager(event_manager* ev_mgr);
346 
347  private:
349 };
350 
351 }
352 }
353 
355 template <>
356 class serialize<sstmac::hw::stat_bytes_sent::aggregation::entry> {
357  public:
359  e.serialize_order(ser);
360  }
361 };
363 
364 
365 #endif // PACKET_FLOW_STATS_H
virtual void set_event_manager(event_manager *ev_mgr)
void record(int port, long bytes)
virtual void collect_single_event(const packet_stats_st &st)
packet_flow_payload * pkt
DeclareFactory(node)
std::vector< port_map > global_aggregation_
A type of logger that collects some kind of statistic and outputs to a file during or at the end of a...
Base type for implementations of an engine that is able to schedule events and advance simulation tim...
Definition: event_manager.h:47
void append(int sid, const port_map &pmap)
void operator()(sstmac::hw::stat_bytes_sent::aggregation::entry &e, sstmac::serializer &ser)
stat_collector * clone() const
virtual void collect_final_event(packet_flow_payload *pkt)
#define SER_NAMESPACE_OPEN
Definition: serializable.h:50
virtual void set_event_manager(event_manager *ev_mgr)
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:33
A basic container for time (subject to future transplant).
Definition: timestamp.h:29
SUMI = Simulator unified messagine interface It is also the name for a solid ink in Japanese - i...
const std::list< entry > & entries() const
this stat_collector class keeps a spy plot
Definition: stat_spyplot.h:28
virtual void set_event_manager(event_manager *ev_mgr)
void set_topology(topology *top)
Encapsulates a topology like torus, fat tree, butterfly which has a regular, well-defined structure...
int id() const
id Either a node or switch id, depending on the device
std::map< int, long > port_map
#define SER_NAMESPACE_CLOSE
Definition: serializable.h:51