kokkos-utils 0.0.1
 
Loading...
Searching...
No Matches
SequenceOfRegionTimerListener.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_UTILS_CALLBACKS_SEQUENCEOFREGIONTIMERLISTENER_HPP
2#define KOKKOS_UTILS_CALLBACKS_SEQUENCEOFREGIONTIMERLISTENER_HPP
3
5
7{
17template <Matcher MatcherType>
19{
20public:
24
25 template <typename... Ms>
26 explicit SequenceOfRegionTimerListener(Ms&&... matchers_)
27 : matchers{std::forward<Ms>(matchers_)...},
28 timers(matchers.size())
29 {}
30
31 void reset() { current = 0; }
32
34 bool all_matched() const {
35 return current == timers.size();
36 }
37
39 void operator()(const PushRegionEvent& event)
40 {
41 if(all_matched()) return;
42
43 const auto matched = matchers.at(current).operator()(event);
44
45 if(matched)
46 timers.at(current).start();
47 }
48
50 void operator()(const PopRegionEvent& event)
51 {
52 if(all_matched()) return;
53
54 const auto matched = matchers.at(current).operator()(event);
55
56 if(matched)
57 {
58 timers.at(current).stop();
59 ++current;
60 }
61 }
62
63public:
64 std::vector<matcher_t> matchers;
65 std::vector<timer_t> timers;
66
67private:
68 size_t current = 0;
69};
70
71} // namespace Kokkos::utils::callbacks
72
73#endif // KOKKOS_UTILS_CALLBACKS_SEQUENCEOFREGIONTIMERLISTENER_HPP
Pop-region event associated with Kokkos::Tools::Experimental::EventSet::pop_region.
Definition Events.hpp:185
Push-region event associated with Kokkos::Tools::Experimental::EventSet::push_region.
Definition Events.hpp:177
Timer listener for a profiling region that matches MatcherType.
EventTypeMatcher< region_matcher_t, PushRegionEvent, PopRegionEvent > matcher_t
void operator()(const PushRegionEvent &event)
Deal with a Kokkos::utils::callbacks::PushRegionEvent event. Only the current timer is auditioned.
bool all_matched() const
Returns true if all regions were correctly matched and timed.
void operator()(const PopRegionEvent &event)
Deal with a Kokkos::utils::callbacks::PopRegionEvent event. If the current timer matches,...