4#include "exec/single_thread_context.hpp"
32using namespace Kokkos::utils::callbacks;
47 using variant_t =
typename recorder_listener_t::event_variant_t;
52 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
56 experimental::execution::single_thread_context stc{};
58 using view_of_5_t = Kokkos::View<value_t[5], typename TEST_EXECUTION_SPACE::memory_space>;
62 | stdexec::let_value([
this]()
noexcept -> stdexec::sender
auto {
64 view_of_5_t{Kokkos::view_alloc(
exec,
"scratch", Kokkos::WithoutInitializing)});
67 static_assert(stdexec::dependent_sender<
decltype(allocate)>);
71 stdexec::get_completion_signatures<
decltype(allocate), stdexec::env<>>()
72 == stdexec::completion_signatures<stdexec::set_value_t(view_of_5_t)>{});
75 auto run = std::move(allocate)
84 | stdexec::let_value([&esc, &data, &stc](
auto&& scratch)
noexcept -> stdexec::sender
auto {
85 static_assert(std::same_as<
decltype(scratch), view_of_5_t&>);
86 EXPECT_EQ(scratch.use_count(), 1);
91 KOKKOS_LAMBDA<std::integral T>(
const T index) {
98 KOKKOS_IF_ON_HOST(EXPECT_EQ(scratch.use_count(), 2);)
99 scratch(index) = index;
100 Kokkos::atomic_add(data.data(), scratch(index));
102 | stdexec::continues_on(stc.get_scheduler())
105 EXPECT_EQ(scratch.use_count(), 2);
106 return std::move(scratch);
111 stdexec::get_completion_signatures<
decltype(run), stdexec::env<>>()
112 == stdexec::completion_signatures<
113 stdexec::set_value_t(view_of_5_t),
114 stdexec::set_error_t(std::exception_ptr)
118 auto check = std::move(run)
119 | stdexec::let_value([&esc, &data](
auto&& scratch)
noexcept -> stdexec::sender
auto {
120 static_assert(std::same_as<
decltype(scratch), view_of_5_t&>);
135 EXPECT_EQ(scratch.use_count(), 2);
138 stdexec::par, 5, KOKKOS_LAMBDA<std::integral T>(
const T index) {
139 Kokkos::atomic_add(data.data(), scratch(index));
146 KOKKOS_IF_ON_HOST(EXPECT_EQ(scratch.use_count(), 2);)
151 stdexec::get_completion_signatures<
decltype(check), stdexec::env<>>()
152 == stdexec::completion_signatures<stdexec::set_value_t(), stdexec::set_error_t(std::exception_ptr)>{});
154 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
161 ASSERT_THAT(recorded_events, [&]() {
194 ASSERT_EQ(data(), 2 * (0 + 1 + 2 + 3 + 4));
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, AllocateDataEvent, DeallocateDataEvent, Kokkos::Execution::Impl::RecordEvent, Kokkos::Execution::Impl::WaitEvent > recorder_listener_t
typename recorder_listener_t::event_variant_t variant_t
#define KOKKOS_EXECUTION_THREADS_THROWS_ON_SYNC_WAIT_ASSERT_AND_SKIP(_sndr_)
#define KOKKOS_EXECUTION_STDEXEC_PRAGMA_DIAGNOSTIC_IGNORED
Basic list of ignored diagnostics when including anything from stdexec.
auto AAllocateDataEvent(Matchers &&... matchers)
auto ADeallocateDataEvent(Matchers &&... matchers)
auto ContainsInOrder(Matchers &&... matchers)
auto record_sync_wait(Sndr &&sndr)
Matcher to filter out events that are just noise for tests.
auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler< Exec >
Event to be sent to Kokkos::utils::callbacks::dispatch when calling record.
Event to be sent to Kokkos::utils::callbacks::dispatch when calling wait.
Kokkos::View< value_t, Kokkos::SharedSpace > view_s_t
Kokkos::Execution::ExecutionSpaceContext< Exec > context_t