kokkos-execution
0.0.1
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
PRAGMA_DIAGNOSTIC_POP
6
7
#include "
kokkos-utils/callbacks/RecorderListener.hpp
"
8
#include "
kokkos-utils/tests/scoped/callbacks/Manager.hpp
"
9
10
#include "
tests/utils/callback_matchers.hpp
"
11
#include "
tests/utils/execution_space_context.hpp
"
12
#include "
tests/utils/functors/increment.hpp
"
13
#include "
tests/utils/functors/sum_indices.hpp
"
14
26
27
namespace
Tests::ExecutionSpaceImpl
{
28
29
using namespace
Kokkos::utils::callbacks;
30
31
class
RepeatEffectUntilTest
32
:
public
Tests::Utils::ExecutionSpaceContextTest
<TEST_EXECUTION_SPACE>
33
,
public
Kokkos::utils::tests::scoped::callbacks::Manager
{
34
public
:
35
using
recorder_listener_t
=
36
RecorderListener<EventDiscardMatcher<TEST_EXECUTION_SPACE>
,
BeginFenceEvent
,
BeginParallelForEvent
>;
37
};
38
40
TEST_F(
RepeatEffectUntilTest
, works) {
41
const
view_s_t
data(Kokkos::view_alloc(
exec
,
"data - shared space"
));
42
43
const
context_t
esc{
exec
};
44
45
auto
chain = stdexec::schedule(esc.
get_scheduler
()) |
THEN_INCREMENT
(data) |
BULK_SUM_INDICES
(2, data);
46
47
ASSERT_THAT(
48
recorder_listener_t::record([chain = std::move(chain)]()
mutable
{
49
unsigned
int
guard = 0;
50
stdexec::sync_wait(
51
experimental::execution::repeat_until(
52
std::move(chain) | stdexec::continues_on(stdexec::inline_scheduler{})
53
| stdexec::then([&guard]() ->
bool
{
return
(++guard) >= 3; })));
54
}),
55
testing::ElementsAre(
56
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"then"
)),
57
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"bulk"
)),
58
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"schedule_from"
)),
59
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"then"
)),
60
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"bulk"
)),
61
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"schedule_from"
)),
62
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"then"
)),
63
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"bulk"
)),
64
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"schedule_from"
))));
65
66
ASSERT_EQ(data(), 6);
67
}
68
69
}
// 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::RecorderListener
Tests::ExecutionSpaceImpl::RepeatEffectUntilTest
Definition
test_repeat_until.cpp:33
Tests::ExecutionSpaceImpl::RepeatEffectUntilTest::recorder_listener_t
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, BeginParallelForEvent > recorder_listener_t
Definition
test_repeat_until.cpp:35
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:35
Tests::ExecutionSpaceImpl
Definition
test_any_sender.cpp:33
Kokkos::Execution::ExecutionSpaceContext::get_scheduler
auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler< Exec >
Definition
execution_space.hpp:136
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:30
Tests::Utils::ContextTest< Kokkos::Execution::ExecutionSpaceContext, Exec >::context_t
Kokkos::Execution::ExecutionSpaceContext< Exec > context_t
Definition
context.hpp:25
Tests::Utils::ExecutionSpaceContextTest
Definition
execution_space_context.hpp:11
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:32
Manager.hpp
tests
execution_space
test_repeat_until.cpp
Generated on
for kokkos-execution by
1.15.0