kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
test_dependency.cpp
Go to the documentation of this file.
1
#include "gtest/gtest.h"
2
3
#include "
kokkos-utils/callbacks/RecorderListener.hpp
"
4
#include "
kokkos-utils/tests/scoped/callbacks/Manager.hpp
"
5
6
#include "
kokkos-execution/impl/dependency.hpp
"
7
#include "
kokkos-execution/impl/event.hpp
"
8
9
#include "
tests/utils/callback_matchers.hpp
"
10
#include "
tests/utils/execution_space_context.hpp
"
11
22
23
#if !defined(KOKKOS_EXECUTION_ENABLE_EVENT_DISPATCH)
24
# error "This is not supported."
25
#endif
26
27
namespace
Tests::Impl
{
28
29
using namespace
Kokkos::utils::callbacks;
30
31
class
DependencyTest
32
:
public
Tests::Utils::ExecutionSpaceContextTest
<TEST_EXECUTION_SPACE>
33
,
public
Kokkos::utils::tests::scoped::callbacks::Manager
{
34
public
:
35
using
recorder_listener_t
=
RecorderListener
<
36
EventDiscardMatcher<TEST_EXECUTION_SPACE>
,
37
BeginFenceEvent
,
38
Kokkos::Execution::Impl::RecordEvent
,
39
Kokkos::Execution::Impl::WaitEvent
40
>;
41
};
42
44
TEST_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
50
if
constexpr
(
Kokkos::Execution::Impl::has_exec_wait_event<TEST_EXECUTION_SPACE>
) {
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
66
TEST_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
RecorderListener.hpp
callback_matchers.hpp
dispatch_label
constexpr std::string dispatch_label(const Exec &, Label &&label)
Get the dispatch label from Exec and label.
Definition
callback_matchers.hpp:47
MATCHER_FOR_WAIT_EXEC_EVENT
#define MATCHER_FOR_WAIT_EXEC_EVENT(_exec_, _record_event_variant_)
Definition
callback_matchers.hpp:71
MATCHER_FOR_RECORD_EVENT
#define MATCHER_FOR_RECORD_EVENT(_exec_)
Definition
callback_matchers.hpp:57
MATCHER_FOR_BEGIN_FENCE
#define MATCHER_FOR_BEGIN_FENCE(_exec_, _label_)
Definition
callback_matchers.hpp:28
Kokkos::utils::callbacks::RecorderListener
Tests::Impl::DependencyTest
Definition
test_dependency.cpp:33
Tests::Impl::DependencyTest::recorder_listener_t
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, Kokkos::Execution::Impl::RecordEvent, Kokkos::Execution::Impl::WaitEvent > recorder_listener_t
Definition
test_dependency.cpp:35
Kokkos::Execution::Impl::has_exec_wait_event
Determine if the Kokkos backend can enqueue a wait for an event into an execution space instance.
Definition
dependency.hpp:16
dependency.hpp
event.hpp
execution_space_context.hpp
Tests::Impl
Definition
test_completion_signal.cpp:23
Tests::Utils::are_same_instances
bool are_same_instances(const Exec &exec, const OtherExec &other_exec)
Definition
kokkos.hpp:13
EventDiscardMatcher
Matcher to filter out events that are just noise for tests.
Definition
callback_matchers.hpp:83
Kokkos::Execution::Impl::Dependency
This is the default implementation.
Definition
dependency.hpp:31
Kokkos::Execution::Impl::RecordEvent
Event to be sent to Kokkos::utils::callbacks::dispatch when calling record.
Definition
event.hpp:54
Kokkos::Execution::Impl::WaitEvent
Event to be sent to Kokkos::utils::callbacks::dispatch when calling wait.
Definition
event.hpp:75
Kokkos::utils::callbacks::BeginFenceEvent
Kokkos::utils::tests::scoped::ExecutionSpace< Exec >::exec
Exec exec
Kokkos::utils::tests::scoped::callbacks::Manager
Tests::Utils::ExecutionSpaceContextTest
Definition
execution_space_context.hpp:12
Manager.hpp
tests
impl
test_dependency.cpp
Generated on
for kokkos-execution by
1.18.0