34using namespace Kokkos::utils::callbacks;
36class TEST_CATEGORY(ParallelReduceTest)
59 template <
typename...>
class SndrAdptr,
60 bool ExptIsDispatchingSender,
61 template <
typename>
typename ExptTransformSenderType
68 using label_t = std::string;
70 using policy_t = Kokkos::RangePolicy<TEST_EXECUTION_SPACE>;
72 using pred_sndr_t = SndrAdptr<schd_sndr_t, TEST_EXECUTION_SPACE, label_t, functor_t, policy_t, reducer_t>;
81 static_assert(!stdexec::dependent_sender<pred_sndr_t>);
83 stdexec::get_completion_signatures<pred_sndr_t>()
84 == stdexec::completion_signatures<stdexec::set_value_t(), stdexec::set_error_t(std::exception_ptr)>{});
87 static_assert(std::same_as<
88 stdexec::__completion_domain_of_t<stdexec::set_value_t, pred_sndr_t, stdexec::env<>>,
93 static_assert(std::same_as<
99 static_assert(stdexec::sender_to<pred_sndr_t, Tests::Utils::SinkReceiver>);
101 static_assert(std::same_as<
102 stdexec::transform_sender_result_t<pred_sndr_t, stdexec::env_of_t<Tests::Utils::SinkReceiver>>,
113 static_assert(!stdexec::__nothrow_connectable<pred_sndr_t, Tests::Utils::SinkReceiver>);
118template <
typename Sndr,
typename Exec,
typename Label,
typename Functor,
typename Policy,
typename Reducer>
124template <
typename Sndr,
typename Exec,
typename Label,
typename Functor,
typename Policy,
typename Reducer>
137template <
typename ViewType>
140 using policy_t = Kokkos::RangePolicy<TEST_EXECUTION_SPACE>;
141 using iter_space_t = Kokkos::dims<1, int>;
142 using reducer_t = ViewType;
160 static_assert(std::is_nothrow_move_constructible_v<closure_policy_t>);
161 static_assert(std::is_nothrow_move_constructible_v<closure_iter_space_t>);
166static_assert(test_closure_traits<typename TEST_CATEGORY(ParallelReduceTest)::view_s_t>());
167static_assert(test_closure_traits<std::span<int>>());
173 Kokkos::RangePolicy<TEST_EXECUTION_SPACE>,
180 const view_s_t target(Kokkos::view_alloc(
exec,
"data - shared space"));
184 constexpr size_t size = 10;
190 Kokkos::RangePolicy<TEST_EXECUTION_SPACE>(0, size),
196 testing::ElementsAre(
203 ASSERT_EQ(target(), size / 2 * (size - 1));
208 constexpr size_t size = 5;
210 using data_view_t = Kokkos::View<value_t[size], TEST_EXECUTION_SPACE>;
211 using max_loc_t = Kokkos::MaxLoc<value_t, typename TEST_EXECUTION_SPACE::index_type, Kokkos::SharedSpace>;
214 const data_view_t data(Kokkos::view_alloc(Kokkos::WithoutInitializing,
exec));
218 const typename max_loc_t::result_view_type target(Kokkos::view_alloc(
exec));
223 Kokkos::RangePolicy<TEST_EXECUTION_SPACE>(0, 1),
224 KOKKOS_LAMBDA<std::integral T>(
const T) {
232 Kokkos::RangePolicy<TEST_EXECUTION_SPACE>(0, size), max_loc_functor_t{.data = data}, max_loc_t{target}));
236 testing::ElementsAre(
245 ASSERT_EQ(target().val, 56);
246 ASSERT_EQ(target().loc, 3);
251 constexpr size_t size = 10;
253 const view_s_t target(Kokkos::view_alloc(
exec,
"data - shared space"));
259 Kokkos::RangePolicy<TEST_EXECUTION_SPACE>(0, size),
263 using chain_t =
decltype(chain);
266 stdexec::get_completion_signatures<chain_t>()
267 == stdexec::completion_signatures<stdexec::set_value_t(), stdexec::set_error_t(std::exception_ptr)>{});
270 std::same_as<stdexec::__completion_domain_of_t<stdexec::set_value_t, chain_t>, stdexec::indeterminate_domain<>>);
273 auto starts_on = stdexec::starts_on(gctx.
get_scheduler(), std::move(chain));
275 using starts_on_t =
decltype(starts_on);
277 static_assert(stdexec::__has_eptr_completion<chain_t>);
278 static_assert(!stdexec::dependent_sender<starts_on_t>);
280 stdexec::get_completion_signatures<starts_on_t>()
281 == stdexec::completion_signatures<stdexec::set_value_t(), stdexec::set_error_t(std::exception_ptr)>{});
287 testing::ElementsAre(
294 ASSERT_EQ(target(), size / 2 * (size - 1));
constexpr std::string dispatch_label(const Exec &, const std::string_view label)
Get the dispatch label from Exec and label.
#define MATCHER_FOR_BEGIN_FENCE(_exec_, _label_)
#define TEST_CATEGORY(_name_)
RecorderListener< ConjunctionMatcher< EventDiscardMatcher< TEST_EXECUTION_SPACE >, GraphEventDiscardMatcher< TEST_EXECUTION_SPACE > >, BeginFenceEvent, BeginParallelForEvent, BeginParallelReduceEvent, Kokkos::Execution::Impl::RecordEvent, Kokkos::Execution::Impl::WaitEvent, Kokkos::Execution::GraphImpl::GraphAddNodeEvent, Kokkos::Execution::GraphImpl::GraphCreateEvent, Kokkos::Execution::GraphImpl::GraphInstantiateEvent, Kokkos::Execution::GraphImpl::GraphSubmitEvent > recorder_listener_t
Concept for a sender whose completion scheduler is Kokkos::Execution::GraphImpl::Scheduler.
Concept that constrains the type of a sender that dispatches a functor for execution.
typename Kokkos::Impl::NodeCtorProps< Kokkos::Impl::DeviceHandle< Exec >, Label >::uniform_type node_props_t
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 auto display_string_of() noexcept -> std::string_view
constexpr parallel_for_t parallel_for
constexpr parallel_reduce_t parallel_reduce
Kokkos::Execution::Impl::ParallelReduceSender< Sndr, Kokkos::Execution::Impl::ParallelReduceData< Functor, Policy, Reducer, Kokkos::Execution::Impl::Label< Label > > > pred_generic_t
consteval bool test_closure_traits()
consteval bool test_sndr_traits()
Kokkos::Execution::GraphImpl::ParallelReduceSender< Sndr, Kokkos::Execution::GraphImpl::node_props_t< Exec, Label >, Functor, Policy, Reducer > pred_impl_t
auto record_sync_wait(Sndr &&sndr)
consteval bool check_continues_on_after_just_stopped()
Tests::Utils::Functors::NoOp< false, false, false > NoOp
auto get_scheduler() const noexcept -> GraphImpl::Scheduler< execution_space >
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph node is added.
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph is created.
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph is instantiated.
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph is submitted.
Scheduler for a Kokkos::Experimental::Graph.
Event to be sent to Kokkos::utils::callbacks::dispatch when calling record.
Event to be sent to Kokkos::utils::callbacks::dispatch when calling wait.
Similar to EventDiscardMatcher, for graph-related events.
Kokkos::View< value_t, Kokkos::SharedSpace > view_s_t
Kokkos::Execution::GraphContext< Exec > context_t
Can be used in a parallel_reduce to find the greater of the values in data alongside its index.
device_handle_t device_handle
#define MATCHER_FOR_GRAPH_CREATE(_device_handle_)
#define MATCHER_FOR_GRAPH_ADDNODE(_graph_create_event_variant_, _device_handle_, _predecessor_,...)
#define MATCHER_FOR_GRAPH_SUBMIT(_exec_, _graph_create_event_variant_)
#define MATCHER_FOR_GRAPH_ROOT_NODE_OF(_graph_create_event_)
#define MATCHER_FOR_GRAPH_NODE_OF(_graph_add_node_event_)