32using namespace Kokkos::utils::callbacks;
47 using variant_t =
typename recorder_listener_t::event_variant_t;
57 using then_sndr_t = stdexec::transform_sender_result_t<
58 decltype(stdexec::then(std::declval<schd_sndr_t>(), std::declval<functor_t>())),
64 static_assert(std::same_as<Kokkos::Execution::Impl::exec_of_t<then_sndr_t>, TEST_EXECUTION_SPACE>);
86 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
92 using chain_t =
decltype(chain);
95 static_assert(std::same_as<stdexec::__domain_of_t<stdexec::env_of_t<chain_t>>, stdexec::default_domain>);
96 static_assert(std::same_as<
97 stdexec::__detail::__completing_domain_t<stdexec::set_value_t, chain_t>,
102 static_assert(std::same_as<
103 decltype(stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(chain))),
109 testing::ElementsAre(
114 ASSERT_EQ(data(), 2);
122 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
132 using chain_t =
decltype(chain);
135 stdexec::get_completion_signatures<chain_t>()
136 == stdexec::completion_signatures<stdexec::set_value_t(), stdexec::set_error_t(std::exception_ptr)>{});
139 std::same_as<stdexec::__completion_domain_of_t<stdexec::set_value_t, chain_t>, stdexec::indeterminate_domain<>>);
142 auto starts_on = stdexec::starts_on(esc.
get_scheduler(), std::move(chain));
144 using starts_on_t =
decltype(starts_on);
147 static_assert(stdexec::__has_eptr_completion<chain_t>);
148 static_assert(!stdexec::dependent_sender<starts_on_t>);
150 stdexec::get_completion_signatures<starts_on_t>()
151 == stdexec::completion_signatures<stdexec::set_value_t(), stdexec::set_error_t(std::exception_ptr)>{});
154 static_assert(stdexec::__completes_where_it_starts<stdexec::set_value_t, stdexec::env_of_t<chain_t>>);
156 static_assert(std::same_as<
160 static_assert(std::same_as<
161 stdexec::__completion_domain_of_t<stdexec::set_value_t, starts_on_t, stdexec::env<>>,
165 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
169 ASSERT_THAT(recorded_events, [&]() {
171 return testing::ElementsAre(
177 return testing::ElementsAre(
184 ASSERT_EQ(data(), 2);
195 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
201 | stdexec::then(KOKKOS_LAMBDA() {
202 Kokkos::abort(
"The value channel should be used at this point.");
205 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
208 recorder_listener_t::record([sndr = std::move(sndr)]()
mutable {
211 testing::ThrowsMessage<std::runtime_error>(
212 testing::HasSubstr(
"ThrowsWhenCopied: Throwing in copy constructor!")));
214 testing::ElementsAre(
219 ASSERT_EQ(data(), 1);
232 auto create_chain_in_scope = [&]() {
233 const view_s_t data(Kokkos::view_alloc(
"data - shared space",
exec));
239 const auto run_test = [&]() {
240 auto chain = create_chain_in_scope();
242 using chain_t =
decltype(chain);
245 static_assert(std::same_as<stdexec::__domain_of_t<stdexec::env_of_t<chain_t>>, stdexec::default_domain>);
246 static_assert(std::same_as<
247 stdexec::__detail::__completing_domain_t<stdexec::set_value_t, chain_t>,
252 static_assert(std::same_as<
253 decltype(stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(chain))),
257 stdexec::sync_wait(std::move(chain));
261 recorder_listener_t::record(run_test),
283 static_assert(std::same_as<
285 stdexec::then_t::__sender<
291 static_assert(stdexec::__detail::__has_nothrow_transform_sender<
293 stdexec::set_value_t,
298 using sndr_then_maythrow_on_move_t =
301 static_assert(!stdexec::__detail::__has_nothrow_transform_sender<
303 stdexec::set_value_t,
304 sndr_then_maythrow_on_move_t&&,
308 using sndr_then_maythrow_on_copy_t =
311 static_assert(!stdexec::__detail::__has_nothrow_transform_sender<
312 Kokkos::Execution::ExecutionSpaceImpl::Domain,
313 stdexec::set_value_t,
314 const sndr_then_maythrow_on_copy_t&,
319 !
noexcept(stdexec::transform_sender(std::declval<const sndr_then_maythrow_on_copy_t&>(), stdexec::env<>{})));
328 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
330 std::atomic<size_t> count = 0;
336 stdexec::sender
auto sndr =
337 stdexec::read_env(stdexec::get_allocator)
343 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
347 ASSERT_THAT(recorded_events, [&]() {
349 return testing::ElementsAre(
354 return testing::ElementsAre(
360 ASSERT_EQ(data(), 1);
362 ASSERT_EQ(value, 42);
367TEST_F(
ThenTest, set_stopped_will_not_dispatch_operation) {
368 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
376 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
382 testing::ElementsAre(
386 ASSERT_EQ(data(), 1);
constexpr std::string dispatch_label(const Exec &, const std::string_view label)
Get the dispatch label from Exec and label.
#define MATCHER_FOR_BEGIN_SINGLE(_exec_, _label_)
#define MATCHER_FOR_WAIT_EVENT(_record_event_variant_)
#define MATCHER_FOR_RECORD_EVENT(_exec_)
#define MATCHER_FOR_BEGIN_FENCE(_exec_, _label_)
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, BeginSingleEvent, AllocateDataEvent, DeallocateDataEvent, Kokkos::Execution::Impl::RecordEvent, Kokkos::Execution::Impl::WaitEvent > recorder_listener_t
typename recorder_listener_t::event_variant_t variant_t
Concept for a sender whose completion scheduler is Kokkos::Execution::ExecutionSpaceImpl::Scheduler.
Concept that constrains the type of a sender that dispatches a functor for execution.
#define THEN_INCREMENT(_data_)
Add a then using Tests::Utils::Functors::Increment that may throw. // NOLINTNEXTLINE(cppcoreguideline...
std::invoke_result_t< stdexec::get_completion_scheduler_t< Tag >, stdexec::env_of_t< Sndr >, Env... > completion_scheduler_of_t
Retrieve the completion scheduler for a given completion tag.
auto AAllocateDataEvent(Matchers &&... matchers)
auto ADeallocateDataEvent(Matchers &&... matchers)
auto ContainsInOrder(Matchers &&... matchers)
consteval bool test_sndr_traits()
consteval bool test_sndr_nothrow_transformable()
auto record_sync_wait(Sndr &&sndr)
consteval bool check_continues_on_after_just_stopped()
constexpr check_rcvr_env_queryable_with_t< true, Queries... > check_rcvr_env_queryable_with
auto round_trip_allocate(Allocator &allocator, T &&value)
Matcher to filter out events that are just noise for tests.
auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler< execution_space >
Event to be sent to Kokkos::utils::callbacks::dispatch when calling record.
Event to be sent to Kokkos::utils::callbacks::dispatch when calling wait.
decltype(std::declval< const context_t >().get_scheduler()) scheduler_t
decltype(stdexec::schedule(std::declval< scheduler_t >())) schedule_sender_t
Kokkos::View< value_t, Kokkos::SharedSpace > view_s_t
Kokkos::Execution::ExecutionSpaceContext< Exec > context_t
This helper struct throws when copy constructed.
Scheduler that returns a sender that always completes on the stop channel.
A minimal tracking allocator.