SST/macro
graphviz.h
Go to the documentation of this file.
1 #ifndef SSTMAC_SOFTWARE_PROCESS_GRAPHVIZ_H
2 #define SSTMAC_SOFTWARE_PROCESS_GRAPHVIZ_H
3 
4 #define GraphVizAppendBacktrace(...) ::sstmac::sw::graph_viz_increment_stack __graphviz_tmp_variable__(__VA_ARGS__)
5 #define GraphVizDoNothing(...) int __graphviz_tmp_variable__
6 
9 
10 namespace sstmac {
11 namespace sw {
12 
13 
15 {
16  public:
17  /**
18  * @brief graph_viz_increment_stack
19  * Should only ever be called from app threads, not the DES thread
20  * @param The name of the function currently being invoked
21  * @param Optional boolean to turn off collection.
22  * There are certain cass where this might get called from
23  * the DES thread, which is an error. This allows
24  * the backtrace to be turned off on the DES thread
25  */
26  graph_viz_increment_stack(const char* fxn);
27 
29 
30 };
31 
32 class graph_viz :
33  public stat_collector
34 {
35  public:
36  graph_viz();
37 
38  std::string
39  to_string() const {
40  return "grahpviz";
41  }
42 
43  virtual ~graph_viz();
44 
45  void simulation_finished(timestamp end);
46 
47  void clear();
48 
49  void reduce(stat_collector *coll);
50 
51  void dump_local_data();
52 
53  void dump_global_data();
54 
55  graph_viz*
56  clone_me(int id) const {
57  graph_viz* cln = new graph_viz;
58  clone_into(cln);
59  cln->set_id(id);
60  return cln;
61  }
62 
63  void
64  global_reduce(parallel_runtime *rt);
65 
67  clone() const {
68  return clone_me(-1);
69  }
70 
71  static void** allocate_trace();
72 
73  static void delete_trace(void** tr);
74 
75  void count_trace(long count, sw::thread* thr);
76 
77  static void
78  delete_statics();
79 
80  private:
81  typedef std::pair<long, long long> graphviz_call;
82  class trace {
83 
84  private:
85  std::map<void*, graphviz_call> calls_;
86 
87  long long self_;
88 
89  void* fxn_;
90 
92 
93  public:
94  trace(graph_viz* parent, void* fxn);
95 
96  std::string
97  to_string() const {
98  return "graphviz trace";
99  }
100 
101  std::string
102  summary() const;
103 
104  void* fxn() const;
105 
106  void add_call(void* fxn, int ncalls, long count);
107 
108  void add_self(long count);
109 
110  };
111 
112  void add_call(int ncalls, long count, void* fxn, void* callfxn);
113 
114  std::map<void*, trace*> traces_;
115 
116  std::map<void*, std::string> ptr_to_fxn_;
117 
118  std::map<std::string, void*> fxn_to_ptr_;
119 
120  friend class trace;
121 
122  trace* get_trace(void* fxn);
123 
124 
125 };
126 
127 }
128 }
129 
130 
131 #endif // GRAPHVIZ_H
132 
std::string to_string() const
Definition: graphviz.h:97
stat_collector * clone() const
Definition: graphviz.h:67
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)
std::map< void *, trace * > traces_
Definition: graphviz.h:114
std::map< void *, std::string > ptr_to_fxn_
Definition: graphviz.h:116
std::map< std::string, void * > fxn_to_ptr_
Definition: graphviz.h:118
std::pair< long, long long > graphviz_call
Definition: graphviz.h:81
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...
graph_viz * clone_me(int id) const
Definition: graphviz.h:56
std::string to_string() const
Definition: graphviz.h:39
graph_viz_increment_stack(const char *fxn)
graph_viz_increment_stack Should only ever be called from app threads, not the DES thread ...
std::map< void *, graphviz_call > calls_
Definition: graphviz.h:85