kokkos-execution 0.0.1
Loading...
Searching...
No Matches
test_repeat_until.cpp
Go to the documentation of this file.
2PRAGMA_DIAGNOSTIC_PUSH
4#include "exec/repeat_until.hpp"
5#include "exec/single_thread_context.hpp"
6PRAGMA_DIAGNOSTIC_POP
7
11
13
21
33
34namespace Tests::GraphImpl {
35
36using namespace Kokkos::utils::callbacks;
37
52
59 const view_s_t data(Kokkos::view_alloc(exec, "data - shared space"));
60
61 exec::single_thread_context stc{};
62 const context_t gctx{exec};
63
64 unsigned int guard = 0;
65
66 auto sndr = experimental::execution::repeat_until(
67 stdexec::schedule(gctx.get_scheduler()) | THEN_INCREMENT(data) | stdexec::continues_on(stc.get_scheduler())
68 | stdexec::then([&guard]() -> bool { return (++guard) >= 3; }));
69
71
72 const auto recorded_events = Tests::Utils::record_sync_wait<recorder_listener_t>(std::move(sndr));
73
74 ASSERT_THAT(
75 recorded_events,
76 testing::ElementsAre(
79 recorded_events.at(0), device_handle, MATCHER_FOR_GRAPH_ROOT_NODE_OF(recorded_events.at(0))),
80 MATCHER_FOR_GRAPH_SUBMIT(exec, recorded_events.at(0)),
84 recorded_events.at(4), device_handle, MATCHER_FOR_GRAPH_ROOT_NODE_OF(recorded_events.at(4))),
85 MATCHER_FOR_GRAPH_SUBMIT(exec, recorded_events.at(4)),
89 recorded_events.at(8), device_handle, MATCHER_FOR_GRAPH_ROOT_NODE_OF(recorded_events.at(8))),
90 MATCHER_FOR_GRAPH_SUBMIT(exec, recorded_events.at(8)),
91 MATCHER_FOR_BEGIN_FENCE(exec, dispatch_label(exec, "schedule_from"))));
92
93 ASSERT_EQ(data(), 3);
94}
95
96} // namespace Tests::GraphImpl
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_)
Definition category.hpp:10
RecorderListener< ConjunctionMatcher< EventDiscardMatcher< TEST_EXECUTION_SPACE >, GraphEventDiscardMatcher< TEST_EXECUTION_SPACE > >, BeginFenceEvent, BeginParallelForEvent, Kokkos::Execution::GraphImpl::GraphAddNodeEvent, Kokkos::Execution::GraphImpl::GraphCreateEvent, Kokkos::Execution::GraphImpl::GraphInstantiateEvent, Kokkos::Execution::GraphImpl::GraphSubmitEvent > recorder_listener_t
#define KOKKOS_EXECUTION_THREADS_THROWS_ON_SYNC_WAIT_ASSERT_AND_SKIP(_sndr_)
Definition context.hpp:76
#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:64
auto record_sync_wait(Sndr &&sndr)
Definition sync_wait.hpp:14
auto get_scheduler() const noexcept -> GraphImpl::Scheduler< execution_space >
Definition graph.hpp:134
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph node is added.
Definition events.hpp:49
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph is created.
Definition events.hpp:28
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph is instantiated.
Definition events.hpp:85
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph is submitted.
Definition events.hpp:98
Similar to EventDiscardMatcher, for graph-related events.
Definition events.hpp:83
Kokkos::View< value_t, Kokkos::SharedSpace > view_s_t
Definition context.hpp:38
#define MATCHER_FOR_GRAPH_CREATE(_device_handle_)
Definition events.hpp:17
#define MATCHER_FOR_GRAPH_ADDNODE(_graph_create_event_variant_, _device_handle_, _predecessor_,...)
Definition events.hpp:24
#define MATCHER_FOR_GRAPH_SUBMIT(_exec_, _graph_create_event_variant_)
Definition events.hpp:71
#define MATCHER_FOR_GRAPH_ROOT_NODE_OF(_graph_create_event_)
Definition events.hpp:51