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 SupportEvents<Kokkos::HIP> : std::true_type { };
16
17template <>
18struct Event<Kokkos::HIP> {
19 hipEvent_t m_event = nullptr;
21
22 Event() = default;
23
24 explicit Event(const Kokkos::HIP& 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::exchange(other.m_event, nullptr))
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 if (m_event != nullptr) {
37 KOKKOS_IMPL_HIP_SAFE_CALL(hipEventDestroy(m_event));
38 }
39 m_event = std::exchange(other.m_event, nullptr);
40 m_event_id = std::exchange(other.m_event_id, invalid_event_id);
41 }
42 return *this;
43 }
44
46 if (m_event != nullptr)
47 KOKKOS_IMPL_HIP_SAFE_CALL(hipEventDestroy(m_event));
48 }
49
50 void record(const Kokkos::HIP& exec) {
51 if (m_event == nullptr) {
52 KOKKOS_IMPL_HIP_SAFE_CALL(hipEventCreateWithFlags(&m_event, hipEventDisableTiming));
53 }
54 KOKKOS_IMPL_HIP_SAFE_CALL(hipEventRecord(m_event, exec.hip_stream()));
56 }
57
58 void wait() const {
60 if (hipEventQuery(m_event) != hipSuccess) {
61 KOKKOS_IMPL_HIP_SAFE_CALL(hipEventSynchronize(m_event));
62 }
63 }
64};
65
66Event(const Kokkos::HIP&) -> Event<Kokkos::HIP>;
67
68} // namespace Kokkos::Execution::Impl
69
70#endif // KOKKOS_EXECUTION_IMPL_HIP_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
void record(const Kokkos::HIP &exec)
Definition event.hpp:50
Event & operator=(Event &&other) noexcept
Definition event.hpp:34
Event & operator=(const Event &)=delete
An event that can be recorded on an execution space instance.
Definition event.hpp:34
Determine if events are supported.
Definition event.hpp:38