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
47template <>
48void impl_wait(const Kokkos::HIP& exec, const Event<Kokkos::HIP>& event) {
49 KOKKOS_EXPECTS(bool(event.m_event));
50 KOKKOS_IMPL_HIP_SAFE_CALL(hipStreamWaitEvent(exec.hip_stream(), event.m_event));
51}
52
53} // namespace Kokkos::Execution::Impl
54
55#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:24
static constexpr auto invalid_event_id
Definition event.hpp:49
void impl_wait(const Kokkos::Cuda &exec, const Event< Kokkos::Cuda > &event)
Definition event.hpp:48
void record(const Kokkos::HIP &exec)
Definition event.hpp:33
Event & operator=(const Event &)=delete
An event that can be recorded on an execution space instance.
Definition event.hpp:108
Determine if the Kokkos backend has non-blocking dispatch.
Definition event.hpp:43