kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
test_scoped_region.cpp
Go to the documentation of this file.
1
#include "
kokkos-utils/callbacks/RecorderListener.hpp
"
2
#include "
kokkos-utils/tests/scoped/callbacks/Manager.hpp
"
3
4
#include "
kokkos-execution/execution_space.hpp
"
5
6
#include "
tests/utils/callback_matchers.hpp
"
7
#include "
tests/utils/execution_space_context.hpp
"
8
#include "
tests/utils/functors/increment.hpp
"
9
#include "
tests/utils/sink_receiver.hpp
"
10
#include "
tests/utils/sync_wait.hpp
"
11
23
24
namespace
Tests::ExecutionSpaceImpl
{
25
26
using namespace
Kokkos::utils::callbacks;
27
28
class
ScopedRegionTest
29
:
public
Tests::Utils::ExecutionSpaceContextTest
<TEST_EXECUTION_SPACE>
30
,
public
Kokkos::utils::tests::scoped::callbacks::Manager
{
31
public
:
32
using
recorder_listener_t
=
RecorderListener
<
33
EventDiscardMatcher<TEST_EXECUTION_SPACE>
,
34
BeginFenceEvent
,
35
BeginParallelForEvent
,
36
PushRegionEvent
,
37
PopRegionEvent
,
38
Kokkos::Execution::Impl::RecordEvent
,
39
Kokkos::Execution::Impl::WaitEvent
40
>;
41
};
42
44
consteval
bool
test_sndr_traits
() {
45
using
schd_sndr_t =
typename
ScopedRegionTest::schedule_sender_t
;
46
47
using
scoped_region_sndr_t =
48
decltype
(std::declval<schd_sndr_t>() |
Kokkos::Execution::Profiling::scoped_region
(
"the name of my nice scoped region"
, stdexec::then(KOKKOS_LAMBDA(){})));
49
50
static_assert
(stdexec::__nothrow_connectable<scoped_region_sndr_t, Tests::Utils::SinkReceiver>);
51
52
return
true
;
53
}
54
static_assert
(
test_sndr_traits
());
55
61
TEST_F(
ScopedRegionTest
, many) {
62
const
view_s_t
data(Kokkos::view_alloc(
"data - shared space"
,
exec
));
63
64
const
context_t
esc{
exec
};
65
66
auto
sndr = stdexec::schedule(esc.
get_scheduler
())
67
|
Kokkos::Execution::Profiling::scoped_region
(
68
"the name of my nice scoped region"
,
THEN_INCREMENT
(data) |
THEN_INCREMENT
(data));
69
70
const
auto
recorded_events =
Tests::Utils::record_sync_wait<recorder_listener_t>
(std::move(sndr));
71
72
ASSERT_THAT(recorded_events, [&]() {
73
if
constexpr
(
Kokkos::Execution::Impl::has_non_blocking_dispatch<TEST_EXECUTION_SPACE>
) {
74
return
testing::ElementsAre(
75
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"push"
)),
76
MATCHER_FOR_PUSH_REGION
(
"the name of my nice scoped region"
),
77
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"then"
)),
78
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"then"
)),
79
MATCHER_FOR_RECORD_EVENT
(
exec
),
80
MATCHER_FOR_WAIT_EVENT
(recorded_events.at(4)),
81
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"pop"
)),
82
MATCHER_FOR_POP_REGION
());
83
}
else
{
84
return
testing::ElementsAre(
85
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"push"
)),
86
MATCHER_FOR_PUSH_REGION
(
"the name of my nice scoped region"
),
87
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"then"
)),
88
MATCHER_FOR_BEGIN_PFOR
(
exec
,
dispatch_label
(
exec
,
"then"
)),
89
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"after dispatch"
)),
90
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"pop"
)),
91
MATCHER_FOR_POP_REGION
());
92
}
93
}());
94
}
95
96
}
// namespace Tests::ExecutionSpaceImpl
RecorderListener.hpp
callback_matchers.hpp
MATCHER_FOR_PUSH_REGION
#define MATCHER_FOR_PUSH_REGION(_label_)
Definition
callback_matchers.hpp:35
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_WAIT_EVENT
#define MATCHER_FOR_WAIT_EVENT(_record_event_variant_)
Definition
callback_matchers.hpp:63
MATCHER_FOR_BEGIN_PFOR
#define MATCHER_FOR_BEGIN_PFOR(_exec_, _label_)
Definition
callback_matchers.hpp:30
MATCHER_FOR_RECORD_EVENT
#define MATCHER_FOR_RECORD_EVENT(_exec_)
Definition
callback_matchers.hpp:57
MATCHER_FOR_POP_REGION
#define MATCHER_FOR_POP_REGION()
Definition
callback_matchers.hpp:36
MATCHER_FOR_BEGIN_FENCE
#define MATCHER_FOR_BEGIN_FENCE(_exec_, _label_)
Definition
callback_matchers.hpp:28
Kokkos::utils::callbacks::RecorderListener
Tests::ExecutionSpaceImpl::ScopedRegionTest
Definition
test_scoped_region.cpp:30
Tests::ExecutionSpaceImpl::ScopedRegionTest::recorder_listener_t
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, BeginParallelForEvent, PushRegionEvent, PopRegionEvent, Kokkos::Execution::Impl::RecordEvent, Kokkos::Execution::Impl::WaitEvent > recorder_listener_t
Definition
test_scoped_region.cpp:32
Kokkos::Execution::Impl::has_non_blocking_dispatch
Definition
event.hpp:48
execution_space.hpp
execution_space_context.hpp
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
Kokkos::Execution::Profiling::scoped_region
constexpr Kokkos::Execution::ExecutionSpaceImpl::ScopedRegion scoped_region
Definition
scoped_region.hpp:156
Tests::ExecutionSpaceImpl
Definition
test_any_sender.cpp:39
Tests::ExecutionSpaceImpl::test_sndr_traits
consteval bool test_sndr_traits()
Definition
test_bulk.cpp:49
Tests::Utils::record_sync_wait
auto record_sync_wait(Sndr &&sndr)
Definition
sync_wait.hpp:14
sink_receiver.hpp
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::callbacks::PopRegionEvent
Kokkos::utils::callbacks::PushRegionEvent
Kokkos::utils::tests::scoped::ExecutionSpace< Exec >::exec
Exec exec
Kokkos::utils::tests::scoped::callbacks::Manager
Tests::Utils::ContextTest< Kokkos::Execution::ExecutionSpaceContext, Exec >::schedule_sender_t
decltype(stdexec::schedule(std::declval< scheduler_t >())) schedule_sender_t
Definition
context.hpp:29
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
sync_wait.hpp
tests
execution_space
test_scoped_region.cpp
Generated on
for kokkos-execution by
1.18.0