54 static_assert(stdexec::__nothrow_connectable<schedule_from_sndr_t, Tests::Utils::SinkReceiver>);
70 const auto [exec_A, exec_B] = Kokkos::Experimental::partition_space(
exec, 1, 1);
75 const context_t esc_A{exec_A}, esc_B{exec_B};
82 auto schs_A_then = std::move(schs_A) |
THEN_LABELED(
'A');
84 const auto sch_B = esc_B.get_scheduler();
85 auto schs_A_then_con_B = std::move(schs_A_then)
86 | stdexec::continues_on(sch_B);
89 ASSERT_EQ(stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(schs_A_then_con_B)), sch_B);
91 auto schs_A_then_con_B_then = std::move(schs_A_then_con_B)
94 static_assert(std::same_as<
95 stdexec::__demangle_t<
decltype(schs_A_then_con_B_then)>,
100 stdexec::continues_on_t,
103 stdexec::schedule_from_t,
117 auto schs_A_then_con_B_then_con_h_then = std::move(schs_A_then_con_B_then)
120 stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(schs_A_then_con_B_then_con_h_then)),
123 const auto op_state = stdexec::connect(
124 std::move(schs_A_then_con_B_then_con_h_then),
126 .state = std::addressof(esc_h.
m_state), .runloop_state =
nullptr, .result =
nullptr});
132 const auto& then_op_state = op_state;
138 Kokkos::RangePolicy<host_execution_space, Kokkos::LaunchBounds<1>>
141 static_assert(std::same_as<
decltype(then_op_state.inner_op_state.rcvr), then_rcvr_t>);
145 const auto& con_h_then_op_state = then_op_state.inner_op_state;
146 static_assert(stdexec::__is_instance_of<
147 std::remove_cvref_t<
decltype(con_h_then_op_state)>,
150 using con_h_then_rcvr_t =
decltype(con_h_then_op_state.inner_op_state.rcvr);
152 static_assert(std::same_as<
153 stdexec::env_of_t<con_h_then_rcvr_t>,
159 stdexec::__env::__fwd<Kokkos::Execution::Impl::SyncWait::env>
165 const auto& sfrom_con_h_then_op_state = con_h_then_op_state.inner_op_state;
166 static_assert(stdexec::__is_instance_of<
167 std::remove_cvref_t<
decltype(sfrom_con_h_then_op_state)>,
170 using sfrom_con_h_then_rcvr_t =
decltype(sfrom_con_h_then_op_state.inner_op_state.completion_signal.rcvr);
174 const auto& then_sfrom_con_h_then_op_state = sfrom_con_h_then_op_state.inner_op_state;
175 static_assert(stdexec::__is_instance_of<
176 std::remove_cvref_t<
decltype(then_sfrom_con_h_then_op_state)>,
179 using then_sfrom_con_h_then_rcvr_t =
decltype(then_sfrom_con_h_then_op_state.inner_op_state.rcvr);
180 static_assert(!stdexec::__queryable_with<
181 stdexec::env_of_t<then_sfrom_con_h_then_rcvr_t>,
185 const auto& con_B_then_sfrom_con_h_then_op_state = then_sfrom_con_h_then_op_state.inner_op_state;
186 static_assert(stdexec::__is_instance_of<
187 std::remove_cvref_t<
decltype(con_B_then_sfrom_con_h_then_op_state)>,
190 using con_B_then_sfrom_con_h_then_rcvr_t =
decltype(con_B_then_sfrom_con_h_then_op_state.inner_op_state.rcvr);
191 static_assert(stdexec::__queryable_with<
192 stdexec::env_of_t<con_B_then_sfrom_con_h_then_rcvr_t>,
195 static_assert(std::same_as<
196 stdexec::env_of_t<con_B_then_sfrom_con_h_then_rcvr_t>,
202 stdexec::__env::__fwd<stdexec::env<
207 stdexec::__env::__fwd<Kokkos::Execution::Impl::SyncWait::env>
216 const auto& sfrom_con_B_then_sfrom_con_h_then_op_state = con_B_then_sfrom_con_h_then_op_state.inner_op_state;
217 static_assert(stdexec::__is_instance_of<
218 std::remove_cvref_t<
decltype(sfrom_con_B_then_sfrom_con_h_then_op_state)>,
221 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
222 .completion_signal.rcvr);
223 static_assert(!stdexec::__queryable_with<
224 stdexec::env_of_t<sfrom_con_B_then_sfrom_con_h_then_rcvr_t>,
228 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;
229 static_assert(stdexec::__is_instance_of<
230 std::remove_cvref_t<
decltype(then_sfrom_B_then_sfrom_con_h_then_op_state)>,
233 using then_sfrom_con_B_then_sfrom_con_h_then_rcvr_t =
decltype(then_sfrom_B_then_sfrom_con_h_then_op_state
234 .inner_op_state.rcvr);
235 static_assert(!stdexec::__queryable_with<
236 stdexec::env_of_t<then_sfrom_con_B_then_sfrom_con_h_then_rcvr_t>,
243 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
249 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
253 ::testing::ElementsAre(
257 ASSERT_EQ(data(), 1);
267 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
275 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
279 ::testing::ElementsAre(
285 ASSERT_EQ(data(), 3) <<
"A synchronization is missing.";
292TEST_F(
ContinuesOnTest, transition_to_another_execution_space_instance_and_back_same_type) {
293 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
295 const auto [exec_A, exec_B] = Kokkos::Experimental::partition_space(
exec, 1, 1);
306 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
313 ::testing::ElementsAre(
326 ::testing::ElementsAre(
334 ::testing::ElementsAre(
344 ASSERT_EQ(data(), 3) <<
"A synchronization is missing.";
351TEST_F(
ContinuesOnTest, transition_to_another_execution_space_instance_and_back_different_type) {
352 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
363 using level_B_env_t = stdexec::__env::__fwd<stdexec::env<
368 stdexec::__env::__fwd<level_C_env_t>
370 using level_A_env_t = stdexec::__env::__fwd<stdexec::env<
383 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
390 ::testing::ElementsAre(
395 }
else if constexpr (
397 && std::same_as<host_execution_space, TEST_EXECUTION_SPACE>) {
400 ::testing::ElementsAre(
412 ::testing::ElementsAre(
421 ASSERT_EQ(data(), 3) <<
"A synchronization is missing.";
426 using continues_on_sndr_t =
427 decltype(stdexec::just() | stdexec::continues_on(std::declval<typename ContinuesOnTest::scheduler_t>()));
429 static_assert(std::same_as<
430 stdexec::__demangle_t<continues_on_sndr_t>,
432 stdexec::continues_on_t,
435 stdexec::schedule_from_t,
442 static_assert(stdexec::__detail::__has_nothrow_transform_sender<
444 stdexec::set_value_t,
445 continues_on_sndr_t&&,
449 using schedule_from_sndr_t =
decltype(stdexec::schedule_from(
450 stdexec::schedule(std::declval<typename ContinuesOnTest::scheduler_t>())));
452 static_assert(std::same_as<
453 stdexec::__demangle_t<schedule_from_sndr_t>,
455 stdexec::schedule_from_t,
461 static_assert(stdexec::__detail::__has_nothrow_transform_sender<
463 stdexec::set_value_t,
464 schedule_from_sndr_t&&,
constexpr std::string dispatch_label(const Exec &, Label &&label)
Get the dispatch label from Exec and label.
#define MATCHER_FOR_WAIT_EXEC_EVENT(_exec_, _record_event_variant_)
#define MATCHER_FOR_BEGIN_PFOR(_exec_, _label_)
#define MATCHER_FOR_RECORD_EVENT(_exec_)
#define MATCHER_FOR_BEGIN_FENCE(_exec_, _label_)
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, BeginParallelForEvent, 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()
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()
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< Exec >
Inspired by https://github.com/kokkos/kokkos/blob/69273c3a4e7b6adeb95066341ca201d62fe1e698/core/src/i...
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