1#include "gmock/gmock.h"
2#include "gtest/gtest.h"
4#include "Kokkos_Core.hpp"
31using namespace Kokkos::utils::callbacks;
45 static_assert(std::same_as<
50 static_assert(Listener <event_in_profile_section_recorder_t>);
51 static_assert(ListenerFor<event_in_profile_section_recorder_t, EventTypeList>);
52 static_assert(ListenerFor<event_in_profile_section_recorder_t, PushRegionEvent, PopRegionEvent>);
55template <Event EvenType>
65 static_assert(std::same_as<typename recorder_listener_t::event_type_list_t, Kokkos::Impl::type_list<TypeParam>>);
66 static_assert(std::same_as<typename recorder_listener_t::matcher_t, AnyEventMatcher>);
68 const auto recorder = std::make_shared<recorder_listener_t>();
73 ASSERT_EQ(recorder->recorded_events.size(), 0);
80 const auto recorder = std::make_shared<event_in_profile_section_recorder_t>(std::move(matcher));
82 const auto any_event_recorder = std::make_shared<RecorderListener<EventTypeList>>();
91 recorder->recorded_events,
96 recorder->recorded_events,
97 ContainsInOrder<
typename decltype(recorder->recorded_events)::value_type>(
114 ASSERT_GT(any_event_recorder->recorded_events.size(), recorder->recorded_events.size());
116 const auto fence_event_outside_profile_section =
ABeginFenceEventWithName(::testing::StrEq(
"other fence after stopping the profile section"));
119 recorder->recorded_events,
120 ::testing::Not(::testing::Contains(fence_event_outside_profile_section))
124 any_event_recorder->recorded_events,
125 ::testing::Contains(fence_event_outside_profile_section)
128 const auto output = [&recorder] () -> std::string {
129 std::ostringstream oss;
130 recorder->report(oss);
134 ASSERT_THAT(output, ::testing::HasSubstr(
"computation - level 0 - pfor"));
135 ASSERT_THAT(output, ::testing::HasSubstr(
"computation - level 0 - fence after pfor"));
159 ::testing::FieldsAre(::testing::StrEq(
"computation - level 0 - pfor"), ::testing::Eq(Kokkos::Tools::Experimental::device_id(this->exec)), ::testing::_)
172 static_assert(std::same_as<
174 Kokkos::Impl::type_list<BeginFenceEvent>
177 static_assert(Listener<fence_finder_t>);
183 const auto exec = Kokkos::Experimental::partition_space(
execution_space{}, 1)[0];
185 const auto fence_finder = std::make_shared<fence_finder_t>(
EventRegexMatcher(std::regex(
"computation - level 0 - fence after pfor")));
193 fence_finder->recorded_events,
196 ::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 Callable 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)
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...
TEST_F(EnqueuedEventTimerTest, duration)
TYPED_TEST(TimerTest, start_aborts_for_wrongly_enqueued_event)
RecorderListener< EventInProfileSectionMatcher< EventRegexMatcher >, EventTypeList > event_in_profile_section_recorder_t
Listener to record events that occur in a profile section.
TYPED_TEST_SUITE(TimerTest, TimerTypes)
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
Create a new execution space instance with RAII semantics.
Initializing and finalizing Kokkos::utils::callbacks::Manager in a RAII manner.
Kokkos::DefaultExecutionSpace execution_space