1#include "gmock/gmock.h"
2#include "gtest/gtest.h"
4#include "Kokkos_Core.hpp"
34using namespace Kokkos::utils::callbacks;
52 static_assert(Matcher <EventRegexMatcher>);
53 static_assert(MatcherFor<EventRegexMatcher, named_event_type_list_t>);
54 static_assert(std::movable<EventRegexMatcher>);
56 static_assert( ! MatcherFor<EventRegexMatcher, BeginDeepCopyEvent>);
67 ASSERT_TRUE( matcher(
AllocateDataEvent{.alloc = {.name =
"buried-allocation-to-time"}}));
68 ASSERT_FALSE(matcher(
AllocateDataEvent{.alloc = {.name =
"not-this-other-allocation"}}));
74 static_assert(Matcher <EventNameMatcher>);
75 static_assert(MatcherFor <EventNameMatcher, named_event_type_list_t>);
76 static_assert(std::movable<EventNameMatcher>);
85 ASSERT_TRUE (matcher(
AllocateDataEvent{.alloc = {.name =
"named-as-I-like-it"}}));
93 static_assert(Matcher <matcher_t>);
94 static_assert(MatcherFor <matcher_t, EventTypeList>);
95 static_assert(std::movable<matcher_t>);
101 constexpr uint32_t section_id = 2;
107 ASSERT_FALSE(matcher(
AllocateDataEvent{})) <<
"Expecting not to record the event before starting the section.";
111 ASSERT_TRUE(matcher(
AllocateDataEvent{})) <<
"Expecting to record the event inside the section.";
115 ASSERT_FALSE(matcher(
AllocateDataEvent{})) <<
"Expecting to record the event after stopping the section.";
125 static_assert(Matcher <matcher_t>);
126 static_assert(MatcherFor <matcher_t, EventTypeList>);
127 static_assert(std::movable<matcher_t>);
179 static_assert(Matcher <AnyEventMatcher>);
180 static_assert(MatcherFor <AnyEventMatcher, EventTypeList>);
181 static_assert(std::movable<AnyEventMatcher>);
190 static_assert(matcher(EventType{}));
199 static_assert(Matcher <matcher_t>);
200 static_assert(MatcherFor <matcher_t, BeginFenceEvent, PushRegionEvent>);
201 static_assert(std::same_as<matcher_event_type_list_t<matcher_t>, Kokkos::Impl::type_list<BeginFenceEvent, PushRegionEvent>>);
202 static_assert(std::movable<matcher_t>);
219 static_assert(Matcher <matcher_t>);
220 static_assert(MatcherFor <matcher_t, BeginParallelForEvent, EndParallelForEvent>);
221 static_assert(std::same_as<matcher_event_type_list_t<matcher_t>, Kokkos::Impl::type_list<BeginParallelForEvent, EndParallelForEvent>>);
222 static_assert(std::movable<matcher_t>);
242 using enqueued_event_type_list_t = Kokkos::Impl::type_list<
249 static_assert(Matcher <matcher_t>);
250 static_assert(std::same_as<matcher_event_type_list_t<matcher_t>, enqueued_event_type_list_t>);
251 static_assert(std::movable<matcher_t>);
257 const auto execs = Kokkos::Experimental::partition_space(
execution_space{}, 1, 1);
259 const auto dev_id_0 = Kokkos::Tools::Experimental::device_id(execs.at(0));
260 const auto dev_id_1 = Kokkos::Tools::Experimental::device_id(execs.at(1));
273 using indexed_event_type_list_t = Kokkos::Impl::type_list<
280 static_assert(Matcher <matcher_t>);
281 static_assert(std::same_as<matcher_event_type_list_t<matcher_t>, indexed_event_type_list_t>);
282 static_assert(std::movable<matcher_t>);
302 static_assert(Matcher <matcher_t>);
303 static_assert(MatcherFor <matcher_t, EventTypeList>);
304 static_assert(std::movable<matcher_t>);
341 static_assert(std::same_as<
351template <Matcher MatcherType>
373 matcher_t{{
"matcher-a"}},
374 matcher_t{{
"matcher-a"}},
375 matcher_t{{
"matcher-b"}},
376 matcher_t{{
"matcher-c"}}
379 ASSERT_FALSE(matcher(
BeginFenceEvent{.name =
"matcher-a", .event_id = 0}));
380 ASSERT_FALSE(matcher(
BeginFenceEvent{.name =
"matcher-a", .event_id = 1}));
381 ASSERT_FALSE(matcher(
BeginFenceEvent{.name =
"matcher-b", .event_id = 2}));
382 ASSERT_FALSE(matcher(
BeginFenceEvent{.name =
"matcher-c", .event_id = 3}));
385 ASSERT_THAT(std::get<0>(matcher.matchers).encountered, ::testing::ElementsAre(
393 ASSERT_THAT(std::get<1>(matcher.matchers).encountered, ::testing::ElementsAre(
399 ASSERT_THAT(std::get<2>(matcher.matchers).encountered, ::testing::ElementsAre(
405 ASSERT_THAT(std::get<3>(matcher.matchers).encountered, ::testing::IsEmpty());
Kokkos::Impl::filter_type_list_t< impl::IsMatcherFor< Callable >::template type, EventTypeList > matcher_event_type_list_t
Type list holding the event types that Callable can be a matcher for.
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)
Kokkos::Impl::type_list< BeginParallelForEvent, BeginParallelReduceEvent, BeginParallelScanEvent, BeginFenceEvent, AllocateDataEvent, DeallocateDataEvent, CreateProfileSectionEvent, PushRegionEvent, ProfileEvent > named_event_type_list_t
List of event types that have a name.
Allocate-data event associated with Kokkos::Tools::Experimental::EventSet::allocate_data.
Matcher that returns true for any event.
Begin-fence event associated with Kokkos::Tools::Experimental::EventSet::begin_fence.
Begin-parallel-reduce event associated with Kokkos::Tools::Experimental::EventSet::begin_parallel_red...
Begin-parallel-scan event associated with Kokkos::Tools::Experimental::EventSet::begin_parallel_scan.
Conjunction of matchers that is true only if all matchers agree.
Create-profile-section event associated with Kokkos::Tools::Experimental::EventSet::create_profile_se...
Deallocate-data event associated with Kokkos::Tools::Experimental::EventSet::deallocate_data.
Destroy-profile-section event associated with Kokkos::Tools::Experimental::EventSet::destroy_profile_...
End-fence event associated with Kokkos::Tools::Experimental::EventSet::end_fence.
End-parallel-for event associated with Kokkos::Tools::Experimental::EventSet::end_parallel_for.
End-parallel-reduce event associated with Kokkos::Tools::Experimental::EventSet::end_parallel_reduce.
End-parallel-scan event associated with Kokkos::Tools::Experimental::EventSet::end_parallel_scan.
Match a begin event and its corresponding end event based on their event_id.
Match an event whose event_id is event_id.
Matcher to select events that occur within a profile section.
Matcher to select events whose name matches name.
Match an event whose dev_id is the same as the one of exec.
Matcher to select events whose name matches a regular expression.
Matcher to select events that occur within a region.
Restrict the event types that can be matched by matcher to the subset EventTypes.
Pop-region event associated with Kokkos::Tools::Experimental::EventSet::pop_region.
Profile event associated with Kokkos::Tools::Experimental::EventSet::profile_event.
Push-region event associated with Kokkos::Tools::Experimental::EventSet::push_region.
Start-profile-section event associated with Kokkos::Tools::Experimental::EventSet::start_profile_sect...
Stop-profile-section event associated with Kokkos::Tools::Experimental::EventSet::stop_profile_sectio...
Helper matcher that records in encountered all the events passed to it.
std::vector< BeginFenceEvent > encountered
bool operator()(const BeginFenceEvent &event)
Kokkos::DefaultExecutionSpace execution_space