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&>(), std::declval<const EventsTest::graph_t::root_t&>())));
59
60 static_assert(
61 !noexcept(Kokkos::Execution::GraphImpl::graph_instantiate_event(std::declval<const EventsTest::graph_t&>())));
62
64 std::declval<const EventsTest::graph_t&>(), std::declval<const TEST_EXECUTION_SPACE&>())));
65
66 static_assert(!noexcept(Kokkos::Execution::GraphImpl::submit_graph(
67 std::declval<const EventsTest::graph_t&>(), std::declval<const TEST_EXECUTION_SPACE&>())));
68
69 return true;
70}
71static_assert(test_noexcept());
72
74TEST_F(EventsTest, create_instantiate_and_submit) {
75 const auto recorded_events = recorder_listener_t::record([this]() {
77
78 graph.instantiate();
80
82 });
83 ASSERT_THAT(
84 recorded_events,
85 testing::ElementsAre(
87 MATCHER_FOR_GRAPH_INSTANTIATE(recorded_events.at(0)),
88 MATCHER_FOR_GRAPH_SUBMIT(exec, recorded_events.at(0))));
89}
90
92TEST_F(EventsTest, create_and_add_nodes) {
93 const auto recorded_events = recorder_listener_t::record([this]() {
94 const graph_t graph{device_handle};
96
97 const auto root = graph.root_node();
98
99 const auto node_A = root.then(Kokkos::Experimental::node_props(device_handle), KOKKOS_LAMBDA(){});
101
102 const auto node_B = node_A.then(Kokkos::Experimental::node_props(device_handle), KOKKOS_LAMBDA(){});
104 });
105 ASSERT_THAT(
106 recorded_events,
107 testing::ElementsAre(
109 MATCHER_FOR_GRAPH_ADDNODE(recorded_events.at(0), device_handle, nullptr),
111 recorded_events.at(0), device_handle, MATCHER_FOR_GRAPH_NODE_OF(recorded_events.at(1)))));
112}
113
114} // 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_create_event(const Kokkos::Experimental::Graph< Exec > &graph)
Record a GraphCreateEvent event.
Definition events.hpp:88
void graph_add_node_event(const Predecessor &predecessor, const NodeType &node)
Record an event for a node added after predecessor.
Definition events.hpp:112
auto * get_node_ptr(const NodeType &node) noexcept
Retrieve the raw node pointer.
Definition events.hpp:82
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:100
void graph_instantiate_event(const Kokkos::Experimental::Graph< Exec > &graph)
Record a GraphInstantiateEvent event.
Definition events.hpp:149
void graph_submit_event(const Kokkos::Experimental::Graph< Exec > &graph, const Exec &exec)
Record a GraphSubmitEvent event.
Definition events.hpp:158
auto * get_graph_impl_ptr(const NodeType &node) noexcept
Retrieve the raw graph pointer from a node.
Definition events.hpp:76
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:168
consteval bool test_noexcept()
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph node is added.
Definition events.hpp:33
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph is created.
Definition events.hpp:14
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph is instantiated.
Definition events.hpp:48
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph is submitted.
Definition events.hpp:59
Similar to EventDiscardMatcher, for graph-related events.
Definition events.hpp:60
#define MATCHER_FOR_GRAPH_CREATE(_device_handle_)
Definition events.hpp:16
#define MATCHER_FOR_GRAPH_SUBMIT(_exec_, _graph_create_event_variant_)
Definition events.hpp:47
#define MATCHER_FOR_GRAPH_ADDNODE(_graph_create_event_variant_, _device_handle_, _predecessor_)
Definition events.hpp:23
#define MATCHER_FOR_GRAPH_INSTANTIATE(_graph_create_event_variant_)
Definition events.hpp:39
#define MATCHER_FOR_GRAPH_NODE_OF(_graph_add_node_event_)
Definition events.hpp:35