4#include "exec/single_thread_context.hpp"
29using namespace Kokkos::utils::callbacks;
37 using variant_t =
typename recorder_listener_t::event_variant_t;
42 const view_s_t data(Kokkos::view_alloc(
exec,
"data - shared space"));
46 experimental::execution::single_thread_context stc{};
48 using view_of_5_t = Kokkos::View<value_t[5], typename TEST_EXECUTION_SPACE::memory_space>;
52 | stdexec::let_value([
this]()
noexcept -> stdexec::sender
auto {
54 view_of_5_t{Kokkos::view_alloc(
exec,
"scratch", Kokkos::WithoutInitializing)});
61#if defined(KOKKOS_COMPILER_CLANG) && defined(KOKKOS_ENABLE_CUDA)
65 stdexec::__mset<stdexec::set_value_t(view_of_5_t), stdexec::set_error_t(std::exception_ptr)>,
72 stdexec::__mset<stdexec::set_value_t(view_of_5_t)>,
78 auto run = std::move(allocate)
87 | stdexec::let_value([&esc, &data, &stc](
auto&& scratch)
noexcept -> stdexec::sender
auto {
88 static_assert(std::same_as<
decltype(scratch), view_of_5_t&>);
89 EXPECT_EQ(scratch.use_count(), 1);
94 KOKKOS_LAMBDA<std::integral T>(
const T index) {
101 KOKKOS_IF_ON_HOST(EXPECT_EQ(scratch.use_count(), 2);)
102 scratch(index) = index;
103 Kokkos::atomic_add(data.data(), scratch(index));
105 | stdexec::continues_on(stc.get_scheduler())
108 EXPECT_EQ(scratch.use_count(), 2);
109 return std::move(scratch);
115 stdexec::__mset<stdexec::set_value_t(view_of_5_t), stdexec::set_error_t(std::exception_ptr)>,
120 auto check = std::move(run)
121 | stdexec::let_value([&esc, &data](
auto&& scratch)
noexcept -> stdexec::sender
auto {
122 static_assert(std::same_as<
decltype(scratch), view_of_5_t&>);
137 EXPECT_EQ(scratch.use_count(), 2);
140 stdexec::par, 5, KOKKOS_LAMBDA<std::integral T>(
const T index) {
141 Kokkos::atomic_add(data.data(), scratch(index));
148 KOKKOS_IF_ON_HOST(EXPECT_EQ(scratch.use_count(), 2);)
154 stdexec::__mset<stdexec::set_value_t(), stdexec::set_error_t(std::exception_ptr)>,
158 ASSERT_EQ(data(), 0) <<
"Eager execution is not allowed.";
161 recorder_listener_t::record([check = std::move(check)]()
mutable {
162 stdexec::sync_wait(std::move(check));
178 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_BEGIN_PFOR(_exec_, _label_)
#define MATCHER_FOR_BEGIN_FENCE(_exec_, _label_)
RecorderListener< BeginFenceEvent, BeginParallelForEvent, AllocateDataEvent, DeallocateDataEvent > recorder_listener_t
typename recorder_listener_t::event_variant_t variant_t
#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 get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler< Exec >
Kokkos::View< value_t, Kokkos::SharedSpace > view_s_t
Kokkos::Execution::ExecutionSpaceContext< Exec > context_t