Itoyori  v0.0.1
prof_events.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "ityr/common/util.hpp"
8 
9 namespace ityr::ito {
10 
12  using prof_event_target_base::prof_event_target_base;
13 
17  bool success) {
18  do_acc(t - ibd, success);
19  }
20 
24  bool success) {
25  MLOG_END(&state_.trace_md, 0, ibd, trace_decoder_base, this, t, success);
26  }
27 
28  void* trace_decoder(FILE* stream, void* buf0, void* buf1) override {
30  auto target_rank = MLOG_READ_ARG(&buf0, common::topology::rank_t);
32  auto success = MLOG_READ_ARG(&buf1, bool);
33 
34  do_acc(t1 - t0, success);
35 
36  success_mode_ = success;
37  auto rank = common::topology::my_rank();
38  fprintf(stream, "%d,%lu,%d,%lu,%s,target=%d\n", rank, t0, rank, t1, str().c_str(), target_rank);
39  return buf1;
40  }
41 
42  std::string str() const override {
43  return success_mode_ ? "sched_steal (success)" : "sched_steal (fail)";
44  }
45 
46  void print_stats() override {
47  success_mode_ = true;
48  sum_time_ = sum_time_success_;
49  max_time_ = max_time_success_;
50  count_ = count_success_;
52  success_mode_ = false;
53  sum_time_ = sum_time_fail_;
54  max_time_ = max_time_fail_;
55  count_ = count_fail_;
57  }
58 
59  void clear() override {
60  sum_time_success_ = 0;
61  sum_time_fail_ = 0;
62  max_time_success_ = 0;
63  max_time_fail_ = 0;
64  count_success_ = 0;
65  count_fail_ = 0;
66  }
67 
68 private:
69  void do_acc(common::wallclock::wallclock_t t, bool success) {
70  if (success) {
71  sum_time_success_ += t;
72  max_time_success_ = std::max(max_time_success_, t);
73  count_success_++;
74  } else {
75  sum_time_fail_ += t;
76  max_time_fail_ = std::max(max_time_fail_, t);
77  count_fail_++;
78  }
79  }
80 
81  common::wallclock::wallclock_t sum_time_success_ = 0;
82  common::wallclock::wallclock_t sum_time_fail_ = 0;
83  common::wallclock::wallclock_t max_time_success_ = 0;
84  common::wallclock::wallclock_t max_time_fail_ = 0;
85  counter_t count_success_ = 0;
86  counter_t count_fail_ = 0;
87  bool success_mode_;
88 };
89 
91  using prof_event_target_base::prof_event_target_base;
92  std::string str() const override { return "sched_mailbox_put"; }
93 };
94 
96  using event::event;
97  std::string str() const override { return "sched_adws_scan_tree"; }
98 };
99 
101  using event::event;
102  std::string str() const override { return "wsqueue_push"; }
103 };
104 
106  using event::event;
107  std::string str() const override { return "wsqueue_pop"; }
108 };
109 
111  using prof_event_target_base::prof_event_target_base;
112  std::string str() const override { return "wsqueue_steal_nolock"; }
113 };
114 
116  using prof_event_target_base::prof_event_target_base;
117  std::string str() const override { return "wsqueue_steal_abort"; }
118 };
119 
121  using prof_event_target_base::prof_event_target_base;
122  std::string str() const override { return "wsqueue_pass"; }
123 };
124 
126  using prof_event_target_base::prof_event_target_base;
127  std::string str() const override { return "wsqueue_empty"; }
128 };
129 
131  using prof_event_target_base::prof_event_target_base;
132  std::string str() const override { return "wsqueue_empty_batch"; }
133 };
134 
136  using event::event;
137  std::string str() const override { return "P_sched_loop"; }
138 };
139 
141  using event::event;
142  std::string str() const override { return "P_sched_fork"; }
143 };
144 
146  using event::event;
147  std::string str() const override { return "P_sched_join"; }
148 };
149 
151  using event::event;
152  std::string str() const override { return "P_sched_die"; }
153 };
154 
156  using event::event;
157  std::string str() const override { return "P_sched_migrate"; }
158 };
159 
161  using event::event;
162  std::string str() const override { return "P_sched_evacuate"; }
163 };
164 
166  using event::event;
167  std::string str() const override { return "P_sched_resume_popped"; }
168 };
169 
171  using event::event;
172  std::string str() const override { return "P_sched_resume_join"; }
173 };
174 
176  using event::event;
177  std::string str() const override { return "P_sched_resume_stolen"; }
178 };
179 
181  using event::event;
182  std::string str() const override { return "P_sched_resume_migrate"; }
183 };
184 
186  using event::event;
187  std::string str() const override { return "P_sched_start_new"; }
188 };
189 
191  using event::event;
192  std::string str() const override { return "P_cb_drift_fork"; }
193 };
194 
196  using event::event;
197  std::string str() const override { return "P_cb_drift_die"; }
198 };
199 
201  using event::event;
202  std::string str() const override { return "P_cb_pre_suspend"; }
203 };
204 
206  using event::event;
207  std::string str() const override { return "P_cb_post_suspend"; }
208 };
209 
211  using event::event;
212  std::string str() const override { return "P_thread"; }
213 };
214 
216  using event::event;
217  std::string str() const override { return "P_spmd"; }
218 };
219 
220 class prof_events {
221 public:
223 
224 private:
252 };
253 
254 }
Definition: profiler.hpp:264
Definition: profiler.hpp:53
profiler_state & state_
Definition: profiler.hpp:168
virtual void print_stats()
Definition: profiler.hpp:104
uint64_t counter_t
Definition: profiler.hpp:145
static void * trace_decoder_base(FILE *stream, int, int, void *buf0, void *buf1)
Definition: profiler.hpp:80
wallclock::wallclock_t sum_time_
Definition: profiler.hpp:169
counter_t count_
Definition: profiler.hpp:171
wallclock::wallclock_t max_time_
Definition: profiler.hpp:170
Definition: prof_events.hpp:220
prof_events()
Definition: prof_events.hpp:222
#define ITYR_ANON_VAR
Definition: util.hpp:55
int rank_t
Definition: topology.hpp:12
rank_t my_rank()
Definition: topology.hpp:207
uint64_t wallclock_t
Definition: wallclock.hpp:13
fprintf(stderr, "\x1b[31m%s\x1b[39m\n", msg)
Definition: aarch64.hpp:5
monoid< T, max_functor<>, lowest< T > > max
Definition: reducer.hpp:104
#define MLOG_READ_ARG(buf, type)
Definition: profiler.hpp:19
#define MLOG_END(...)
Definition: profiler.hpp:18
Definition: prof_events.hpp:10
Definition: profiler.hpp:37
wallclock::wallclock_t interval_begin_data
Definition: profiler.hpp:38
Definition: profiler.hpp:41
void * interval_begin_data
Definition: profiler.hpp:42
mlog_data_t trace_md
Definition: profiler.hpp:50
Definition: prof_events.hpp:95
std::string str() const override
Definition: prof_events.hpp:97
Definition: prof_events.hpp:90
std::string str() const override
Definition: prof_events.hpp:92
Definition: prof_events.hpp:11
void * trace_decoder(FILE *stream, void *buf0, void *buf1) override
Definition: prof_events.hpp:28
void interval_end(common::profiler::mode_stats, common::wallclock::wallclock_t t, common::profiler::mode_stats::interval_begin_data ibd, bool success)
Definition: prof_events.hpp:14
std::string str() const override
Definition: prof_events.hpp:42
void interval_end(common::profiler::mode_trace, common::wallclock::wallclock_t t, common::profiler::mode_trace::interval_begin_data ibd, bool success)
Definition: prof_events.hpp:21
void print_stats() override
Definition: prof_events.hpp:46
void clear() override
Definition: prof_events.hpp:59
Definition: prof_events.hpp:130
std::string str() const override
Definition: prof_events.hpp:132
Definition: prof_events.hpp:125
std::string str() const override
Definition: prof_events.hpp:127
Definition: prof_events.hpp:120
std::string str() const override
Definition: prof_events.hpp:122
Definition: prof_events.hpp:105
std::string str() const override
Definition: prof_events.hpp:107
Definition: prof_events.hpp:100
std::string str() const override
Definition: prof_events.hpp:102
Definition: prof_events.hpp:115
std::string str() const override
Definition: prof_events.hpp:117
Definition: prof_events.hpp:110
std::string str() const override
Definition: prof_events.hpp:112
Definition: prof_events.hpp:195
std::string str() const override
Definition: prof_events.hpp:197
Definition: prof_events.hpp:190
std::string str() const override
Definition: prof_events.hpp:192
Definition: prof_events.hpp:205
std::string str() const override
Definition: prof_events.hpp:207
Definition: prof_events.hpp:200
std::string str() const override
Definition: prof_events.hpp:202
Definition: prof_events.hpp:150
std::string str() const override
Definition: prof_events.hpp:152
Definition: prof_events.hpp:160
std::string str() const override
Definition: prof_events.hpp:162
Definition: prof_events.hpp:140
std::string str() const override
Definition: prof_events.hpp:142
Definition: prof_events.hpp:145
std::string str() const override
Definition: prof_events.hpp:147
Definition: prof_events.hpp:135
std::string str() const override
Definition: prof_events.hpp:137
Definition: prof_events.hpp:155
std::string str() const override
Definition: prof_events.hpp:157
Definition: prof_events.hpp:170
std::string str() const override
Definition: prof_events.hpp:172
Definition: prof_events.hpp:180
std::string str() const override
Definition: prof_events.hpp:182
Definition: prof_events.hpp:165
std::string str() const override
Definition: prof_events.hpp:167
Definition: prof_events.hpp:175
std::string str() const override
Definition: prof_events.hpp:177
Definition: prof_events.hpp:185
std::string str() const override
Definition: prof_events.hpp:187
Definition: prof_events.hpp:215
std::string str() const override
Definition: prof_events.hpp:217
Definition: prof_events.hpp:210
std::string str() const override
Definition: prof_events.hpp:212