kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
test_repeat_until.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/repeat_until.hpp"
5
#include "exec/single_thread_context.hpp"
6
PRAGMA_DIAGNOSTIC_POP
7
8
#include "
kokkos-utils/callbacks/RecorderListener.hpp
"
9
#include "
kokkos-utils/tests/scoped/callbacks/Manager.hpp
"
10
11
#include "
kokkos-execution/execution_space.hpp
"
12
13
#include "
tests/utils/callback_matchers.hpp
"
14
#include "
tests/utils/category.hpp
"
15
#include "
tests/utils/execution_space_context.hpp
"
16
#include "
tests/utils/functors/increment.hpp
"
17
#include "
tests/utils/functors/sum_indices.hpp
"
18
#include "
tests/utils/sync_wait.hpp
"
19
31
32
namespace
Tests::ExecutionSpaceImpl
{
33
34
using namespace
Kokkos::utils::callbacks;
35
36
class
TEST_CATEGORY(RepeatEffectUntilTest)
37
:
public
Tests::Utils::ExecutionSpaceContextTest
<TEST_EXECUTION_SPACE>
38
,
public
Kokkos::utils::tests::scoped::callbacks::Manager
{
39
public
:
40
using
recorder_listener_t
=
RecorderListener
<
41
EventDiscardMatcher<TEST_EXECUTION_SPACE>
,
42
BeginFenceEvent
,
43
BeginParallelForEvent
,
44
BeginSingleEvent
,
45
Kokkos::Execution::Impl::RecordEvent
,
46
Kokkos::Execution::Impl::WaitEvent
47
>;
48
};
49
51
TEST_F(
TEST_CATEGORY
(
RepeatEffectUntilTest
), works) {
52
const
view_s_t
data(Kokkos::view_alloc(
exec
,
"data - shared space"
));
53
54
exec::single_thread_context stc{};
55
const
context_t
esc{
exec
};
56
57
unsigned
int
guard = 0;
58
59
auto
sndr = experimental::execution::repeat_until(
60
stdexec::schedule(esc.
get_scheduler
()) |
THEN_INCREMENT
(data) |
BULK_SUM_INDICES
(2, data)
61
| stdexec::continues_on(stc.get_scheduler()) | stdexec::then([&guard]() ->
bool
{ return (++guard) >= 3; }));
62
63
KOKKOS_EXECUTION_THREADS_THROWS_ON_SYNC_WAIT_ASSERT_AND_SKIP
(sndr)
64
65
ASSERT_THAT(
66
Tests::Utils::record_sync_wait<recorder_listener_t>
(std::move(sndr)),
67
testing::ElementsAre(
68
MATCHER_FOR_BEGIN_SINGLE
(
exec
,
dispatch_label
(
exec
,
"then"
)),
69
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"bulk"
)),
70
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"schedule_from"
)),
71
MATCHER_FOR_BEGIN_SINGLE
(
exec
,
dispatch_label
(
exec
,
"then"
)),
72
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"bulk"
)),
73
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"schedule_from"
)),
74
MATCHER_FOR_BEGIN_SINGLE
(
exec
,
dispatch_label
(
exec
,
"then"
)),
75
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"bulk"
)),
76
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"schedule_from"
))));
77
78
ASSERT_EQ(data(), 6);
79
}
80
81
}
// namespace Tests::ExecutionSpaceImpl
RecorderListener.hpp
callback_matchers.hpp
dispatch_label
constexpr std::string dispatch_label(const Exec &, const std::string_view label)
Get the dispatch label from Exec and label.
Definition
callback_matchers.hpp:57
MATCHER_FOR_BEGIN_SINGLE
#define MATCHER_FOR_BEGIN_SINGLE(_exec_, _label_)
Definition
callback_matchers.hpp:42
MATCHER_FOR_BEGIN_PFOR
#define MATCHER_FOR_BEGIN_PFOR(_exec_, _label_)
Definition
callback_matchers.hpp:37
MATCHER_FOR_BEGIN_FENCE
#define MATCHER_FOR_BEGIN_FENCE(_exec_, _label_)
Definition
callback_matchers.hpp:35
category.hpp
TEST_CATEGORY
#define TEST_CATEGORY(_name_)
Definition
category.hpp:10
Kokkos::utils::callbacks::RecorderListener
Tests::ExecutionSpaceImpl::RepeatEffectUntilTest
Definition
test_repeat_until.cpp:38
Tests::ExecutionSpaceImpl::RepeatEffectUntilTest::recorder_listener_t
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, BeginParallelForEvent, BeginSingleEvent, Kokkos::Execution::Impl::RecordEvent, Kokkos::Execution::Impl::WaitEvent > recorder_listener_t
Definition
test_repeat_until.cpp:40
KOKKOS_EXECUTION_THREADS_THROWS_ON_SYNC_WAIT_ASSERT_AND_SKIP
#define KOKKOS_EXECUTION_THREADS_THROWS_ON_SYNC_WAIT_ASSERT_AND_SKIP(_sndr_)
Definition
context.hpp:76
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:44
increment.hpp
THEN_INCREMENT
#define THEN_INCREMENT(_data_)
Add a then using Tests::Utils::Functors::Increment that may throw. // NOLINTNEXTLINE(cppcoreguideline...
Definition
increment.hpp:64
Tests::ExecutionSpaceImpl
Definition
test_any_sender.cpp:39
Tests::Utils::record_sync_wait
auto record_sync_wait(Sndr &&sndr)
Definition
sync_wait.hpp:14
EventDiscardMatcher
Matcher to filter out events that are just noise for tests.
Definition
callback_matchers.hpp:99
Kokkos::Execution::ExecutionSpaceContext::get_scheduler
auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler< execution_space >
Definition
execution_space.hpp:141
Kokkos::Execution::Impl::RecordEvent
Event to be sent to Kokkos::utils::callbacks::dispatch when calling record.
Definition
event.hpp:59
Kokkos::Execution::Impl::WaitEvent
Event to be sent to Kokkos::utils::callbacks::dispatch when calling wait.
Definition
event.hpp:80
Kokkos::utils::callbacks::BeginFenceEvent
Kokkos::utils::callbacks::BeginParallelForEvent
Kokkos::utils::callbacks::BeginSingleEvent
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:38
Tests::Utils::ContextTest< Kokkos::Execution::ExecutionSpaceContext, Exec >::context_t
Kokkos::Execution::ExecutionSpaceContext< Exec > context_t
Definition
context.hpp:33
Tests::Utils::ExecutionSpaceContextTest
Definition
execution_space_context.hpp:12
sum_indices.hpp
BULK_SUM_INDICES
#define BULK_SUM_INDICES(_size_, _data_)
Add a bulk using Tests::Utils::Functors::SumIndices. // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)...
Definition
sum_indices.hpp:37
Manager.hpp
sync_wait.hpp
tests
execution_space
test_repeat_until.cpp
Generated on
for kokkos-execution by
1.18.0