kokkos-execution 0.0.1
Loading...
Searching...
No Matches
event.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_IMPL_HIP_EVENT_HPP
2#define KOKKOS_EXECUTION_IMPL_HIP_EVENT_HPP
3
4#include "Kokkos_Core.hpp"
5
11
13
14template <>
15struct HasNonBlockingDispatch<Kokkos::HIP> : std::true_type { };
16
17template <>
18struct Event<Kokkos::HIP> {
19 hipEvent_t m_event = nullptr;
21
22 Event() = default;
23 Event(const Event&) = delete;
24 Event& operator=(const Event&) = delete;
25 Event(Event&&) noexcept = delete;
26 Event& operator=(Event&&) noexcept = delete;
27
28 ~Event() {
29 if (m_event != nullptr)
30 KOKKOS_IMPL_HIP_SAFE_CALL(hipEventDestroy(m_event));
31 }
32
33 void record(const Kokkos::HIP& exec) {
34 if (m_event == nullptr) {
35 KOKKOS_IMPL_HIP_SAFE_CALL(hipEventCreateWithFlags(&m_event, hipEventDisableTiming));
36 }
37 KOKKOS_IMPL_HIP_SAFE_CALL(hipEventRecord(m_event, exec.hip_stream()));
38 }
39
40 void wait() const {
41 if (hipEventQuery(m_event) != hipSuccess) {
42 KOKKOS_IMPL_HIP_SAFE_CALL(hipEventSynchronize(m_event));
43 }
44 }
45
46 [[nodiscard]]
47 constexpr hipEvent_t hip_event() const noexcept {
48 return m_event;
49 }
50};
51
52template <Kokkos::ExecutionSpace... ExecFrom>
53requires(std::same_as<ExecFrom, Kokkos::HIP> && ...)
54void impl_wait(const Kokkos::HIP& exec, const Event<ExecFrom>&... events) {
55 auto do_impl_wait = [&exec](const auto& event) {
56 KOKKOS_EXPECTS(bool(event.hip_event()));
57 KOKKOS_IMPL_HIP_SAFE_CALL(hipStreamWaitEvent(exec.hip_stream(), event.hip_event()));
58 };
59 (do_impl_wait(events), ...);
60}
61
62} // namespace Kokkos::Execution::Impl
63
64#endif // KOKKOS_EXECUTION_IMPL_HIP_EVENT_HPP
Constrain an EventType type to be a valid event type for Exec execution space type.
Definition event.hpp:26
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
void record(const Kokkos::HIP &exec)
Definition event.hpp:33
Event & operator=(const Event &)=delete
constexpr hipEvent_t hip_event() const noexcept
Definition event.hpp:47
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