kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
callback_matchers.hpp
Go to the documentation of this file.
1
#ifndef KOKKOS_EXECUTION_TESTS_UTILS_CALLBACK_MATCHERS_HPP
2
#define KOKKOS_EXECUTION_TESTS_UTILS_CALLBACK_MATCHERS_HPP
3
4
#include <string>
5
#include <string_view>
6
7
#include "Kokkos_Core.hpp"
8
9
#include "
kokkos-utils/callbacks/Helpers.hpp
"
10
18
19
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
20
#define MATCHER_FOR_NAME(_type_, _name_) \
21
::testing::Field(&Kokkos::utils::callbacks::_type_##Event::name, ::testing::StrEq(_name_))
22
23
#define MATCHER_FOR_DEV_ID(_type_, _exec_) \
24
::testing::Field( \
25
&Kokkos::utils::callbacks::_type_##Event::dev_id, \
26
::testing::Eq(Kokkos::Tools::Experimental::device_id(_exec_)))
27
28
#define MATCHER_FOR_BEGIN_FENCE(_exec_, _label_) \
29
ABeginFenceEvent(MATCHER_FOR_NAME(BeginFence, _label_), MATCHER_FOR_DEV_ID(BeginFence, _exec_))
30
#define MATCHER_FOR_BEGIN_PFOR(_exec_, _label_) \
31
ABeginParallelForEvent(MATCHER_FOR_NAME(BeginParallelFor, _label_), MATCHER_FOR_DEV_ID(BeginParallelFor, _exec_))
32
#define MATCHER_FOR_BEGIN_PRED(_exec_, _label_) \
33
ABeginParallelReduceEvent( \
34
MATCHER_FOR_NAME(BeginParallelReduce, _label_), MATCHER_FOR_DEV_ID(BeginParallelReduce, _exec_))
35
#define MATCHER_FOR_PUSH_REGION(_label_) APushRegionEventWithName(::testing::StrEq(_label_))
36
#define MATCHER_FOR_POP_REGION() APopRegionEvent()
37
38
#define MATCHER_FOR_BEGIN_DEEP_COPY(_dst_, _src_) \
39
ABeginDeepCopyEvent( \
40
Kokkos::utils::callbacks::PartialMatcher<Kokkos::utils::callbacks::BeginDeepCopyEvent>{}( \
41
Kokkos::utils::callbacks::BeginDeepCopyEvent{ \
42
.dst = KOKKOS_IMPL_STRIP_PARENS(_dst_), .src = KOKKOS_IMPL_STRIP_PARENS(_src_)}))
43
// NOLINTEND(cppcoreguidelines-macro-usage)
44
46
template
<Kokkos::ExecutionSpace Exec, std::convertible_to<std::
string
_view> Label>
47
constexpr
std::string
dispatch_label
(
const
Exec&, Label&& label) {
48
return
std::string(Kokkos::Impl::TypeInfo<Exec>::name()).append(
": "
).append(std::forward<Label>(label));
49
}
50
51
#if defined(KOKKOS_EXECUTION_IMPL_EVENT_HPP)
52
DEFINE_EVENT_MATCHER_IN
(
Kokkos::Execution::Impl
, RecordEvent)
53
DEFINE_EVENT_MATCHER_IN
(
Kokkos::Execution::Impl
, WaitEvent)
54
#endif
55
56
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
57
#define MATCHER_FOR_RECORD_EVENT(_exec_) \
58
ARecordEvent( \
59
::testing::Field( \
60
&Kokkos::Execution::Impl::RecordEvent::dev_id, \
61
::testing::Eq(Kokkos::Tools::Experimental::device_id(_exec_))))
62
63
#define MATCHER_FOR_WAIT_EVENT(_record_event_variant_) \
64
AWaitEvent( \
65
::testing::Field( \
66
&Kokkos::Execution::Impl::WaitEvent::event_id, \
67
::testing::Eq(std::get<Kokkos::Execution::Impl::RecordEvent>(_record_event_variant_).event_id)), \
68
::testing::Field( \
69
&Kokkos::Execution::Impl::WaitEvent::dev_id, ::testing::Eq(Kokkos::Execution::Impl::invalid_dev_id)))
70
71
#define MATCHER_FOR_WAIT_EXEC_EVENT(_exec_, _record_event_variant_) \
72
AWaitEvent( \
73
::testing::Field( \
74
&Kokkos::Execution::Impl::WaitEvent::event_id, \
75
::testing::Eq(std::get<Kokkos::Execution::Impl::RecordEvent>(_record_event_variant_).event_id)), \
76
::testing::Field( \
77
&Kokkos::Execution::Impl::WaitEvent::dev_id, \
78
::testing::Eq(Kokkos::Tools::Experimental::device_id(_exec_))))
79
// NOLINTEND(cppcoreguidelines-macro-usage)
80
82
template
<Kokkos::ExecutionSpace Exec>
83
struct
EventDiscardMatcher
{
84
#if defined(KOKKOS_ENABLE_SYCL)
86
bool
operator()
(
const
Kokkos::utils::callbacks::BeginFenceEvent
& event)
const
87
requires
std::same_as<Exec, Kokkos::SYCL>
88
{
89
return
event
.name.find(
"Kokkos::SYCLInternal::USMObject"
) == std::string::npos;
90
}
91
93
bool
operator()
(
const
Kokkos::utils::callbacks::AllocateDataEvent
& event)
const
94
requires
std::same_as<Exec, Kokkos::SYCL>
95
{
96
return
event
.alloc.name.find(
"Kokkos::SYCL::USMObject"
) == std::string::npos;
97
}
98
#endif
99
#if defined(KOKKOS_ENABLE_THREADS)
101
bool
operator()
(
const
Kokkos::utils::callbacks::BeginFenceEvent
& event)
const
{
102
return
event
.name.find(
"Kokkos::ThreadsInternal::fence: Unnamed Instance Fence"
) == std::string::npos;
103
}
104
#endif
105
106
#if defined(KOKKOS_ENABLE_HPX)
114
bool
operator()
(
const
Kokkos::utils::callbacks::BeginFenceEvent
& event)
const
115
requires
std::same_as<Exec, Kokkos::Experimental::HPX>
116
{
117
return
event
.name !=
"Kokkos::Experimental::HPX: fence on destruction"
;
118
}
119
#endif
120
121
template
<Kokkos::utils::callbacks::Event EventType>
122
constexpr
bool
operator()
(
const
EventType&)
const
{
123
return
true
;
124
}
125
};
126
127
#endif
// KOKKOS_EXECUTION_TESTS_UTILS_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
Helpers.hpp
DEFINE_EVENT_MATCHER_IN
#define DEFINE_EVENT_MATCHER_IN(__namespace__, __eventtype__)
Kokkos::Execution::Impl
Definition
attributes.hpp:6
EventDiscardMatcher
Matcher to filter out events that are just noise for tests.
Definition
callback_matchers.hpp:83
EventDiscardMatcher::operator()
constexpr bool operator()(const EventType &) const
Definition
callback_matchers.hpp:122
Kokkos::utils::callbacks::AllocateDataEvent
Kokkos::utils::callbacks::BeginFenceEvent
tests
utils
callback_matchers.hpp
Generated on
for kokkos-execution by
1.18.0