kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
test_ensure_started.cpp
Go to the documentation of this file.
1
#include "
kokkos-execution/utils/ignore_warnings.hpp
"
2
PRAGMA_DIAGNOSTIC_PUSH
3
KOKKOS_EXECUTION_STDEXEC_PRAGMA_DIAGNOSTIC_IGNORED
4
#include "exec/ensure_started.hpp"
5
PRAGMA_DIAGNOSTIC_POP
6
7
#include "
kokkos-utils/callbacks/RecorderListener.hpp
"
8
#include "
kokkos-utils/tests/scoped/callbacks/Manager.hpp
"
9
10
#include "
kokkos-execution/execution_space.hpp
"
11
12
#include "
tests/utils/callback_matchers.hpp
"
13
#include "
tests/utils/execution_space_context.hpp
"
14
#include "
tests/utils/functors/increment.hpp
"
15
#include "
tests/utils/stdexec.hpp
"
16
28
29
namespace
Tests::ExecutionSpaceImpl
{
30
31
using namespace
Kokkos::utils::callbacks;
32
33
class
EnsureStartedTest
34
:
public
Tests::Utils::ExecutionSpaceContextTest
<TEST_EXECUTION_SPACE>
35
,
public
Kokkos::utils::tests::scoped::callbacks::Manager
{
36
public
:
37
using
recorder_listener_t
=
RecorderListener
<
38
EventDiscardMatcher<TEST_EXECUTION_SPACE>
,
39
BeginFenceEvent
,
40
BeginParallelForEvent
,
41
Kokkos::Execution::Impl::RecordEvent
,
42
Kokkos::Execution::Impl::WaitEvent
43
>;
44
};
45
47
TEST_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
54
Kokkos::utils::callbacks::Manager::register_listener
(recorder_listener);
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(
66
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"then"
)),
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
85
static_assert
(!
Tests::Utils::has_completion_scheduler_for<sndr_t, stdexec::set_value_t, stdexec::env<>
>);
86
}
87
Kokkos::utils::callbacks::Manager::unregister_listener
(recorder_listener.get());
88
}
89
90
}
// namespace Tests::ExecutionSpaceImpl
RecorderListener.hpp
callback_matchers.hpp
dispatch_label
constexpr std::string dispatch_label(const Exec &, Label &&label)
Get the dispatch label from Exec and label.
Definition
callback_matchers.hpp:47
MATCHER_FOR_BEGIN_PFOR
#define MATCHER_FOR_BEGIN_PFOR(_exec_, _label_)
Definition
callback_matchers.hpp:30
MATCHER_FOR_BEGIN_FENCE
#define MATCHER_FOR_BEGIN_FENCE(_exec_, _label_)
Definition
callback_matchers.hpp:28
Kokkos::utils::callbacks::Manager::unregister_listener
static void unregister_listener(const Callable *const callable)
Kokkos::utils::callbacks::Manager::register_listener
static listener_list_const_iter_t register_listener(std::shared_ptr< Callable > callable)
Kokkos::utils::callbacks::RecorderListener
Tests::ExecutionSpaceImpl::EnsureStartedTest
Definition
test_ensure_started.cpp:35
Tests::ExecutionSpaceImpl::EnsureStartedTest::recorder_listener_t
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, BeginParallelForEvent, Kokkos::Execution::Impl::RecordEvent, Kokkos::Execution::Impl::WaitEvent > recorder_listener_t
Definition
test_ensure_started.cpp:37
Tests::Utils::has_completion_scheduler_for
Definition
stdexec.hpp:15
execution_space.hpp
execution_space_context.hpp
ignore_warnings.hpp
KOKKOS_EXECUTION_STDEXEC_PRAGMA_DIAGNOSTIC_IGNORED
#define KOKKOS_EXECUTION_STDEXEC_PRAGMA_DIAGNOSTIC_IGNORED
Basic list of ignored diagnostics when including anything from stdexec.
Definition
ignore_warnings.hpp:38
increment.hpp
THEN_INCREMENT
#define THEN_INCREMENT(_data_)
Add a then using Tests::Utils::Functors::Increment that may throw. // NOLINTNEXTLINE(cppcoreguideline...
Definition
increment.hpp:59
Tests::ExecutionSpaceImpl
Definition
test_any_sender.cpp:39
EventDiscardMatcher
Matcher to filter out events that are just noise for tests.
Definition
callback_matchers.hpp:83
Kokkos::Execution::ExecutionSpaceContext::get_scheduler
auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler< Exec >
Definition
execution_space.hpp:133
Kokkos::Execution::Impl::RecordEvent
Event to be sent to Kokkos::utils::callbacks::dispatch when calling record.
Definition
event.hpp:54
Kokkos::Execution::Impl::WaitEvent
Event to be sent to Kokkos::utils::callbacks::dispatch when calling wait.
Definition
event.hpp:75
Kokkos::utils::callbacks::BeginFenceEvent
Kokkos::utils::callbacks::BeginParallelForEvent
Kokkos::utils::tests::scoped::ExecutionSpace< Exec >::exec
Exec exec
Kokkos::utils::tests::scoped::callbacks::Manager
Tests::Utils::ContextTest< Kokkos::Execution::ExecutionSpaceContext, Exec >::view_s_t
Kokkos::View< value_t, Kokkos::SharedSpace > view_s_t
Definition
context.hpp:32
Tests::Utils::ContextTest< Kokkos::Execution::ExecutionSpaceContext, Exec >::context_t
Kokkos::Execution::ExecutionSpaceContext< Exec > context_t
Definition
context.hpp:27
Tests::Utils::ExecutionSpaceContextTest
Definition
execution_space_context.hpp:12
Manager.hpp
stdexec.hpp
tests
execution_space
test_ensure_started.cpp
Generated on
for kokkos-execution by
1.18.0