1#include "gmock/gmock.h"
2#include "gtest/gtest.h"
25using namespace Kokkos::utils::callbacks;
30 static_assert(BeginEvent<BeginParallelForEvent>);
31 static_assert(BeginEvent<BeginParallelReduceEvent>);
32 static_assert(BeginEvent<BeginParallelScanEvent>);
33 static_assert(BeginEvent<BeginFenceEvent>);
35 static_assert( ! BeginEvent<EndParallelForEvent>);
37 static_assert( ! BeginEvent<PushRegionEvent>);
43 static_assert(EndEvent<EndParallelForEvent>);
44 static_assert(EndEvent<EndParallelReduceEvent>);
45 static_assert(EndEvent<EndParallelScanEvent>);
46 static_assert(EndEvent<EndFenceEvent>);
48 static_assert( ! EndEvent<BeginParallelForEvent>);
50 static_assert( ! EndEvent<PopRegionEvent>);
52 static_assert( ! EndEvent<StopProfileSectionEvent>);
58 static_assert(DataEvent<AllocateDataEvent>);
59 static_assert(DataEvent<DeallocateDataEvent>);
61 static_assert( ! DataEvent<PopRegionEvent>);
70 static_assert( ! ProfileSectionManipulationEvent<EndParallelForEvent>);
72 static_assert(ProfileSectionManipulationEvent<StartProfileSectionEvent>);
73 static_assert(ProfileSectionManipulationEvent<StopProfileSectionEvent>);
74 static_assert(ProfileSectionManipulationEvent<DestroyProfileSectionEvent>);
76 static_assert( ! ProfileSectionManipulationEvent<PushRegionEvent>);
77 static_assert( ! ProfileSectionManipulationEvent<PopRegionEvent>);
86 static_assert(NamedEvent<BeginParallelForEvent>);
87 static_assert(NamedEvent<BeginParallelReduceEvent>);
88 static_assert(NamedEvent<BeginParallelScanEvent>);
89 static_assert(NamedEvent<BeginFenceEvent>);
90 static_assert(NamedEvent<CreateProfileSectionEvent>);
91 static_assert(NamedEvent<PushRegionEvent>);
92 static_assert(NamedEvent<ProfileEvent>);
94 static_assert( ! NamedEvent<PopRegionEvent>);
100#define CHECK_GET_NAME(__type__) \
101 static_assert(get_name<__type__>() == #__type__);
115 static_assert(std::same_as<paired_event_t<BeginFenceEvent>,
EndFenceEvent>);
117 static_assert(std::same_as<paired_event_t<BeginDeepCopyEvent>,
EndDeepCopyEvent>);
120 static_assert(std::same_as<paired_event_t<PushRegionEvent>,
PopRegionEvent>);
126template <BeginEvent EventType>
129 EventType
event {.name =
"my begin event", .dev_id = 1, .event_id = 2};
130 std::string
expt_descr =
"{name = \"my begin event\", dev_id = 1, event_id = 2}";
133template <EndEvent EventType>
134struct EventTest<EventType> :
public ::testing::Test
136 EventType
event {.event_id = 1};
137 std::string expt_descr {
"{event_id = 1}"};
140template <DataEvent EventType>
141struct EventTest<EventType> :
public ::testing::Test
143 EventType
event {.alloc = {.kpsh = Kokkos::Profiling::make_space_handle(
"Host"), .name =
"my data event", .ptr =
reinterpret_cast<void*
>(0x7ffdbc161a70), .size = 2}};
144 std::string expt_descr {
"{name = \"my data event\", space = \"Host\", ptr = 0x7ffdbc161a70, size = 2}"};
151 .dst = {.kpsh = Kokkos::Profiling::make_space_handle(
"Cuda"), .name =
"my destination", .ptr =
reinterpret_cast<void*
>(0x7ffdbc161a80), .size = 2},
152 .src = {.kpsh = Kokkos::Profiling::make_space_handle(
"Host"), .name =
"my source", .ptr =
reinterpret_cast<void*
>(0x7ffdbc161a70), .size = 2}
154 std::string
expt_descr {
"{src = \"my source\" (Host, 0x7ffdbc161a70) -> dst = \"my destination\" (Cuda, 0x7ffdbc161a80) of size 2}"};
168 std::string
expt_descr {
"{name = \"my profile section\", section_id = 1}"};
171template <ProfileSectionManipulationEvent EventType>
172struct EventTest<EventType> :
public ::testing::Test
174 EventType
event {.section_id = 1};
175 std::string expt_descr {
"{section_id = 1}"};
182 std::string
expt_descr {
"{name = \"my push region event\"}"};
204 static_assert(Event<TypeParam>);
210 ASSERT_EQ(this->event, this->event);
216 static_assert(std::is_aggregate_v<TypeParam>);
217 static_assert(std::is_default_constructible_v<TypeParam>);
218 static_assert(std::movable<TypeParam>);
224 ASSERT_THAT([&event = this->event]{ std::stringstream oss; oss << event;
return oss.str(); }(), ::testing::StrEq(std::string(
get_name<TypeParam>()) +
": " + this->expt_descr));
237 const auto context_callbacks = Kokkos::Tools::Experimental::get_callbacks();
241 static_assert(std::same_as<std::remove_const_t<
decltype(context_callback)>, callback_fptr_t>);
246 const auto callback_to_register = [] <
typename... Args>(Args...) ->
void {};
247 static_assert(std::convertible_to<
decltype(callback_to_register), callback_fptr_t>);
constexpr auto get_name()
auto get_callback_from_eventset(const Kokkos::Tools::Experimental::EventSet &event_set)
auto get_callback_setter()
Get the setter function of a Kokkos profiling callback corresponding to EventType.
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(TimerTest, start_aborts_for_wrongly_enqueued_event)
TYPED_TEST_SUITE(TimerTest, TimerTypes)
TEST(EventTest, BeginEvent)
Begin-deep-copy event associated with Kokkos::Tools::Experimental::EventSet::begin_deep_copy.
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.
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-deep-copy event associated with Kokkos::Tools::Experimental::EventSet::end_deep_copy.
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.
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.
Stop-profile-section event associated with Kokkos::Tools::Experimental::EventSet::stop_profile_sectio...
#define CHECK_GET_NAME(__type__)
Kokkos::DefaultExecutionSpace execution_space