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 using completion_signatures_t = stdexec::__completion_signatures_of_t<pfor_sndr_t, stdexec::env<>>;
73 static_assert(stdexec::__mset_eq<
74 stdexec::__mset<stdexec::set_value_t(), stdexec::set_error_t(std::exception_ptr)>,
75 completion_signatures_t
79 static_assert(std::same_as<
80 stdexec::__completion_domain_of_t<stdexec::set_value_t, pfor_sndr_t, stdexec::env<>>,
85 static_assert(std::same_as<
91 static_assert(stdexec::sender_to<pfor_sndr_t, Tests::Utils::SinkReceiver>);
93 static_assert(std::same_as<
94 stdexec::transform_sender_result_t<pfor_sndr_t, stdexec::env_of_t<Tests::Utils::SinkReceiver>>,
105 static_assert(stdexec::__nothrow_connectable<pfor_sndr_t, Tests::Utils::SinkReceiver>);
122 using label_t = std::string;
124 using policy_t = Kokkos::RangePolicy<TEST_EXECUTION_SPACE>;
128 static_assert(stdexec::__sender_for<pfor_sndr_t, Kokkos::Execution::parallel_for_t>);
130 static_assert(std::same_as<
131 stdexec::__data_of<pfor_sndr_t>,
135 static_assert(stdexec::__nbr_children_of<pfor_sndr_t> == 1);
136 static_assert(std::same_as<stdexec::__child_of<pfor_sndr_t>, schd_sndr_t>);
139 static_assert(stdexec::__applicable<
142 const stdexec::env<>&
150template <
typename ViewType>
153 using policy_t = Kokkos::RangePolicy<TEST_EXECUTION_SPACE>;
159 static_assert(std::is_nothrow_move_constructible_v<closure_t>);
170 Kokkos::RangePolicy<TEST_EXECUTION_SPACE>,
176 constexpr int size = 32;
178 const auto [num_teams, team_size] = [&]() {
180#if defined(KOKKOS_ENABLE_HPX)
181 if constexpr (std::same_as<TEST_EXECUTION_SPACE, Kokkos::Experimental::HPX>) {
182 return std::make_tuple(size, 1);
185 const int team_size_ = std::bit_floor(
static_cast<unsigned short>(std::min(
exec.concurrency(), size / 2)));
186 return std::make_tuple(size / team_size_, team_size_);
189 ASSERT_EQ(team_size * num_teams, size);
191 const view_s_t witness(Kokkos::view_alloc(
exec,
"data - shared space"));
198 Kokkos::TeamPolicy<TEST_EXECUTION_SPACE>(num_teams, team_size),
201 stdexec::sync_wait(std::move(chain));
203 ASSERT_EQ(witness(), size / 2 * (size - 1));
206template <
typename ViewType, Kokkos::ExecutionSpace Exec>
209 const ViewType& witness,
211 auto chain = stdexec::schedule(esc.get_scheduler())
213 "passing label, execution policy and functor",
214 Kokkos::RangePolicy<Exec>(0, size),
219 if constexpr (std::same_as<Exec, Kokkos::DefaultExecutionSpace>) {
220 return std::move(chain)
231 constexpr size_t size = 10;
233 const view_s_t witness(Kokkos::view_alloc(
exec,
"data - shared space"));
238 unsigned short int ievent = 0;
240 ASSERT_GE(recorded_events.size(), 3);
251 if constexpr (std::same_as<TEST_EXECUTION_SPACE, Kokkos::DefaultExecutionSpace>) {
260 ASSERT_EQ(witness(), ievent * size / 2 * (size - 1));
265 constexpr size_t size = 10;
267 const view_s_t witness(Kokkos::view_alloc(
exec,
"data - shared space"));
273 std::format(
"{}: hello from pfor", Kokkos::Impl::TypeInfo<TEST_EXECUTION_SPACE>::name()),
274 Kokkos::RangePolicy<TEST_EXECUTION_SPACE>(0, size),
278 .prev = size / 2 * (size - 1), .value = 4, .data = witness.data()})
280 std::format(
"{}: hello again from pfor", Kokkos::Impl::TypeInfo<TEST_EXECUTION_SPACE>::name()),
281 Kokkos::RangePolicy<TEST_EXECUTION_SPACE>(0, 2 * size),
286 testing::ElementsAre(
292 ASSERT_EQ(witness(), size / 2 * (size - 1) + 4 + 2 * size * (2 * size - 1) / 2);
297 constexpr size_t size = 10;
299 const view_s_t witness(Kokkos::view_alloc(
exec,
"data - shared space"));
301 auto sndr = stdexec::just()
303 std::format(
"{}: hello from pfor", Kokkos::Impl::TypeInfo<TEST_EXECUTION_SPACE>::name()),
304 Kokkos::RangePolicy<TEST_EXECUTION_SPACE>(0, size),
308 auto starts_on = stdexec::starts_on(esc.get_scheduler(), std::move(sndr));
316 static_assert(stdexec::__is_instance_of<
317 stdexec::transform_sender_result_t<
319 stdexec::env_of_t<Kokkos::Execution::Impl::SyncWait::Receiver<TEST_EXECUTION_SPACE>>
321 stdexec::__seq::__sndr
326 ASSERT_THAT(recorded_events, [&]() {
328 return testing::ElementsAre(
333 return testing::ElementsAre(
339 ASSERT_EQ(witness(), size / 2 * (size - 1));
344 constexpr size_t size = 10;
346 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
348 std::atomic<size_t> count = 0;
354 stdexec::sender
auto sndr =
355 stdexec::read_env(stdexec::get_allocator)
361 Kokkos::RangePolicy<TEST_EXECUTION_SPACE>(0, size),
365 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
369 ASSERT_THAT(recorded_events, [&]() {
371 return testing::ElementsAre(
376 return testing::ElementsAre(
382 ASSERT_EQ(data(), size / 2 * (size - 1));
384 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_)
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, BeginParallelForEvent, 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.
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.