kokkos-execution 0.0.1
Loading...
Searching...
No Matches
test_any_sender.cpp
Go to the documentation of this file.
2PRAGMA_DIAGNOSTIC_PUSH
4#include "exec/any_sender_of.hpp"
5PRAGMA_DIAGNOSTIC_POP
6
9
14
32
34
35using namespace Kokkos::utils::callbacks;
36
44
50TEST_F(AnySenderTest, then) {
51 using any_sender_t = experimental::execution::any_receiver_ref<
52 stdexec::completion_signatures<stdexec::set_value_t(), stdexec::set_error_t(std::exception_ptr)>,
55 >::
56 template any_sender<
57 stdexec::get_completion_scheduler<stdexec::set_value_t>.signature<scheduler_t() noexcept>,
58 stdexec::get_completion_domain<stdexec::set_value_t>.signature<Kokkos::Execution::ExecutionSpaceImpl::Domain() noexcept>
59 >;
60
61 const view_s_t data(Kokkos::view_alloc(exec, "data - shared space"));
62
63 const context_t esc{exec};
64
65 any_sender_t chain = stdexec::schedule(esc.get_scheduler()) | THEN_INCREMENT(data) | THEN_INCREMENT(data);
66
67 static_assert(std::same_as<
68 stdexec::__completion_domain_of_t<stdexec::set_value_t, decltype(chain)>,
70 >);
71 static_assert(std::same_as<
72 stdexec::__completion_scheduler_of_t<stdexec::set_value_t, decltype(chain)>,
74 >);
75
76 auto continues_on = std::move(chain) | stdexec::continues_on(esc.get_scheduler());
77
78 static_assert(std::same_as<
79 stdexec::__demangle_t<decltype(continues_on)>,
81 stdexec::continues_on_t,
84 >
85 >);
86
87 any_sender_t extended_chain = std::move(continues_on) | THEN_INCREMENT(data);
88
89 ASSERT_EQ(data(), 0) << "Eager execution is not allowed.";
90
91 ASSERT_THAT(
92 recorder_listener_t::record(
93 [extended_chain = std::move(extended_chain)]() mutable { stdexec::sync_wait(std::move(extended_chain)); }),
94 testing::ElementsAre(
99
100 ASSERT_EQ(data(), 3);
101}
102
103} // namespace Tests::ExecutionSpaceImpl
constexpr std::string dispatch_label(const Exec &, Label &&label)
Get the dispatch label from Exec and label.
#define MATCHER_FOR_BEGIN_PFOR(_exec_, _label_)
#define MATCHER_FOR_BEGIN_FENCE(_exec_, _label_)
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, BeginParallelForEvent > recorder_listener_t
#define KOKKOS_EXECUTION_STDEXEC_PRAGMA_DIAGNOSTIC_IGNORED
Basic list of ignored diagnostics when including anything from stdexec.
#define THEN_INCREMENT(_data_)
Add a then using Tests::Utils::Functors::Increment that may throw. // NOLINTNEXTLINE(cppcoreguideline...
Definition increment.hpp:35
typename stdexec::__basic_sender< Args... >::type basic_sender_t
See https://github.com/NVIDIA/stdexec/pull/1873#discussion_r2834863237.
Definition stdexec.hpp:10
auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler< Exec >
Wrap a Kokkos execution space to make it cheap to copy/move in new environments.
Definition get_exec.hpp:31
decltype(std::declval< const context_t >().get_scheduler()) scheduler_t
Definition context.hpp:26
Kokkos::Execution::ExecutionSpaceContext< Exec > context_t
Definition context.hpp:25