1#ifndef KOKKOS_EXECUTION_TESTS_UTILS_CALLBACK_MATCHERS_HPP
2#define KOKKOS_EXECUTION_TESTS_UTILS_CALLBACK_MATCHERS_HPP
7#include "Kokkos_Core.hpp"
20#define MATCHER_FOR_NAME(_type_, _name_) \
21 ::testing::Field(&Kokkos::utils::callbacks::_type_##Event::name, ::testing::StrEq(_name_))
23#define MATCHER_FOR_DEV_ID(_type_, _exec_) \
25 &Kokkos::utils::callbacks::_type_##Event::dev_id, \
26 ::testing::Eq(Kokkos::Tools::Experimental::device_id(_exec_)))
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()
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_)}))
46template <Kokkos::ExecutionSpace Exec, std::convertible_to<std::
string_view> Label>
48 return std::string(Kokkos::Impl::TypeInfo<Exec>::name()).append(
": ").append(std::forward<Label>(label));
51#if defined(KOKKOS_EXECUTION_IMPL_EVENT_HPP)
57#define MATCHER_FOR_RECORD_EVENT(_exec_) \
60 &Kokkos::Execution::Impl::RecordEvent::dev_id, \
61 ::testing::Eq(Kokkos::Tools::Experimental::device_id(_exec_))))
63#define MATCHER_FOR_WAIT_EVENT(_record_event_variant_) \
66 &Kokkos::Execution::Impl::WaitEvent::event_id, \
67 ::testing::Eq(std::get<Kokkos::Execution::Impl::RecordEvent>(_record_event_variant_).event_id)))
71template <Kokkos::ExecutionSpace Exec>
73#if defined(KOKKOS_ENABLE_SYCL)
76 requires std::same_as<Exec, Kokkos::SYCL>
78 return event.name.find(
"Kokkos::SYCLInternal::USMObject") == std::string::npos;
83 requires std::same_as<Exec, Kokkos::SYCL>
85 return event.alloc.name.find(
"Kokkos::SYCL::USMObject") == std::string::npos;
89 template <Kokkos::utils::callbacks::Event EventType>
constexpr std::string dispatch_label(const Exec &, Label &&label)
Get the dispatch label from Exec and label.
#define DEFINE_EVENT_MATCHER_IN(__namespace__, __eventtype__)
Matcher to filter out events that are just noise for tests.
constexpr bool operator()(const EventType &) const