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 HasNonBlockingDispatch<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 Event(const Event&) = delete;
24 Event& operator=(const Event&) = delete;
25 Event(Event&& other) noexcept = delete;
26 Event& operator=(Event&& other) noexcept = delete;
27
32 void record(const Kokkos::SYCL& exec) {
33 m_event = exec.sycl_queue().ext_oneapi_submit_barrier();
34 }
35
36 void wait() const {
37 if (m_event.has_value()) {
38 m_event->wait_and_throw();
39 m_event = std::nullopt;
40 }
41 }
42
43 [[nodiscard]]
44 constexpr const sycl::event& sycl_event() const noexcept {
45 KOKKOS_EXPECTS(m_event.has_value());
46 return *m_event;
47 }
48};
49
50template <Kokkos::ExecutionSpace... ExecFrom>
51requires(std::same_as<ExecFrom, Kokkos::SYCL> && ...)
52void impl_wait(const Kokkos::SYCL& exec, const Event<ExecFrom>&... events) {
53 exec.sycl_queue().submit([&](sycl::handler& cgh) { (cgh.depends_on(events.sycl_event()), ...); });
54}
55
56} // namespace Kokkos::Execution::Impl
57
58#endif // KOKKOS_EXECUTION_IMPL_SYCL_EVENT_HPP
static constexpr auto invalid_event_id
Definition event.hpp:51
void impl_wait(const Kokkos::Cuda &exec, const Event< ExecFrom > &... events)
Definition event.hpp:54
Event & operator=(const Event &)=delete
Event(Event &&other) noexcept=delete
void record(const Kokkos::SYCL &exec)
Definition event.hpp:32
constexpr const sycl::event & sycl_event() const noexcept
Definition event.hpp:44
std::optional< sycl::event > m_event
Definition event.hpp:19
Event & operator=(Event &&other) noexcept=delete
An event that can be recorded on an execution space instance.
Definition event.hpp:110
Determine if the Kokkos backend has non-blocking dispatch.
Definition event.hpp:45