31using namespace Kokkos::utils::callbacks;
46 using variant_t =
typename recorder_listener_t::event_variant_t;
56 using then_sndr_t = stdexec::transform_sender_result_t<
57 decltype(stdexec::then(std::declval<schd_sndr_t>(), std::declval<functor_t>())),
63 static_assert(std::same_as<Kokkos::Execution::Impl::exec_of_t<then_sndr_t>, TEST_EXECUTION_SPACE>);
69 using policy_t =
typename then_sndr_t::closure_t::policy_t;
70 static_assert(std::same_as<typename policy_t::launch_bounds, Kokkos::LaunchBounds<1>>);
88 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
94 using chain_t =
decltype(chain);
97 static_assert(std::same_as<stdexec::__domain_of_t<stdexec::env_of_t<chain_t>>, stdexec::default_domain>);
98 static_assert(std::same_as<
99 stdexec::__detail::__completing_domain_t<stdexec::set_value_t, chain_t>,
104 static_assert(std::same_as<
105 decltype(stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(chain))),
111 testing::ElementsAre(
116 ASSERT_EQ(data(), 2);
124 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
134 using chain_t =
decltype(chain);
137 stdexec::get_completion_signatures<chain_t>()
138 == stdexec::completion_signatures<stdexec::set_value_t(), stdexec::set_error_t(std::exception_ptr)>{});
141 std::same_as<stdexec::__completion_domain_of_t<stdexec::set_value_t, chain_t>, stdexec::indeterminate_domain<>>);
144 auto starts_on = stdexec::starts_on(esc.
get_scheduler(), std::move(chain));
146 using starts_on_t =
decltype(starts_on);
149 static_assert(stdexec::__has_eptr_completion<chain_t>);
150 static_assert(!stdexec::dependent_sender<starts_on_t>);
152 stdexec::get_completion_signatures<starts_on_t>()
153 == stdexec::completion_signatures<stdexec::set_value_t(), stdexec::set_error_t(std::exception_ptr)>{});
156 static_assert(stdexec::__completes_where_it_starts<stdexec::set_value_t, stdexec::env_of_t<chain_t>>);
158 static_assert(std::same_as<
162 static_assert(std::same_as<
163 stdexec::__completion_domain_of_t<stdexec::set_value_t, starts_on_t, stdexec::env<>>,
167 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
171 ASSERT_THAT(recorded_events, [&]() {
173 return testing::ElementsAre(
179 return testing::ElementsAre(
186 ASSERT_EQ(data(), 2);
197 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
203 | stdexec::then(KOKKOS_LAMBDA() {
204 Kokkos::abort(
"The value channel should be used at this point.");
207 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
210 recorder_listener_t::record([sndr = std::move(sndr)]()
mutable {
213 testing::ThrowsMessage<std::runtime_error>(
214 testing::HasSubstr(
"ThrowsWhenCopied: Throwing in copy constructor!")));
216 testing::ElementsAre(
221 ASSERT_EQ(data(), 1);
234 auto create_chain_in_scope = [&]() {
235 const view_s_t data(Kokkos::view_alloc(
"data - shared space",
exec));
241 const auto run_test = [&]() {
242 auto chain = create_chain_in_scope();
244 using chain_t =
decltype(chain);
247 static_assert(std::same_as<stdexec::__domain_of_t<stdexec::env_of_t<chain_t>>, stdexec::default_domain>);
248 static_assert(std::same_as<
249 stdexec::__detail::__completing_domain_t<stdexec::set_value_t, chain_t>,
254 static_assert(std::same_as<
255 decltype(stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(chain))),
259 stdexec::sync_wait(std::move(chain));
263 recorder_listener_t::record(run_test),
285 static_assert(std::same_as<
286 stdexec::__demangle_t<sndr_then_t>,
294 static_assert(stdexec::__detail::__has_nothrow_transform_sender<
296 stdexec::set_value_t,
301 using sndr_then_maythrow_on_move_t =
304 static_assert(!stdexec::__detail::__has_nothrow_transform_sender<
306 stdexec::set_value_t,
307 sndr_then_maythrow_on_move_t&&,
317 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
319 std::atomic<size_t> count = 0;
325 stdexec::sender
auto sndr =
326 stdexec::read_env(stdexec::get_allocator)
332 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
336 ASSERT_THAT(recorded_events, [&]() {
338 return testing::ElementsAre(
343 return testing::ElementsAre(
349 ASSERT_EQ(data(), 1);
351 ASSERT_EQ(value, 42);
constexpr std::string dispatch_label(const Exec &, Label &&label)
Get the dispatch label from Exec and label.
#define MATCHER_FOR_WAIT_EVENT(_record_event_variant_)
#define MATCHER_FOR_BEGIN_PFOR(_exec_, _label_)
#define MATCHER_FOR_RECORD_EVENT(_exec_)
#define MATCHER_FOR_BEGIN_FENCE(_exec_, _label_)
typename recorder_listener_t::event_variant_t variant_t
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, BeginParallelForEvent, AllocateDataEvent, DeallocateDataEvent, Kokkos::Execution::Impl::RecordEvent, Kokkos::Execution::Impl::WaitEvent > recorder_listener_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()
typename stdexec::__basic_sender< Args... >::type basic_sender_t
See https://github.com/NVIDIA/stdexec/pull/1873#discussion_r2834863237.
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< Exec >
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.
A minimal tracking allocator.