1#include "gtest/gtest.h"
23#if !defined(KOKKOS_EXECUTION_ENABLE_EVENT_DISPATCH)
24# error "This is not supported."
29using namespace Kokkos::utils::callbacks;
41 template <Kokkos::ExecutionSpace Exec>
43#if defined(KOKKOS_ENABLE_CUDA)
44 if constexpr (std::same_as<Exec, Kokkos::Cuda>)
47#if defined(KOKKOS_ENABLE_HIP)
48 if constexpr (std::same_as<Exec, Kokkos::HIP>)
51#if defined(KOKKOS_ENABLE_HPX)
52 if constexpr (std::same_as<Exec, Kokkos::Experimental::HPX>)
55#if defined(KOKKOS_ENABLE_SYCL)
56 if constexpr (std::same_as<Exec, Kokkos::SYCL>)
76template <Kokkos::ExecutionSpace Exec>
86template <Kokkos::ExecutionSpace Exec>
92#define KOKKOS_EXECUTION_TESTS_IMPL_EVENT(_fixture_, _name_, _statement_) \
93 TEST_F(_fixture_, _name_) { \
94 if constexpr (EventTest::has_support<TEST_EXECUTION_SPACE>) { \
95 test_event_##_name_ _statement_; \
97 GTEST_SKIP() << Kokkos::Impl::TypeInfo<TEST_EXECUTION_SPACE>::name() << " does not support events."; \
102template <Kokkos::ExecutionSpace Exec>
104 const auto recorded_events = EventTest::recorder_listener_t::record([&exec]() {
110 ASSERT_EQ(recorded_events.size(), 2);
118template <Kokkos::ExecutionSpace Exec>
120 const auto recorded_events = EventTest::recorder_listener_t::record([&exec]() {
128 ASSERT_EQ(recorded_events.size(), 1);
135template <Kokkos::ExecutionSpace Exec>
137 const auto recorded_events = EventTest::recorder_listener_t::record([&exec]() {
147 ASSERT_THAT(recorded_events, ::testing::SizeIs(6));
159template <Kokkos::ExecutionSpace Exec>
161 const auto recorded_events = EventTest::recorder_listener_t::record([&exec]() {
169 ASSERT_THAT(recorded_events, ::testing::SizeIs(4));
181template <Kokkos::ExecutionSpace Exec>
193template <Kokkos::ExecutionSpace Exec>
195 const auto recorded_events = EventTest::recorder_listener_t::record([&exec]() {
197 event_before.record(exec);
199 event_after.record(exec);
204 ASSERT_THAT(recorded_events, ::testing::SizeIs(2));
210 std::get<Kokkos::Execution::Impl::RecordEvent>(recorded_events.at(0)).event_id,
211 std::get<Kokkos::Execution::Impl::RecordEvent>(recorded_events.at(1)).event_id);
217template <Kokkos::ExecutionSpace Exec>
228 const Exec default_exec{};
230 const auto recorded_events = recorder_listener_with_fence_t::record([&default_exec]() {
236 ASSERT_THAT(recorded_events, ::testing::SizeIs(2));
#define MATCHER_FOR_WAIT_EVENT(_record_event_variant_)
#define MATCHER_FOR_RECORD_EVENT(_exec_)
static bool is_initialized()
Fixture that does not set any Kokkos::utils::callbacks::Manager callback.
static constexpr bool has_support
Fixture that enables callbacks with Kokkos::utils::tests::scoped::callbacks::Manager.
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, Kokkos::Execution::Impl::RecordEvent, Kokkos::Execution::Impl::WaitEvent > recorder_listener_t
Constrain an EventType type to be a valid event type for Exec execution space type.
void test_event_record_and_wait_no_check(const Exec &exec)
consteval bool test_models_event()
void test_event_record_and_wait(const Exec &exec)
void test_event_default_instance()
void test_event_record_and_wait_many_times(const Exec &exec)
void test_event_uniqueness(const Exec &exec)
void test_event_record_and_wait_and_record_and_wait(const Exec &exec)
consteval bool test_support_events()
void test_event_record_but_dont_wait(const Exec &exec)
Matcher to filter out events that are just noise for tests.
An event that can be recorded on an execution space instance.
Event to be sent to Kokkos::utils::callbacks::dispatch when an event is recorded on an execution spac...
Event to be sent to Kokkos::utils::callbacks::dispatch when an event is being waited for.
#define KOKKOS_EXECUTION_TESTS_IMPL_EVENT(_fixture_, _name_, _statement_)