kokkos-execution 0.0.1
Loading...
Searching...
No Matches
test_dependency.cpp
Go to the documentation of this file.
1#include "gtest/gtest.h"
2
5
8
11
22
23#if !defined(KOKKOS_EXECUTION_ENABLE_EVENT_DISPATCH)
24# error "This is not supported."
25#endif
26
27namespace Tests::Impl {
28
29using namespace Kokkos::utils::callbacks;
30
42
44TEST_F(DependencyTest, same_type) {
45 const auto [exec_A, exec_B] = Kokkos::Experimental::partition_space(exec, 1, 1);
46
47 const auto recorded_events = recorder_listener_t::record(
48 [&exec_A, &exec_B]() { const Kokkos::Execution::Impl::Dependency dependency{exec_B, exec_A}; });
49
51 ASSERT_THAT(recorded_events, ::testing::SizeIs(2));
52 ASSERT_THAT(recorded_events.at(0), MATCHER_FOR_RECORD_EVENT(exec_A));
53 ASSERT_THAT(recorded_events.at(1), MATCHER_FOR_WAIT_EXEC_EVENT(exec_B, recorded_events.at(0)));
54 } else {
55 if (Tests::Utils::are_same_instances(exec_A, exec_B)) {
56 ASSERT_THAT(recorded_events, testing::IsEmpty());
57 } else {
58 ASSERT_THAT(
59 recorded_events,
60 testing::ElementsAre(MATCHER_FOR_BEGIN_FENCE(exec_A, dispatch_label(exec_A, "dependency"))));
61 }
62 }
63}
64
66TEST_F(DependencyTest, different_type) {
67 if constexpr (std::same_as<TEST_EXECUTION_SPACE, Kokkos::DefaultHostExecutionSpace>) {
68 GTEST_SKIP() << "The default host execution space is the same type as the test execution space.";
69 }
70
71 const Kokkos::DefaultHostExecutionSpace exec_h;
72
73 const auto recorded_events = recorder_listener_t::record(
74 [this, &exec_h]() { const Kokkos::Execution::Impl::Dependency dependency{exec_h, this->exec}; });
75
76 ASSERT_THAT(
77 recorded_events,
78 testing::ElementsAre(MATCHER_FOR_BEGIN_FENCE(this->exec, dispatch_label(this->exec, "dependency"))));
79}
80
81} // namespace Tests::Impl
constexpr std::string dispatch_label(const Exec &, Label &&label)
Get the dispatch label from Exec and label.
#define MATCHER_FOR_WAIT_EXEC_EVENT(_exec_, _record_event_variant_)
#define MATCHER_FOR_RECORD_EVENT(_exec_)
#define MATCHER_FOR_BEGIN_FENCE(_exec_, _label_)
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, Kokkos::Execution::Impl::RecordEvent, Kokkos::Execution::Impl::WaitEvent > recorder_listener_t
Determine if the Kokkos backend can enqueue a wait for an event into an execution space instance.
bool are_same_instances(const Exec &exec, const OtherExec &other_exec)
Definition kokkos.hpp:13
Matcher to filter out events that are just noise for tests.
This is the default implementation.
Event to be sent to Kokkos::utils::callbacks::dispatch when calling record.
Definition event.hpp:54
Event to be sent to Kokkos::utils::callbacks::dispatch when calling wait.
Definition event.hpp:75