1#include "gmock/gmock.h"
2#include "gtest/gtest.h"
4#include "Kokkos_Macros.hpp"
5#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
8#include "Kokkos_Core.hpp"
39using namespace Kokkos::utils::callbacks;
58 static_assert(Matcher <EventRegexMatcher>);
59 static_assert(MatcherFor<EventRegexMatcher, named_event_type_list_t>);
60 static_assert(std::movable<EventRegexMatcher>);
62 static_assert( ! MatcherFor<EventRegexMatcher, BeginDeepCopyEvent>);
73 ASSERT_TRUE( matcher(
AllocateDataEvent{.alloc = {.name =
"buried-allocation-to-time"}}));
74 ASSERT_FALSE(matcher(
AllocateDataEvent{.alloc = {.name =
"not-this-other-allocation"}}));
80 static_assert(Matcher <EventNameMatcher>);
81 static_assert(MatcherFor <EventNameMatcher, named_event_type_list_t>);
82 static_assert(std::movable<EventNameMatcher>);
91 ASSERT_TRUE (matcher(
AllocateDataEvent{.alloc = {.name =
"named-as-I-like-it"}}));
99 static_assert(Matcher <matcher_t>);
100 static_assert(MatcherFor <matcher_t, EventTypeList>);
101 static_assert(std::movable<matcher_t>);
107 constexpr uint32_t section_id = 2;
113 ASSERT_FALSE(matcher(
AllocateDataEvent{})) <<
"Expecting not to record the event before starting the section.";
117 ASSERT_TRUE(matcher(
AllocateDataEvent{})) <<
"Expecting to record the event inside the section.";
121 ASSERT_FALSE(matcher(
AllocateDataEvent{})) <<
"Expecting to record the event after stopping the section.";
131 static_assert(Matcher <matcher_t>);
132 static_assert(MatcherFor <matcher_t, EventTypeList>);
133 static_assert(std::movable<matcher_t>);
185 static_assert(Matcher <AnyEventMatcher>);
186 static_assert(MatcherFor <AnyEventMatcher, EventTypeList>);
187 static_assert(std::movable<AnyEventMatcher>);
196 static_assert(matcher(EventType{}));
205 static_assert(Matcher <matcher_t>);
206 static_assert(MatcherFor <matcher_t, BeginFenceEvent, PushRegionEvent>);
207 static_assert(std::same_as<matcher_event_type_list_t<matcher_t>, Kokkos::Impl::type_list<BeginFenceEvent, PushRegionEvent>>);
208 static_assert(std::movable<matcher_t>);
225 static_assert(Matcher <matcher_t>);
226 static_assert(MatcherFor <matcher_t, BeginParallelForEvent, EndParallelForEvent>);
227 static_assert(std::same_as<matcher_event_type_list_t<matcher_t>, Kokkos::Impl::type_list<BeginParallelForEvent, EndParallelForEvent>>);
228 static_assert(std::movable<matcher_t>);
248 using enqueued_event_type_list_t = Kokkos::Impl::type_list<
256 static_assert(Matcher <matcher_t>);
257 static_assert(std::same_as<matcher_event_type_list_t<matcher_t>, enqueued_event_type_list_t>);
258 static_assert(std::movable<matcher_t>);
264 const auto execs = Kokkos::Experimental::partition_space(
execution_space{}, 1, 1);
266 const auto dev_id_0 = Kokkos::Tools::Experimental::device_id(execs.at(0));
267 const auto dev_id_1 = Kokkos::Tools::Experimental::device_id(execs.at(1));
280 using indexed_event_type_list_t = Kokkos::Impl::type_list<
288 static_assert(Matcher <matcher_t>);
289 static_assert(std::same_as<matcher_event_type_list_t<matcher_t>, indexed_event_type_list_t>);
290 static_assert(std::movable<matcher_t>);
310 static_assert(Matcher <matcher_t>);
311 static_assert(MatcherFor <matcher_t, EventTypeList>);
312 static_assert(std::movable<matcher_t>);
349 static_assert(std::same_as<
363 static_assert(std::default_initializable<matcher_t>);
367template <Matcher MatcherType>
389 matcher_t{{
"matcher-a"}},
390 matcher_t{{
"matcher-a"}},
391 matcher_t{{
"matcher-b"}},
392 matcher_t{{
"matcher-c"}}
395 ASSERT_FALSE(matcher(
BeginFenceEvent{.name =
"matcher-a", .event_id = 0}));
396 ASSERT_FALSE(matcher(
BeginFenceEvent{.name =
"matcher-a", .event_id = 1}));
397 ASSERT_FALSE(matcher(
BeginFenceEvent{.name =
"matcher-b", .event_id = 2}));
398 ASSERT_FALSE(matcher(
BeginFenceEvent{.name =
"matcher-c", .event_id = 3}));
401 ASSERT_THAT(std::get<0>(matcher.
matchers).encountered, ::testing::ElementsAre(
409 ASSERT_THAT(std::get<1>(matcher.
matchers).encountered, ::testing::ElementsAre(
415 ASSERT_THAT(std::get<2>(matcher.
matchers).encountered, ::testing::ElementsAre(
421 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...
Kokkos::Impl::type_list< BeginParallelForEvent, BeginParallelReduceEvent, BeginParallelScanEvent, BeginSingleEvent, BeginFenceEvent, AllocateDataEvent, DeallocateDataEvent, CreateProfileSectionEvent, PushRegionEvent, ProfileEvent > named_event_type_list_t
List of event types that have a name.
TEST(EventTest, BeginEvent)
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.
Begin-single event associated with Kokkos::Tools::Experimental::EventSet::begin_single.
Conjunction of matchers that is true only if all matchers agree.
std::tuple< MatcherTypes... > matchers
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.
End-single event associated with Kokkos::Tools::Experimental::EventSet::end_single.
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