kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
test_any_sender.cpp
Go to the documentation of this file.
1
#include "
kokkos-execution/utils/ignore_warnings.hpp
"
2
PRAGMA_DIAGNOSTIC_PUSH
3
KOKKOS_EXECUTION_STDEXEC_PRAGMA_DIAGNOSTIC_IGNORED
4
#include "exec/any_sender_of.hpp"
5
PRAGMA_DIAGNOSTIC_POP
6
7
#include "
kokkos-utils/callbacks/RecorderListener.hpp
"
8
#include "
kokkos-utils/tests/scoped/callbacks/Manager.hpp
"
9
10
#if defined(KOKKOS_COMPILER_GNU) && KOKKOS_COMPILER_GNU == 1520
11
# define KOKKOS_EXECUTION_IMPL_OP_STATE_IMMOVABLE_FIX
12
#endif
13
#include "
kokkos-execution/execution_space.hpp
"
14
15
#include "
tests/utils/callback_matchers.hpp
"
16
#include "
tests/utils/execution_space_context.hpp
"
17
#include "
tests/utils/functors/increment.hpp
"
18
#include "
tests/utils/stdexec.hpp
"
19
#include "
tests/utils/sync_wait.hpp
"
20
38
39
namespace
Tests::ExecutionSpaceImpl
{
40
41
using namespace
Kokkos::utils::callbacks
;
42
43
class
AnySenderTest
44
:
public
Tests::Utils::ExecutionSpaceContextTest
<TEST_EXECUTION_SPACE>
45
,
public
Kokkos::utils::tests::scoped::callbacks::Manager
{
46
public
:
47
using
recorder_listener_t
=
48
RecorderListener<EventDiscardMatcher<TEST_EXECUTION_SPACE>
,
BeginFenceEvent
,
BeginParallelForEvent
>;
49
};
50
52
TEST_F(
AnySenderTest
, then) {
53
using
completion_signatures_t =
54
stdexec::completion_signatures<stdexec::set_value_t(), stdexec::set_error_t(std::exception_ptr)>;
55
using
any_receiver_t = exec::any_receiver<completion_signatures_t>;
56
using
any_sender_t = exec::any_sender<any_receiver_t>;
57
58
static_assert
(std::same_as<
59
stdexec::__completion_domain_of_t<stdexec::set_value_t, any_sender_t>,
60
stdexec::indeterminate_domain<>
61
>);
62
static_assert
(std::same_as<
63
stdexec::__completion_domain_of_t<stdexec::set_value_t, any_sender_t, stdexec::env<>>,
64
stdexec::default_domain
65
>);
66
67
static_assert
(stdexec::get_completion_signatures<any_sender_t, stdexec::env<>>() == completion_signatures_t{});
68
69
const
view_s_t
data(Kokkos::view_alloc(
exec
,
"data - shared space"
));
70
71
const
context_t
esc{
exec
};
72
73
any_sender_t chain = stdexec::schedule(esc.
get_scheduler
()) |
THEN_INCREMENT
(data) |
THEN_INCREMENT
(data);
74
75
auto
continues_on = std::move(chain) | stdexec::continues_on(esc.
get_scheduler
());
76
77
static_assert
(std::same_as<
78
stdexec::__demangle_t<
decltype
(continues_on)>,
79
Tests::Utils::basic_sender_t
<
80
stdexec::continues_on_t,
81
typename
AnySenderTest::scheduler_t
,
82
Tests::Utils::basic_sender_t<stdexec::schedule_from_t, stdexec::__, any_sender_t>
83
>
84
>);
85
86
any_sender_t extended_chain = std::move(continues_on) |
THEN_INCREMENT
(data);
87
88
ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed."
;
89
90
ASSERT_THAT(
91
Tests::Utils::record_sync_wait<recorder_listener_t>
(std::move(extended_chain)),
92
testing::ElementsAre(
93
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"then"
)),
94
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"then"
)),
95
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"after dispatch"
)),
96
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"then"
)),
97
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"after dispatch"
))));
98
99
ASSERT_EQ(data(), 3);
100
}
101
102
}
// namespace Tests::ExecutionSpaceImpl
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_BEGIN_PFOR
#define MATCHER_FOR_BEGIN_PFOR(_exec_, _label_)
Definition
callback_matchers.hpp:30
MATCHER_FOR_BEGIN_FENCE
#define MATCHER_FOR_BEGIN_FENCE(_exec_, _label_)
Definition
callback_matchers.hpp:28
Kokkos::utils::callbacks::RecorderListener
Tests::ExecutionSpaceImpl::AnySenderTest
Definition
test_any_sender.cpp:45
Tests::ExecutionSpaceImpl::AnySenderTest::recorder_listener_t
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, BeginParallelForEvent > recorder_listener_t
Definition
test_any_sender.cpp:47
execution_space.hpp
execution_space_context.hpp
ignore_warnings.hpp
KOKKOS_EXECUTION_STDEXEC_PRAGMA_DIAGNOSTIC_IGNORED
#define KOKKOS_EXECUTION_STDEXEC_PRAGMA_DIAGNOSTIC_IGNORED
Basic list of ignored diagnostics when including anything from stdexec.
Definition
ignore_warnings.hpp:38
increment.hpp
THEN_INCREMENT
#define THEN_INCREMENT(_data_)
Add a then using Tests::Utils::Functors::Increment that may throw. // NOLINTNEXTLINE(cppcoreguideline...
Definition
increment.hpp:59
Kokkos::utils::callbacks
Tests::ExecutionSpaceImpl
Definition
test_any_sender.cpp:39
Tests::Utils::basic_sender_t
typename stdexec::__basic_sender< Args... >::type basic_sender_t
See https://github.com/NVIDIA/stdexec/pull/1873#discussion_r2834863237.
Definition
stdexec.hpp:12
Tests::Utils::record_sync_wait
auto record_sync_wait(Sndr &&sndr)
Definition
sync_wait.hpp:14
Kokkos::Execution::ExecutionSpaceContext::get_scheduler
auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler< Exec >
Definition
execution_space.hpp:133
Kokkos::utils::callbacks::BeginFenceEvent
Kokkos::utils::callbacks::BeginParallelForEvent
Kokkos::utils::tests::scoped::ExecutionSpace< Exec >::exec
Exec exec
Kokkos::utils::tests::scoped::callbacks::Manager
Tests::Utils::ContextTest< Kokkos::Execution::ExecutionSpaceContext, Exec >::scheduler_t
decltype(std::declval< const context_t >().get_scheduler()) scheduler_t
Definition
context.hpp:28
Tests::Utils::ContextTest< Kokkos::Execution::ExecutionSpaceContext, Exec >::view_s_t
Kokkos::View< value_t, Kokkos::SharedSpace > view_s_t
Definition
context.hpp:32
Tests::Utils::ContextTest< Kokkos::Execution::ExecutionSpaceContext, Exec >::context_t
Kokkos::Execution::ExecutionSpaceContext< Exec > context_t
Definition
context.hpp:27
Tests::Utils::ExecutionSpaceContextTest
Definition
execution_space_context.hpp:12
Manager.hpp
stdexec.hpp
sync_wait.hpp
tests
execution_space
test_any_sender.cpp
Generated on
for kokkos-execution by
1.18.0