1#include "gmock/gmock.h"
2#include "gtest/gtest.h"
4#include "Kokkos_Core.hpp"
27using namespace Kokkos::utils::callbacks;
32 static_assert( ! std::is_copy_constructible_v<Manager>);
33 static_assert( ! std::is_copy_assignable_v <Manager>);
35 static_assert( ! std::is_move_constructible_v<Manager>);
36 static_assert( ! std::is_move_assignable_v <Manager>);
115template <Event... EventTypes>
120 std::get<std::vector<EventType>>(
events).push_back(event);
123 std::tuple<std::vector<EventTypes>...>
events {};
129 const auto tester_listener = std::make_shared<TesterListener<BeginParallelForEvent, EndParallelForEvent, BeginFenceEvent>>();
137 const auto& [begin_parallel_for_events, end_parallel_for_events, begin_fence_events] = tester_listener->events;
140 ASSERT_EQ(begin_parallel_for_events.size(), 1);
141 ASSERT_EQ(begin_parallel_for_events[0].name,
"computation - level 0 - pfor");
144 ASSERT_EQ(end_parallel_for_events.size(), 1);
145 ASSERT_EQ(begin_parallel_for_events[0].event_id, end_parallel_for_events[0].event_id);
148 ASSERT_GT(begin_fence_events.size(), 2);
151 ::testing::Contains(::testing::Field(&
BeginFenceEvent::name, ::testing::StrEq(
"computation - level 0 - fence after pfor")))
155 ::testing::Contains(::testing::Field(&
BeginFenceEvent::name, ::testing::StrEq(
"other fence after stopping the profile section")))
162 const auto tester_listener_a = std::make_shared<TesterListener<BeginParallelForEvent>>();
163 const auto tester_listener_b = std::make_shared<TesterListener<BeginParallelForEvent, EndParallelForEvent>>();
173 const auto& [begin_parallel_for_events_listener_a] = tester_listener_a->events;
174 const auto& [begin_parallel_for_events_listener_b, end_parallel_for_events_listener_b] = tester_listener_b->events;
177 ASSERT_EQ(begin_parallel_for_events_listener_a.size(), 1);
178 ASSERT_EQ(begin_parallel_for_events_listener_a[0].name,
"computation - level 0 - pfor");
179 ASSERT_EQ(begin_parallel_for_events_listener_b.size(), 1);
180 ASSERT_EQ(begin_parallel_for_events_listener_b[0].name,
"computation - level 0 - pfor");
183 ASSERT_EQ(end_parallel_for_events_listener_b.size(), 1);
184 ASSERT_EQ(begin_parallel_for_events_listener_b[0].event_id, end_parallel_for_events_listener_b[0].event_id);
190 bool matched =
false;
192 using view_t = Kokkos::View<int, execution_space>;
194 const view_t my_src_view(Kokkos::view_alloc(Kokkos::WithoutInitializing, exec,
"my rank-0 src view"));
195 const view_t my_dst_view(Kokkos::view_alloc(Kokkos::WithoutInitializing, exec,
"my rank-0 dst view"));
199 if (event.
dst.
size ==
sizeof(
int) && event.
src.
ptr == my_src_view.data()
200 && event.
dst.
ptr == my_dst_view.data()) matched =
true;
204 Kokkos::deep_copy(exec, my_dst_view, my_src_view);
206 ASSERT_TRUE(matched);
Class to manage Kokkos profiling callback calls.
static void unregister_listener(const Callable *const callable)
Unregister a callable object as a listener.
static Manager & get_instance()
static bool is_initialized()
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.
Check if T is the same as one of the types Ts.
auto get_next_event_id() noexcept
If the Manager is initialized, return Manager::get_next_event_id. Otherwise, return EventTraits::inva...
void dispatch(const EventType &event)
If the Manager is initialized, call Manager::dispatch with event.
TEST_F(EnqueuedEventTimerTest, duration)
constexpr bool test_singleton_traits()
TEST(EventTest, BeginEvent)
Begin-deep-copy event associated with Kokkos::Tools::Experimental::EventSet::begin_deep_copy.
static constexpr event_id_t invalid_event_id
Profile event associated with Kokkos::Tools::Experimental::EventSet::profile_event.
void execute(const Exec &exec) const
Listener that stores the events it receives.
void operator()(const EventType &event)
std::tuple< std::vector< EventTypes >... > events
Create a new execution space instance with RAII semantics.
Initializing and finalizing Kokkos::utils::callbacks::Manager in a RAII manner.
Kokkos::DefaultExecutionSpace execution_space