kokkos-utils 0.0.1
 
Loading...
Searching...
No Matches
EventRegionMatcher.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_UTILS_CALLBACKS_EVENTREGIONMATCHER_HPP
2#define KOKKOS_UTILS_CALLBACKS_EVENTREGIONMATCHER_HPP
3
6
8{
9
21template <typename MatcherType, bool TrueOnBoundary = false> requires MatcherFor<MatcherType, PushRegionEvent>
23{
24 static constexpr uint32_t invalid_nested_level = Kokkos::Experimental::finite_max_v<uint32_t>;
25
27 bool operator()(const PushRegionEvent& event)
28 {
29 if (this->matching)
30 {
31 ++this->nested_level;
32 return ! TrueOnBoundary;
33 }
34 else if (matcher(event))
35 {
36 this->nested_level = 1;
37 this->matching = true;
38 return TrueOnBoundary;
39 }
40
41 return TrueOnBoundary ? false : this->matching;
42 }
43
46 {
47 if (this->matching)
48 {
49 --this->nested_level;
50
51 if (this->nested_level == 0)
52 {
53 this->matching = false;
54 return TrueOnBoundary;
55 }
56 }
57
58 return TrueOnBoundary ? false : this->matching;
59 }
60
61 template <Event EventType>
62 bool operator()(const EventType&) const {
63 return TrueOnBoundary ? false : this->matching;
64 }
65
66 MatcherType matcher {};
67 bool matching = false;
69};
70
71} // namespace Kokkos::utils::callbacks
72
73#endif // KOKKOS_UTILS_CALLBACKS_EVENTREGIONMATCHER_HPP
Check that Callable is a matcher for each event in EventTypes.
Definition Matcher.hpp:35
Matcher to select events that occur within a region.
bool operator()(const PushRegionEvent &event)
If the event matches matcher, matching is set to true.
bool operator()(const PopRegionEvent &)
Decrement nested_level if we are still matching.
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