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__);
112template <BeginEvent EventType>
115 EventType
event {.name =
"my begin event", .dev_id = 1, .event_id = 2};
116 std::string
expt_descr =
"{name = \"my begin event\", dev_id = 1, event_id = 2}";
119template <EndEvent EventType>
120struct EventTest<EventType> :
public ::testing::Test
122 EventType
event {.event_id = 1};
123 std::string expt_descr {
"{event_id = 1}"};
126template <DataEvent EventType>
127struct EventTest<EventType> :
public ::testing::Test
129 EventType
event {.alloc = {.kpsh = Kokkos::Profiling::make_space_handle(
"Host"), .name =
"my data event", .ptr =
reinterpret_cast<void*
>(0x7ffdbc161a70), .size = 2}};
130 std::string expt_descr {
"{name = \"my data event\", space = \"Host\", ptr = 0x7ffdbc161a70, size = 2}"};
137 .dst = {.kpsh = Kokkos::Profiling::make_space_handle(
"Cuda"), .name =
"my destination", .ptr =
reinterpret_cast<void*
>(0x7ffdbc161a80), .size = 2},
138 .src = {.kpsh = Kokkos::Profiling::make_space_handle(
"Host"), .name =
"my source", .ptr =
reinterpret_cast<void*
>(0x7ffdbc161a70), .size = 2}
140 std::string
expt_descr {
"{src = \"my source\" (Host, 0x7ffdbc161a70) -> dst = \"my destination\" (Cuda, 0x7ffdbc161a80) of size 2}"};
154 std::string
expt_descr {
"{name = \"my profile section\", section_id = 1}"};
157template <ProfileSectionManipulationEvent EventType>
158struct EventTest<EventType> :
public ::testing::Test
160 EventType
event {.section_id = 1};
161 std::string expt_descr {
"{section_id = 1}"};
168 std::string
expt_descr {
"{name = \"my push region event\"}"};
190 static_assert(Event<TypeParam>);
196 static_assert(std::is_aggregate_v<TypeParam>);
197 static_assert(std::is_default_constructible_v<TypeParam>);
198 static_assert(std::movable<TypeParam>);
204 ASSERT_THAT([&event = this->event]{ std::stringstream oss; oss << event;
return oss.str(); }(), ::testing::StrEq(std::string(
get_name<TypeParam>()) +
": " + this->expt_descr));
217 const auto context_callbacks = Kokkos::Tools::Experimental::get_callbacks();
221 static_assert(std::same_as<std::remove_const_t<
decltype(context_callback)>, callback_fptr_t>);
226 const auto callback_to_register = [] <
typename... Args>(Args...) ->
void {};
227 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.
TYPED_TEST(EventTest, concept)
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_SUITE(EventTest, EventTestTypes)
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...
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.
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.
#define CHECK_GET_NAME(__type__)
Kokkos::DefaultExecutionSpace execution_space