kokkos-execution 0.0.1
Loading...
Searching...
No Matches
event.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_IMPL_EVENT_HPP
2#define KOKKOS_EXECUTION_IMPL_EVENT_HPP
3
4#include <concepts>
5#include <format>
6
7#include "Kokkos_Core.hpp"
8
9#if defined(KOKKOS_EXECUTION_ENABLE_EVENT_DISPATCH)
11#endif
12
19
21
23template <typename EventType, typename Exec>
24concept event = Kokkos::ExecutionSpace<Exec> && std::default_initializable<EventType>
25 && std::constructible_from<EventType, const Exec&> && std::move_constructible<EventType>
26 && requires(EventType& obj, const Exec& exec) {
27 { obj.record(exec) } -> std::same_as<void>;
28 } && requires(const EventType& obj) {
29 { obj.wait() } -> std::same_as<void>;
30 };
31
33template <Kokkos::ExecutionSpace Exec>
34struct Event;
35
37template <Kokkos::ExecutionSpace Exec>
38struct SupportEvents : std::false_type { };
39
40template <typename Exec>
42
43static constexpr auto invalid_event_id = Kokkos::Experimental::finite_max_v<uint64_t>;
44
47 uint32_t dev_id = 0;
48 uint64_t event_id = 0;
49
50 constexpr auto operator<=>(const RecordEvent&) const = default;
51};
52
53template <Kokkos::ExecutionSpace Exec>
54void record_event(const Exec& exec, uint64_t& event_id) {
55#if defined(KOKKOS_EXECUTION_ENABLE_EVENT_DISPATCH)
58 RecordEvent{.dev_id = Kokkos::Tools::Experimental::device_id(exec), .event_id = event_id});
59#endif
60}
61
63struct WaitEvent {
64 uint64_t event_id = 0;
65
66 constexpr auto operator<=>(const WaitEvent&) const = default;
67};
68
69inline void wait_event(const uint64_t event_id) {
70#if defined(KOKKOS_EXECUTION_ENABLE_EVENT_DISPATCH)
71 Kokkos::utils::callbacks::dispatch(WaitEvent{.event_id = event_id});
72#endif
73}
74
75} // namespace Kokkos::Execution::Impl
76
77#if defined(KOKKOS_ENABLE_CUDA)
79#endif
80#if defined(KOKKOS_ENABLE_HIP)
82#endif
83#if defined(KOKKOS_ENABLE_HPX)
85#endif
86#if defined(KOKKOS_ENABLE_SYCL)
88#endif
89
90#endif // KOKKOS_EXECUTION_IMPL_EVENT_HPP
Constrain an EventType type to be a valid event type for Exec execution space type.
Definition event.hpp:24
static constexpr auto invalid_event_id
Definition event.hpp:43
void record_event(const Exec &exec, uint64_t &event_id)
Definition event.hpp:54
void wait_event(const uint64_t event_id)
Definition event.hpp:69
auto get_next_event_id() noexcept
void dispatch(const EventType &event)
An event that can be recorded on an execution space instance.
Definition event.hpp:34
Event to be sent to Kokkos::utils::callbacks::dispatch when an event is recorded on an execution spac...
Definition event.hpp:46
constexpr auto operator<=>(const RecordEvent &) const =default
Determine if events are supported.
Definition event.hpp:38
Event to be sent to Kokkos::utils::callbacks::dispatch when an event is being waited for.
Definition event.hpp:63
constexpr auto operator<=>(const WaitEvent &) const =default