54 static_assert(stdexec::__nothrow_connectable<schedule_from_sndr_t, Tests::Utils::SinkReceiver>);
72 const auto [exec_A, exec_B] = Kokkos::Experimental::partition_space(
exec, 1, 1);
77 const context_t esc_A{exec_A}, esc_B{exec_B};
84 auto schs_A_then = std::move(schs_A) |
THEN_LABELED(
'A');
86 const auto sch_B = esc_B.get_scheduler();
87 auto schs_A_then_con_B = std::move(schs_A_then)
88 | stdexec::continues_on(sch_B);
91 ASSERT_EQ(stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(schs_A_then_con_B)), sch_B);
93 auto schs_A_then_con_B_then = std::move(schs_A_then_con_B)
96 static_assert(std::same_as<
97 decltype(schs_A_then_con_B_then),
98 stdexec::then_t::__sender<
101 stdexec::continues_on_t,
104 stdexec::schedule_from_t,
114 auto schs_A_then_con_B_then_con_h_then = std::move(schs_A_then_con_B_then)
117 stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(schs_A_then_con_B_then_con_h_then)),
120 const auto op_state = stdexec::connect(
121 std::move(schs_A_then_con_B_then_con_h_then),
123 .state = std::addressof(esc_h.
m_state), .runloop_state =
nullptr, .result =
nullptr});
129 const auto& then_op_state = op_state;
138 static_assert(std::same_as<
decltype(then_op_state.inner_op_state.rcvr), then_rcvr_t>);
142 const auto& con_h_then_op_state = then_op_state.inner_op_state;
143 static_assert(stdexec::__is_instance_of<
144 std::remove_cvref_t<
decltype(con_h_then_op_state)>,
147 using con_h_then_rcvr_t =
decltype(con_h_then_op_state.inner_op_state.rcvr);
149 static_assert(std::same_as<
150 stdexec::env_of_t<con_h_then_rcvr_t>,
156 stdexec::__env::__fwd<Kokkos::Execution::Impl::SyncWait::env>
162 const auto& sfrom_con_h_then_op_state = con_h_then_op_state.inner_op_state;
163 static_assert(stdexec::__is_instance_of<
164 std::remove_cvref_t<
decltype(sfrom_con_h_then_op_state)>,
167 using sfrom_con_h_then_rcvr_t =
decltype(sfrom_con_h_then_op_state.inner_op_state.completion_signal.rcvr);
171 const auto& then_sfrom_con_h_then_op_state = sfrom_con_h_then_op_state.inner_op_state;
172 static_assert(stdexec::__is_instance_of<
173 std::remove_cvref_t<
decltype(then_sfrom_con_h_then_op_state)>,
176 using then_sfrom_con_h_then_rcvr_t =
decltype(then_sfrom_con_h_then_op_state.inner_op_state.rcvr);
177 static_assert(!stdexec::__queryable_with<
178 stdexec::env_of_t<then_sfrom_con_h_then_rcvr_t>,
182 const auto& con_B_then_sfrom_con_h_then_op_state = then_sfrom_con_h_then_op_state.inner_op_state;
183 static_assert(stdexec::__is_instance_of<
184 std::remove_cvref_t<
decltype(con_B_then_sfrom_con_h_then_op_state)>,
187 using con_B_then_sfrom_con_h_then_rcvr_t =
decltype(con_B_then_sfrom_con_h_then_op_state.inner_op_state.rcvr);
188 static_assert(stdexec::__queryable_with<
189 stdexec::env_of_t<con_B_then_sfrom_con_h_then_rcvr_t>,
192 static_assert(std::same_as<
193 stdexec::env_of_t<con_B_then_sfrom_con_h_then_rcvr_t>,
199 stdexec::__env::__fwd<stdexec::env<
204 stdexec::__env::__fwd<Kokkos::Execution::Impl::SyncWait::env>
213 const auto& sfrom_con_B_then_sfrom_con_h_then_op_state = con_B_then_sfrom_con_h_then_op_state.inner_op_state;
214 static_assert(stdexec::__is_instance_of<
215 std::remove_cvref_t<
decltype(sfrom_con_B_then_sfrom_con_h_then_op_state)>,
218 using sfrom_con_B_then_sfrom_con_h_then_rcvr_t =
decltype(sfrom_con_B_then_sfrom_con_h_then_op_state.inner_op_state
219 .completion_signal.rcvr);
220 static_assert(!stdexec::__queryable_with<
221 stdexec::env_of_t<sfrom_con_B_then_sfrom_con_h_then_rcvr_t>,
225 const auto& then_sfrom_B_then_sfrom_con_h_then_op_state = sfrom_con_B_then_sfrom_con_h_then_op_state.inner_op_state;
226 static_assert(stdexec::__is_instance_of<
227 std::remove_cvref_t<
decltype(then_sfrom_B_then_sfrom_con_h_then_op_state)>,
230 using then_sfrom_con_B_then_sfrom_con_h_then_rcvr_t =
decltype(then_sfrom_B_then_sfrom_con_h_then_op_state
231 .inner_op_state.rcvr);
232 static_assert(!stdexec::__queryable_with<
233 stdexec::env_of_t<then_sfrom_con_B_then_sfrom_con_h_then_rcvr_t>,
240 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
246 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
250 ::testing::ElementsAre(
254 ASSERT_EQ(data(), 1);
264 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
272 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
276 ::testing::ElementsAre(
282 ASSERT_EQ(data(), 3) <<
"A synchronization is missing.";
289TEST_F(
ContinuesOnTest, transition_to_another_execution_space_instance_and_back_same_type) {
290 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
292 const auto [exec_A, exec_B] = Kokkos::Experimental::partition_space(
exec, 1, 1);
303 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
310 ::testing::ElementsAre(
323 ::testing::ElementsAre(
331 ::testing::ElementsAre(
341 ASSERT_EQ(data(), 3) <<
"A synchronization is missing.";
348TEST_F(
ContinuesOnTest, transition_to_another_execution_space_instance_and_back_different_type) {
349 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
360 using level_B_env_t = stdexec::__env::__fwd<stdexec::env<
365 stdexec::__env::__fwd<level_C_env_t>
367 using level_A_env_t = stdexec::__env::__fwd<stdexec::env<
380 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
387 ::testing::ElementsAre(
392 }
else if constexpr (
394 && std::same_as<host_execution_space, TEST_EXECUTION_SPACE>) {
397 ::testing::ElementsAre(
409 ::testing::ElementsAre(
418 ASSERT_EQ(data(), 3) <<
"A synchronization is missing.";
423 using continues_on_sndr_t =
424 decltype(stdexec::just() | stdexec::continues_on(std::declval<typename ContinuesOnTest::scheduler_t>()));
426 static_assert(std::same_as<
429 stdexec::continues_on_t,
431 stdexec::__sexpr<stdexec::schedule_from_t, stdexec::__, stdexec::just_t::__sender<>>
435 static_assert(stdexec::__detail::__has_nothrow_transform_sender<
437 stdexec::set_value_t,
438 continues_on_sndr_t&&,
442 using schedule_from_sndr_t =
decltype(stdexec::schedule_from(
443 stdexec::schedule(std::declval<typename ContinuesOnTest::scheduler_t>())));
445 static_assert(std::same_as<
446 schedule_from_sndr_t,
447 stdexec::__sexpr<stdexec::schedule_from_t, stdexec::__, typename ContinuesOnTest::schedule_sender_t>
450 static_assert(stdexec::__detail::__has_nothrow_transform_sender<
452 stdexec::set_value_t,
453 schedule_from_sndr_t&&,
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_EXEC_EVENT(_exec_, _record_event_variant_)
#define MATCHER_FOR_RECORD_EVENT(_exec_)
#define MATCHER_FOR_BEGIN_FENCE(_exec_, _label_)
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, BeginSingleEvent, Kokkos::Execution::Impl::RecordEvent, Kokkos::Execution::Impl::WaitEvent > recorder_listener_t
Determine if the Kokkos backend can enqueue a wait for an event into an execution space instance.
Kokkos::DefaultHostExecutionSpace host_execution_space
#define THEN_INCREMENT(_data_)
Add a then using Tests::Utils::Functors::Increment that may throw. // NOLINTNEXTLINE(cppcoreguideline...
#define THEN_LABELED(_id_)
Add a then using Tests::Utils::Functors::Labeled. // NOLINTNEXTLINE(cppcoreguidelines-macro-usage).
constexpr get_exec_t get_exec
consteval bool test_schedule_from_sndr_traits()
consteval bool test_sndr_nothrow_transformable()
consteval bool test_continues_on_sndr_traits()
auto record_sync_wait(Sndr &&sndr)
consteval bool check_continues_on()
Check how the scheduler customizes stdexec::continues_on.
void show_exec_space_id(const Exec &exec, std::string_view label="", std::ostream &out=std::cout)
constexpr check_rcvr_env_t< ExpectedEnv > check_rcvr_env
bool are_same_instances(const Exec &exec, const OtherExec &other_exec)
Matcher to filter out events that are just noise for tests.
Execution context using a Kokkos execution space under the hood.
auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler< execution_space >
Wrap a Kokkos execution space to make it cheap to copy/move in new environments.
Receiver for an object parent_op that implements complete.
Event to be sent to Kokkos::utils::callbacks::dispatch when calling record.
Receiver for stdexec::sync_wait.
Inspired by https://github.com/NVIDIA/stdexec/blob/16076a81efa4477513e6ede9c2741fd034ecef99/include/s...
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