SST/macro
ftq.h
Go to the documentation of this file.
1 #ifndef sstmac_software_process_FTQ_H
2 #define sstmac_software_process_FTQ_H
3 
7 #include <stdint.h>
8 #include <vector>
9 
10 #include <sprockit/unordered.h>
11 
12 #include <string>
13 #include <stdlib.h>
14 
15 /**
16  "Fixed time quanta" collection of the amount of work done in particular time intervals
17  over the course of the computation
18 */
19 namespace sstmac {
20 namespace sw {
21 
22 
23 class ftq_epoch
24 {
25  protected:
26  long long* totals_;
27 
28  public:
29  ftq_epoch();
30 
31  virtual ~ftq_epoch();
32 
33  void
34  collect(int key_typeid, long ticks) {
35  totals_[key_typeid] += ticks;
36  }
37 
38  void init(int num_events, long long* buffer);
39 
40  long long
41  event_time(int key_typeid) const {
42  return totals_[key_typeid];
43  }
44 
45  void
46  set_event_time(int key_typeid, long long count) {
47  totals_[key_typeid] = count;
48  }
49 
50 };
51 
52 struct event_node {
54 
56 
57  long ticks_end;
58 
60 
61 };
62 
64  public ftq_epoch
65 {
66  public:
67 
69 
70  virtual ~task_ftq_calendar();
71 
72  void collect(int event_typeid, long ticks_begin, long ticks);
73 
74  virtual std::string
75  to_string() const {
76  return "TaskFTQCalendar";
77  }
78 
79  void dump(std::ofstream& os);
80 
81  protected:
83 
85 
86  long max_tick_;
87 
88 
89 };
90 
92  public task_ftq_calendar
93 {
94 
95  public:
96  app_ftq_calendar(int aid,
97  const std::string& appname,
98  long nticks_epoch);
99 
100  void dump(const std::string& fileroot);
101 
102  virtual ~app_ftq_calendar();
103 
104  /**
105  Resolution of the ticks is set by timestamp_resolution parameter.
106  timestamp_resolution gives the number of ps per tick
107  timestamp_resolution=100 -> 100ps = 1 tick
108  @param event_typeid The type of event (MPI,Compute,Sleep,etc)
109  @param tid The task id (essentially MPI Rank)
110  @param ticks_begin The time the event started
111  @param num_ticks The duration of the event
112  */
113  void collect(int event_typeid, int tid, long ticks_begin, long num_ticks);
114 
115  virtual std::string
116  to_string() const {
117  return "AppFTQCalendar";
118  }
119 
120  void
121  reduce(app_ftq_calendar* cal);
122 
123  void
124  global_reduce(parallel_runtime* rt);
125 
126  private:
127  spkt_unordered_map<int, task_ftq_calendar*> calendars_;
128  spkt_unordered_map<int, ftq_epoch*> thread_epochs_;
129 
130  std::vector<ftq_epoch> epochs_;
131 
132  std::list<long long*> buffers_;
133 
134  int aid_;
135 
136  int max_tid_;
137 
139 
141 
143 
144  std::string appname_;
145 
146  void dumpi_gnuplot_histogram(const std::string& fileroot, int num_categories);
147 
148  void allocate_epochs(long max_epoch);
149 
150  static const long allocation_num_epochs;
151 
152 };
153 
155  public stat_collector
156 {
157  public:
158  ftq_calendar();
159 
160  void init(long nticks_per_epoch);
161 
162  virtual ~ftq_calendar();
163 
164  void collect(int event_typeid,
165  int aid,
166  int tid,
167  long ticks_begin,
168  long num_ticks);
169 
170  app_ftq_calendar* get_calendar(int aid) const;
171 
172  void register_app(int aid, const std::string& appname);
173 
174  void simulation_finished(timestamp end);
175 
176  void dump_local_data();
177 
178  void dump_global_data();
179 
180  void clear();
181 
182  void reduce(stat_collector* coll);
183 
184  void global_reduce(parallel_runtime *rt);
185 
186  virtual void
187  init_factory_params(sprockit::sim_parameters* params);
188 
189  ftq_calendar*
190  clone_me(int id) const {
191  ftq_calendar* cln = new ftq_calendar;
192  clone_into(cln);
193  cln->set_id(id);
194  return cln;
195  }
196 
198  clone() const {
199  return clone_me(-1);
200  }
201 
202  virtual std::string
203  to_string() const {
204  return "FTQCalendar";
205  }
206 
207  protected:
208  void
209  clone_into(ftq_calendar* cln) const;
210 
211  private:
212  static spkt_unordered_map<int, app_ftq_calendar*> calendars_;
213 
215 
216 
217 
218 };
219 
220 }
221 }
222 
223 #endif // FTQ_H
224 
void collect(int key_typeid, long ticks)
Definition: ftq.h:34
spkt_unordered_map< int, ftq_epoch * > thread_epochs_
Definition: ftq.h:128
virtual std::string to_string() const
Definition: ftq.h:203
stat_collector * clone() const
Definition: ftq.h:198
spkt_unordered_map< int, task_ftq_calendar * > calendars_
Definition: ftq.h:127
A type of logger that collects some kind of statistic and outputs to a file during or at the end of a...
virtual void set_id(int id)
static spkt_unordered_map< int, app_ftq_calendar * > calendars_
Definition: ftq.h:212
virtual std::string to_string() const
Definition: ftq.h:116
std::string appname_
Definition: ftq.h:144
long long * totals_
Definition: ftq.h:26
void init(int num_events, long long *buffer)
std::list< long long * > buffers_
Definition: ftq.h:132
long long event_time(int key_typeid) const
Definition: ftq.h:41
event_node * head_
Definition: ftq.h:82
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...
event_node * next
Definition: ftq.h:59
std::vector< ftq_epoch > epochs_
Definition: ftq.h:130
virtual std::string to_string() const
Definition: ftq.h:75
void set_event_time(int key_typeid, long long count)
Definition: ftq.h:46
ftq_calendar * clone_me(int id) const
Definition: ftq.h:190
static const long allocation_num_epochs
Definition: ftq.h:150
event_node * tail_
Definition: ftq.h:84