32using namespace Kokkos::utils::callbacks;
45 using variant_t =
typename recorder_listener_t::event_variant_t;
52template <
template <
typename...>
class SndrAdptr,
bool IsDispatchingSender,
typename... Args>
58 using label_t = std::string;
60 using policy_t = Kokkos::RangePolicy<TEST_EXECUTION_SPACE>;
61 using pfor_sndr_t = SndrAdptr<Args..., schd_sndr_t, label_t, functor_t, policy_t>;
65 static_assert(std::same_as<Kokkos::Execution::Impl::exec_of_t<pfor_sndr_t>, TEST_EXECUTION_SPACE>);
71 static_assert(!stdexec::dependent_sender<pfor_sndr_t>);
73 stdexec::get_completion_signatures<pfor_sndr_t>()
74 == stdexec::completion_signatures<stdexec::set_value_t(), stdexec::set_error_t(std::exception_ptr)>{});
77 static_assert(std::same_as<
78 stdexec::__completion_domain_of_t<stdexec::set_value_t, pfor_sndr_t, stdexec::env<>>,
83 static_assert(std::same_as<
89 static_assert(stdexec::sender_to<pfor_sndr_t, Tests::Utils::SinkReceiver>);
91 static_assert(std::same_as<
92 stdexec::transform_sender_result_t<pfor_sndr_t, stdexec::env_of_t<Tests::Utils::SinkReceiver>>,
103 static_assert(stdexec::__nothrow_connectable<pfor_sndr_t, Tests::Utils::SinkReceiver>);
120 using label_t = std::string;
122 using policy_t = Kokkos::RangePolicy<TEST_EXECUTION_SPACE>;
126 static_assert(stdexec::__sender_for<pfor_sndr_t, Kokkos::Execution::parallel_for_t>);
128 static_assert(std::same_as<
129 stdexec::__data_of<pfor_sndr_t>,
133 static_assert(stdexec::__nbr_children_of<pfor_sndr_t> == 1);
134 static_assert(std::same_as<stdexec::__child_of<pfor_sndr_t>, schd_sndr_t>);
137 static_assert(stdexec::__applicable<
140 const stdexec::env<>&
148template <
typename ViewType>
151 using policy_t = Kokkos::RangePolicy<TEST_EXECUTION_SPACE>;
157 static_assert(std::is_nothrow_move_constructible_v<closure_t>);
168 Kokkos::RangePolicy<TEST_EXECUTION_SPACE>,
174 constexpr int size = 32;
176 const auto [num_teams, team_size] = [&]() {
178#if defined(KOKKOS_ENABLE_HPX)
179 if constexpr (std::same_as<TEST_EXECUTION_SPACE, Kokkos::Experimental::HPX>) {
180 return std::make_tuple(size, 1);
183 const int team_size_ = std::bit_floor(
static_cast<unsigned short>(std::min(
exec.concurrency(), size / 2)));
184 return std::make_tuple(size / team_size_, team_size_);
187 ASSERT_EQ(team_size * num_teams, size);
189 const view_s_t witness(Kokkos::view_alloc(
exec,
"data - shared space"));
196 Kokkos::TeamPolicy<TEST_EXECUTION_SPACE>(num_teams, team_size),
199 stdexec::sync_wait(std::move(chain));
201 ASSERT_EQ(witness(), size / 2 * (size - 1));
204template <
typename ViewType, Kokkos::ExecutionSpace Exec>
207 const ViewType& witness,
209 auto chain = stdexec::schedule(esc.get_scheduler())
211 "passing label, execution policy and functor",
212 Kokkos::RangePolicy<Exec>(0, size),
217 if constexpr (std::same_as<Exec, Kokkos::DefaultExecutionSpace>) {
218 return std::move(chain)
229 constexpr size_t size = 10;
231 const view_s_t witness(Kokkos::view_alloc(
exec,
"data - shared space"));
236 unsigned short int ievent = 0;
238 ASSERT_GE(recorded_events.size(), 3);
249 if constexpr (std::same_as<TEST_EXECUTION_SPACE, Kokkos::DefaultExecutionSpace>) {
258 ASSERT_EQ(witness(), ievent * size / 2 * (size - 1));
263 constexpr size_t size = 10;
265 const view_s_t witness(Kokkos::view_alloc(
exec,
"data - shared space"));
271 std::format(
"{}: hello from pfor", Kokkos::Impl::TypeInfo<TEST_EXECUTION_SPACE>::name()),
272 Kokkos::RangePolicy<TEST_EXECUTION_SPACE>(0, size),
276 .prev = size / 2 * (size - 1), .value = 4, .data = witness.data()})
278 std::format(
"{}: hello again from pfor", Kokkos::Impl::TypeInfo<TEST_EXECUTION_SPACE>::name()),
279 Kokkos::RangePolicy<TEST_EXECUTION_SPACE>(0, 2 * size),
284 testing::ElementsAre(
290 ASSERT_EQ(witness(), size / 2 * (size - 1) + 4 + 2 * size * (2 * size - 1) / 2);
295 constexpr size_t size = 10;
297 const view_s_t witness(Kokkos::view_alloc(
exec,
"data - shared space"));
299 auto chain = stdexec::just()
301 std::format(
"{}: hello from pfor", Kokkos::Impl::TypeInfo<TEST_EXECUTION_SPACE>::name()),
302 Kokkos::RangePolicy<TEST_EXECUTION_SPACE>(0, size),
305 using chain_t =
decltype(chain);
308 stdexec::get_completion_signatures<chain_t>()
309 == stdexec::completion_signatures<stdexec::set_value_t(), stdexec::set_error_t(std::exception_ptr)>{});
312 std::same_as<stdexec::__completion_domain_of_t<stdexec::set_value_t, chain_t>, stdexec::indeterminate_domain<>>);
315 auto starts_on = stdexec::starts_on(esc.
get_scheduler(), std::move(chain));
317 using starts_on_t =
decltype(starts_on);
319 static_assert(stdexec::__has_eptr_completion<chain_t>);
320 static_assert(!stdexec::dependent_sender<starts_on_t>);
322 stdexec::get_completion_signatures<starts_on_t>()
323 == stdexec::completion_signatures<stdexec::set_value_t(), stdexec::set_error_t(std::exception_ptr)>{});
331 static_assert(stdexec::__is_instance_of<
332 stdexec::transform_sender_result_t<
334 stdexec::env_of_t<Kokkos::Execution::Impl::SyncWait::Receiver<TEST_EXECUTION_SPACE>>
336 stdexec::__seq::__sndr
341 ASSERT_THAT(recorded_events, [&]() {
343 return testing::ElementsAre(
348 return testing::ElementsAre(
354 ASSERT_EQ(witness(), size / 2 * (size - 1));
359 constexpr size_t size = 10;
361 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
363 std::atomic<size_t> count = 0;
369 stdexec::sender
auto sndr =
370 stdexec::read_env(stdexec::get_allocator)
376 Kokkos::RangePolicy<TEST_EXECUTION_SPACE>(0, size),
380 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
384 ASSERT_THAT(recorded_events, [&]() {
386 return testing::ElementsAre(
391 return testing::ElementsAre(
397 ASSERT_EQ(data(), size / 2 * (size - 1));
399 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, 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.
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.
constexpr parallel_for_t parallel_for
auto ElementAt(const size_t index, ElementMatcher &&matcher)
consteval bool test_sndr_traits()
auto closure_object_creation_overloads(const size_t size, const ViewType &witness, const Kokkos::Execution::ExecutionSpaceContext< Exec > &esc) -> stdexec::sender auto
consteval bool test_closure_traits()
consteval bool test_sndr_decomposition()
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.
Execution context using a Kokkos execution space under the hood.
auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler< Exec >
Scheduler for a Kokkos 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.
Custom algorithm for the Kokkos::parallel_for construct.
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
Load the value at data and check it is equal to prev. Then, add value to it.
A minimal tracking allocator.