1#include "gmock/gmock.h"
2#include "gtest/gtest.h"
4#include "Kokkos_Core.hpp"
30using namespace Kokkos::utils::callbacks;
50 static_assert(std::same_as<
55 static_assert(Listener<event_in_profile_section_recorder_t>);
58template <Event EvenType>
67 static_assert(std::same_as<typename recorder_listener_t::event_type_list_t, Kokkos::Impl::type_list<TypeParam>>);
68 static_assert(std::same_as<typename recorder_listener_t::matcher_t, AnyEventMatcher>);
70 const auto recorder = std::make_shared<recorder_listener_t>();
75 ASSERT_EQ(recorder->recorded_events.size(), 0);
82 const auto recorder = std::make_shared<event_in_profile_section_recorder_t>(std::move(matcher));
84 const auto any_event_recorder = std::make_shared<RecorderListener<EventTypeList>>();
93 recorder->recorded_events,
98 recorder->recorded_events,
99 ContainsInOrder<
typename decltype(recorder->recorded_events)::value_type>(
116 ASSERT_GT(any_event_recorder->recorded_events.size(), recorder->recorded_events.size());
118 const auto fence_event_outside_profile_section =
ABeginFenceEventWithName(::testing::StrEq(
"other fence after stopping the profile section"));
121 recorder->recorded_events,
122 ::testing::Not(::testing::Contains(fence_event_outside_profile_section))
126 any_event_recorder->recorded_events,
127 ::testing::Contains(fence_event_outside_profile_section)
130 const auto output = [&recorder] () -> std::string {
131 std::ostringstream oss;
132 recorder->report(oss);
136 ASSERT_THAT(output, ::testing::HasSubstr(
"computation - level 0 - pfor"));
137 ASSERT_THAT(output, ::testing::HasSubstr(
"computation - level 0 - fence after pfor"));
161 ::testing::FieldsAre(::testing::StrEq(
"computation - level 0 - pfor"), ::testing::Eq(Kokkos::Tools::Experimental::device_id(this->exec)), ::testing::_)
174 static_assert(std::same_as<
176 Kokkos::Impl::type_list<BeginFenceEvent>
179 static_assert(Listener<fence_finder_t>);
185 const auto exec = Kokkos::Experimental::partition_space(
execution_space{}, 1)[0];
187 const auto fence_finder = std::make_shared<fence_finder_t>(
EventRegexMatcher(std::regex(
"computation - level 0 - fence after pfor")));
195 fence_finder->recorded_events,
198 ::testing::Field(&
BeginFenceEvent::name, ::testing::StrEq(
"computation - level 0 - fence after pfor")),
static void unregister_listener(const Callable *const callable)
Unregister a callable object as a listener.
static listener_list_const_iter_t register_listener(std::shared_ptr< Callable > callable)
Register a callable object, passed as a shared pointer, as a listener.
#define TEST_F_WITH_CB_MGR(__test_fixture_name__, __test_name__)
auto APopRegionEvent(Matchers &&... matchers)
auto AEndParallelReduceEvent(Matchers &&... matchers)
auto ABeginParallelForEvent(Matchers &&... matchers)
auto ABeginParallelForEventWithName(Matcher &&matcher)
Kokkos::Impl::filter_type_list_t< impl::IsListenerFor< Callable >::template type, EventTypeList > listener_event_type_list_t
Type list holding the event types that a callable object can be a listener for.
auto APushRegionEventWithName(Matcher &&matcher)
auto AEndFenceEvent(Matchers &&... matchers)
auto ABeginParallelReduceEventWithName(Matcher &&matcher)
Kokkos::Impl::type_list< BeginParallelForEvent, EndParallelForEvent, BeginParallelReduceEvent, EndParallelReduceEvent, BeginParallelScanEvent, EndParallelScanEvent, BeginFenceEvent, EndFenceEvent, AllocateDataEvent, DeallocateDataEvent, BeginDeepCopyEvent, EndDeepCopyEvent, CreateProfileSectionEvent, DestroyProfileSectionEvent, StartProfileSectionEvent, StopProfileSectionEvent, PushRegionEvent, PopRegionEvent, ProfileEvent > EventTypeList
Type list holding all event types.
auto AProfileEventWithName(Matcher &&matcher)
auto ABeginFenceEventWithName(Matcher &&matcher)
auto ABeginFenceEvent(Matchers &&... matchers)
auto ContainsInOrder(Matchers &&... matchers)
auto AEndParallelForEvent(Matchers &&... matchers)
TYPED_TEST(EventTest, concept)
typename impl::EventTestTypes< Kokkos::utils::callbacks::EventTypeList >::type EventTestTypes
Useful type for defining a typed test suite over all types in Kokkos::utils::callbacks::EventTypeList...
TYPED_TEST_SUITE(EventTest, EventTestTypes)
TEST_F(ManagerTest, dispatch_to_call_operators_of_single_listener)
RecorderListener< EventInProfileSectionRegexMatcher, EventTypeList > event_in_profile_section_recorder_t
Listener to record events that occur in a profile section.
RecorderListener< EventRegexMatcher, BeginFenceEvent > fence_finder_t
Listener to record fence events.
TEST(EventTest, BeginEvent)
Matcher to select events that occur within a profile section.
Matcher to select events whose name matches a regular expression.
void execute(const Exec &exec) const
Kokkos::DefaultExecutionSpace execution_space