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
BeginSingleEvent
,
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
55
static_assert
(
test_sndr_traits
());
56
62
TEST_F(
ScopedRegionTest
, many) {
63
const
view_s_t
data(Kokkos::view_alloc(
"data - shared space"
,
exec
));
64
65
const
context_t
esc{
exec
};
66
67
auto
sndr = stdexec::schedule(esc.
get_scheduler
())
68
|
Kokkos::Execution::Profiling::scoped_region
(
69
"the name of my nice scoped region"
,
THEN_INCREMENT
(data) |
THEN_INCREMENT
(data));
70
71
const
auto
recorded_events =
Tests::Utils::record_sync_wait<recorder_listener_t>
(std::move(sndr));
72
73
ASSERT_THAT(recorded_events, [&]() {
74
if
constexpr
(
Kokkos::Execution::Impl::has_non_blocking_dispatch<TEST_EXECUTION_SPACE>
) {
75
return
testing::ElementsAre(
76
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"push"
)),
77
MATCHER_FOR_PUSH_REGION
(
"the name of my nice scoped region"
),
78
MATCHER_FOR_BEGIN_SINGLE
(
exec
,
dispatch_label
(
exec
,
"then"
)),
79
MATCHER_FOR_BEGIN_SINGLE
(
exec
,
dispatch_label
(
exec
,
"then"
)),
80
MATCHER_FOR_RECORD_EVENT
(
exec
),
81
MATCHER_FOR_WAIT_EVENT
(recorded_events.at(4)),
82
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"pop"
)),
83
MATCHER_FOR_POP_REGION
());
84
}
else
{
85
return
testing::ElementsAre(
86
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"push"
)),
87
MATCHER_FOR_PUSH_REGION
(
"the name of my nice scoped region"
),
88
MATCHER_FOR_BEGIN_SINGLE
(
exec
,
dispatch_label
(
exec
,
"then"
)),
89
MATCHER_FOR_BEGIN_SINGLE
(
exec
,
dispatch_label
(
exec
,
"then"
)),
90
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"after dispatch"
)),
91
MATCHER_FOR_BEGIN_FENCE
(
exec
,
dispatch_label
(
exec
,
"pop"
)),
92
MATCHER_FOR_POP_REGION
());
93
}
94
}());
95
}
96
97
}
// 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_PUSH_REGION
#define MATCHER_FOR_PUSH_REGION(_label_)
Definition
callback_matchers.hpp:44
MATCHER_FOR_WAIT_EVENT
#define MATCHER_FOR_WAIT_EVENT(_record_event_variant_)
Definition
callback_matchers.hpp:78
MATCHER_FOR_RECORD_EVENT
#define MATCHER_FOR_RECORD_EVENT(_exec_)
Definition
callback_matchers.hpp:72
MATCHER_FOR_POP_REGION
#define MATCHER_FOR_POP_REGION()
Definition
callback_matchers.hpp:45
MATCHER_FOR_BEGIN_FENCE
#define MATCHER_FOR_BEGIN_FENCE(_exec_, _label_)
Definition
callback_matchers.hpp:35
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, BeginSingleEvent, 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:53
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:64
Kokkos::Execution::Profiling::scoped_region
constexpr Kokkos::Execution::ExecutionSpaceImpl::ScopedRegion scoped_region
Definition
scoped_region.hpp:157
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: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::BeginSingleEvent
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:35
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
Manager.hpp
sync_wait.hpp
tests
execution_space
test_scoped_region.cpp
Generated on
for kokkos-execution by
1.18.0