kokkos-execution 0.0.1
Loading...
Searching...
No Matches
test_ensure_started.cpp
Go to the documentation of this file.
2PRAGMA_DIAGNOSTIC_PUSH
4#include "exec/ensure_started.hpp"
5PRAGMA_DIAGNOSTIC_POP
6
8
11
16
28
30
31using namespace Kokkos::utils::callbacks;
32
45
47TEST_F(EnsureStartedTest, then) {
48 const view_s_t data(Kokkos::view_alloc(exec, "data - shared space"));
49
50 const context_t esc{exec};
51
52 const auto recorder_listener = std::make_shared<recorder_listener_t>();
53
55 {
56 auto sndr = stdexec::schedule(esc.get_scheduler()) | THEN_INCREMENT(data)
57 | experimental::execution::ensure_started();
58
59 using sndr_t = decltype(sndr);
60
61 ASSERT_THAT(recorder_listener->recorded_events, ::testing::SizeIs(2));
62 ASSERT_THAT(data(), ::testing::Eq(1));
63 ASSERT_THAT(
64 recorder_listener->recorded_events,
65 testing::ElementsAre(
67 MATCHER_FOR_BEGIN_FENCE(exec, dispatch_label(exec, "after dispatch"))));
68
71 static_assert(!stdexec::__decay_copyable<sndr_t&>);
72
73 stdexec::sync_wait(std::move(sndr));
74
75 ASSERT_THAT(recorder_listener->recorded_events, ::testing::SizeIs(2));
76
78 static_assert(std::same_as<stdexec::__domain_of_t<stdexec::env_of_t<sndr_t>>, stdexec::default_domain>);
79 static_assert(std::same_as<
80 stdexec::__detail::__completing_domain_t<stdexec::set_value_t, sndr_t, stdexec::env<>>,
81 stdexec::default_domain
82 >);
83
86 }
88}
89
90} // namespace Tests::ExecutionSpaceImpl
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_)
static void unregister_listener(const Callable *const callable)
static listener_list_const_iter_t register_listener(std::shared_ptr< Callable > callable)
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, BeginParallelForEvent, Kokkos::Execution::Impl::RecordEvent, Kokkos::Execution::Impl::WaitEvent > recorder_listener_t
#define KOKKOS_EXECUTION_STDEXEC_PRAGMA_DIAGNOSTIC_IGNORED
Basic list of ignored diagnostics when including anything from stdexec.
#define THEN_INCREMENT(_data_)
Add a then using Tests::Utils::Functors::Increment that may throw. // NOLINTNEXTLINE(cppcoreguideline...
Definition increment.hpp:35
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.
Definition event.hpp:52
Event to be sent to Kokkos::utils::callbacks::dispatch when calling wait.
Definition event.hpp:73
Kokkos::Execution::ExecutionSpaceContext< Exec > context_t
Definition context.hpp:27