kokkos-utils 0.0.1
 
Loading...
Searching...
No Matches
test_Matchers.cpp
Go to the documentation of this file.
1#include "gtest/gtest.h"
2
3#include "Kokkos_Core.hpp"
4
6
10
20
21using execution_space = Kokkos::DefaultExecutionSpace;
22
24{
25using namespace Kokkos::utils::callbacks;
26
29{
30 static_assert(Matcher<EventRegexMatcher, Kokkos::Impl::type_list<
40 >>);
41 static_assert(std::movable<EventRegexMatcher>);
42
43 static_assert( ! Matcher<EventRegexMatcher, BeginDeepCopyEvent>);
44
45 static_assert( ! Matcher<EventRegexMatcher, Kokkos::Impl::type_list<>>);
46}
47
49TEST(EventRegexMatcher, regex_matcher)
50{
51 const EventRegexMatcher matcher{.regex = std::regex("buried-[a-z]+-to-time")};
52
53 ASSERT_TRUE( matcher(BeginParallelForEvent{.name = "buried-kernel-to-time", .event_id = 2}));
54 ASSERT_FALSE(matcher(BeginParallelForEvent{.name = "not-this-other-kernel", .event_id = 2}));
55
56 ASSERT_TRUE( matcher(AllocateDataEvent{.alloc = {.name = "buried-allocation-to-time"}}));
57 ASSERT_FALSE(matcher(AllocateDataEvent{.alloc = {.name = "not-this-other-allocation"}}));
58}
59
62{
63 static_assert(Matcher<EventInProfileSectionRegexMatcher, EventTypeList>);
64 static_assert(std::movable<EventInProfileSectionRegexMatcher>);
65}
66
68TEST(EventInProfileSectionRegexMatcher, in_profile_section_matcher)
69{
70 constexpr uint32_t section_id = 2;
71
72 EventInProfileSectionRegexMatcher matcher(std::regex("buried-profile-section"));
73
74 ASSERT_FALSE(matcher(CreateProfileSectionEvent{.name = "buried-profile-section", .section_id = section_id}));
75
76 ASSERT_FALSE(matcher(AllocateDataEvent{})) << "Expecting not to record the event before starting the region.";
77
78 ASSERT_FALSE(matcher(StartProfileSectionEvent{.section_id = section_id}));
79
80 ASSERT_TRUE(matcher(AllocateDataEvent{})) << "Expecting to record the event inside the region.";
81
82 ASSERT_FALSE(matcher(StopProfileSectionEvent{.section_id = section_id}));
83
84 ASSERT_FALSE(matcher(AllocateDataEvent{})) << "Expecting to record the event after stopping the region.";
85
86 ASSERT_FALSE(matcher(DestroyProfileSectionEvent{.section_id = section_id}));
87}
88
91{
92 static_assert(Matcher<AnyEventMatcher, EventTypeList>);
93 static_assert(std::movable<AnyEventMatcher>);
94}
95
97TEST(AnyEventMatcher, operator_parentheses)
98{
99 AnyEventMatcher matcher;
100
101 Kokkos::utils::impl::for_each<EventTypeList>([&] <Event EventType>() {
102 static_assert(matcher(EventType{}));
103 });
104}
105
106} // namespace Kokkos::utils::tests::callbacks
constexpr void for_each(Callable callable)
Calls the instantiation of the call operator of a callable object for each type in a Kokkos::Impl::ty...
TEST(EventTest, BeginEvent)
Allocate-data event associated with Kokkos::Tools::Experimental::EventSet::allocate_data.
Definition Events.hpp:90
Matcher that returns true for any event.
Definition Matcher.hpp:33
Begin-fence event associated with Kokkos::Tools::Experimental::EventSet::begin_fence.
Definition Events.hpp:67
Begin-parallel-reduce event associated with Kokkos::Tools::Experimental::EventSet::begin_parallel_red...
Definition Events.hpp:39
Begin-parallel-scan event associated with Kokkos::Tools::Experimental::EventSet::begin_parallel_scan.
Definition Events.hpp:53
Create-profile-section event associated with Kokkos::Tools::Experimental::EventSet::create_profile_se...
Definition Events.hpp:112
Deallocate-data event associated with Kokkos::Tools::Experimental::EventSet::deallocate_data.
Definition Events.hpp:96
Destroy-profile-section event associated with Kokkos::Tools::Experimental::EventSet::destroy_profile_...
Definition Events.hpp:131
Matcher to select events that occur within a profile section.
Matcher to select events whose name matches a regular expression.
Profile event associated with Kokkos::Tools::Experimental::EventSet::profile_event.
Definition Events.hpp:146
Push-region event associated with Kokkos::Tools::Experimental::EventSet::push_region.
Definition Events.hpp:137
Start-profile-section event associated with Kokkos::Tools::Experimental::EventSet::start_profile_sect...
Definition Events.hpp:119
Stop-profile-section event associated with Kokkos::Tools::Experimental::EventSet::stop_profile_sectio...
Definition Events.hpp:125
Kokkos::DefaultExecutionSpace execution_space