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_Macros.hpp"
5#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
6import kokkos.core;
7# include "Kokkos_Assert.hpp"
8#else
9# include "Kokkos_Core.hpp"
10#endif
11
17
19
20template <>
21struct HasNonBlockingDispatch<Kokkos::SYCL> : std::true_type { };
22
23template <>
24struct Event<Kokkos::SYCL> {
25 mutable std::optional<sycl::event> m_event = std::nullopt;
26 uint64_t m_event_id = invalid_event_id;
27
28 Event() = default;
29 Event(const Event&) = delete;
30 Event& operator=(const Event&) = delete;
31 Event(Event&& other) noexcept = delete;
32 Event& operator=(Event&& other) noexcept = delete;
33
38 void record(const Kokkos::SYCL& exec) {
39 m_event = exec.sycl_queue().ext_oneapi_submit_barrier();
40 }
41
42 void wait() const {
43 if (m_event.has_value()) {
44 m_event->wait_and_throw();
45 m_event = std::nullopt;
46 }
47 }
48
49 [[nodiscard]]
50 constexpr const sycl::event& sycl_event() const noexcept {
51 KOKKOS_EXPECTS(m_event.has_value());
52 return *m_event;
53 }
54};
55
56template <Kokkos::ExecutionSpace... ExecFrom>
57requires(std::same_as<ExecFrom, Kokkos::SYCL> && ...)
58void impl_wait(const Kokkos::SYCL& exec, const Event<ExecFrom>&... events) {
59 exec.sycl_queue().submit([&](sycl::handler& cgh) { (cgh.depends_on(events.sycl_event()), ...); });
60}
61
62} // namespace Kokkos::Execution::Impl
63
64#endif // KOKKOS_EXECUTION_IMPL_SYCL_EVENT_HPP
void impl_wait(const Kokkos::Cuda &exec, const Event< ExecFrom > &... events)
Definition event.hpp:60
Event & operator=(const Event &)=delete
Event(Event &&other) noexcept=delete
void record(const Kokkos::SYCL &exec)
Definition event.hpp:38
constexpr const sycl::event & sycl_event() const noexcept
Definition event.hpp:50
std::optional< sycl::event > m_event
Definition event.hpp:25
Event & operator=(Event &&other) noexcept=delete
An event that can be recorded on an execution space instance.
Definition event.hpp:115
Determine if the Kokkos backend has non-blocking dispatch.
Definition event.hpp:50