kokkos-execution 0.0.1
Loading...
Searching...
No Matches
test_events.cpp
Go to the documentation of this file.
1#include "gmock/gmock.h"
2#include "gtest/gtest.h"
3
6
8
11
22
23#if !defined(KOKKOS_EXECUTION_ENABLE_EVENT_DISPATCH)
24# error "This is not supported."
25#endif
26
27namespace Tests::GraphImpl {
28
29using namespace Kokkos::utils::callbacks;
30
44
46consteval bool test_noexcept() {
47 static_assert(
48 noexcept(Kokkos::Execution::GraphImpl::get_graph_impl_ptr(std::declval<const EventsTest::graph_t::root_t&>())));
49 static_assert(
50 noexcept(Kokkos::Execution::GraphImpl::get_node_ptr(std::declval<const EventsTest::graph_t::root_t&>())));
51
52 static_assert(
53 !noexcept(Kokkos::Execution::GraphImpl::graph_create_event(std::declval<const EventsTest::graph_t&>())));
54 static_assert(
55 !noexcept(Kokkos::Execution::GraphImpl::create_graph(std::declval<const EventsTest::device_handle_t&>())));
56
58 std::declval<const EventsTest::graph_t::root_t&>(),
59 std::declval<const EventsTest::graph_t::root_t&>(),
60 std::declval<const EventsTest::device_handle_t&>())));
61
62 static_assert(
63 !noexcept(Kokkos::Execution::GraphImpl::graph_instantiate_event(std::declval<const EventsTest::graph_t&>())));
64
66 std::declval<const EventsTest::graph_t&>(), std::declval<const TEST_EXECUTION_SPACE&>())));
67
68 static_assert(!noexcept(Kokkos::Execution::GraphImpl::submit_graph(
69 std::declval<const EventsTest::graph_t&>(), std::declval<const TEST_EXECUTION_SPACE&>())));
70
71 return true;
72}
73static_assert(test_noexcept());
74
76TEST_F(EventsTest, create_instantiate_and_submit) {
77 const auto recorded_events = recorder_listener_t::record([this]() {
79
80 graph.instantiate();
82
84 });
85 ASSERT_THAT(
86 recorded_events,
87 testing::ElementsAre(
89 MATCHER_FOR_GRAPH_INSTANTIATE(recorded_events.at(0)),
90 MATCHER_FOR_GRAPH_SUBMIT(exec, recorded_events.at(0))));
91}
92
94TEST_F(EventsTest, create_and_add_nodes) {
95 const auto recorded_events = recorder_listener_t::record([this]() {
96 const graph_t graph{device_handle};
98
99 const auto root = graph.root_node();
100
101 const auto node_A = root.then(Kokkos::Experimental::node_props(device_handle), KOKKOS_LAMBDA(){});
103
104 const auto node_B = node_A.then(Kokkos::Experimental::node_props(device_handle), KOKKOS_LAMBDA(){});
106 });
107 ASSERT_THAT(
108 recorded_events,
109 testing::ElementsAre(
111 MATCHER_FOR_GRAPH_ADDNODE(recorded_events.at(0), device_handle, nullptr),
113 recorded_events.at(0), device_handle, MATCHER_FOR_GRAPH_NODE_OF(recorded_events.at(1)))));
114}
115
116} // namespace Tests::GraphImpl
RecorderListener< GraphEventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, Kokkos::Execution::GraphImpl::GraphAddNodeEvent, Kokkos::Execution::GraphImpl::GraphCreateEvent, Kokkos::Execution::GraphImpl::GraphInstantiateEvent, Kokkos::Execution::GraphImpl::GraphSubmitEvent > recorder_listener_t
void graph_add_node_event(const Predecessor &predecessor, const NodeType &node, const Kokkos::Impl::DeviceHandle< Exec > &device_handle)
Record an event for a node added after predecessor.
Definition events.hpp:129
void graph_create_event(const Kokkos::Experimental::Graph< Exec > &graph)
Record a GraphCreateEvent event.
Definition events.hpp:105
auto * get_node_ptr(const NodeType &node) noexcept
Retrieve the raw node pointer.
Definition events.hpp:99
auto create_graph(const Kokkos::Impl::DeviceHandle< Exec > &device_handle, Args &&... args)
Create a graph and record the associated event with graph_create_event.
Definition events.hpp:117
void graph_instantiate_event(const Kokkos::Experimental::Graph< Exec > &graph)
Record a GraphInstantiateEvent event.
Definition events.hpp:159
void graph_submit_event(const Kokkos::Experimental::Graph< Exec > &graph, const Exec &exec)
Record a GraphSubmitEvent event.
Definition events.hpp:168
auto * get_graph_impl_ptr(const NodeType &node) noexcept
Retrieve the raw graph pointer from a node.
Definition events.hpp:93
void submit_graph(const Kokkos::Experimental::Graph< Exec > &graph, const Exec &exec)
Submit a graph and record the associated event with graph_submit_event.
Definition events.hpp:178
consteval bool test_noexcept()
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph node is added.
Definition events.hpp:35
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph is created.
Definition events.hpp:16
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph is instantiated.
Definition events.hpp:65
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph is submitted.
Definition events.hpp:76
Similar to EventDiscardMatcher, for graph-related events.
Definition events.hpp:76
#define MATCHER_FOR_GRAPH_CREATE(_device_handle_)
Definition events.hpp:17
#define MATCHER_FOR_GRAPH_SUBMIT(_exec_, _graph_create_event_variant_)
Definition events.hpp:63
#define MATCHER_FOR_GRAPH_ADDNODE(_graph_create_event_variant_, _device_handle_, _predecessor_)
Definition events.hpp:24
#define MATCHER_FOR_GRAPH_INSTANTIATE(_graph_create_event_variant_)
Definition events.hpp:55
#define MATCHER_FOR_GRAPH_NODE_OF(_graph_add_node_event_)
Definition events.hpp:47