kokkos-execution 0.0.1
Loading...
Searching...
No Matches
event.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_IMPL_SYCL_EVENT_HPP
2#define KOKKOS_EXECUTION_IMPL_SYCL_EVENT_HPP
3
4#include "Kokkos_Core.hpp"
5
11
13
14template <>
15struct SupportEvents<Kokkos::SYCL> : std::true_type { };
16
17template <>
18struct Event<Kokkos::SYCL> {
19 mutable std::optional<sycl::event> m_event = std::nullopt;
21
22 Event() = default;
23
24 explicit Event(const Kokkos::SYCL& exec) {
25 record(exec);
26 }
27
28 Event(const Event&) = delete;
29 Event& operator=(const Event&) = delete;
30 Event(Event&& other) noexcept
31 : m_event(std::move(other.m_event))
32 , m_event_id(std::exchange(other.m_event_id, invalid_event_id)) {
33 }
34 Event& operator=(Event&& other) noexcept {
35 if (this != &other) {
36 m_event = std::move(other.m_event);
37 m_event_id = std::exchange(other.m_event_id, invalid_event_id);
38 }
39 return *this;
40 }
41
46 void record(const Kokkos::SYCL& exec) {
47 m_event = exec.sycl_queue().ext_oneapi_submit_barrier();
49 }
50
51 void wait() const {
53 if (m_event.has_value()) {
54 m_event->wait_and_throw();
55 m_event = std::nullopt;
56 }
57 }
58};
59
60Event(const Kokkos::SYCL&) -> Event<Kokkos::SYCL>;
61
62} // namespace Kokkos::Execution::Impl
63
64#endif // KOKKOS_EXECUTION_IMPL_SYCL_EVENT_HPP
static constexpr auto invalid_event_id
Definition event.hpp:43
void record_event(const Exec &exec, uint64_t &event_id)
Definition event.hpp:54
Event(const Kokkos::Cuda &) -> Event< Kokkos::Cuda >
void wait_event(const uint64_t event_id)
Definition event.hpp:69
Event & operator=(const Event &)=delete
void record(const Kokkos::SYCL &exec)
Definition event.hpp:46
std::optional< sycl::event > m_event
Definition event.hpp:19
Event & operator=(Event &&other) noexcept
Definition event.hpp:34
An event that can be recorded on an execution space instance.
Definition event.hpp:34
Determine if events are supported.
Definition event.hpp:38