kokkos-execution 0.0.1
Loading...
Searching...
No Matches
event.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_IMPL_CUDA_EVENT_HPP
2#define KOKKOS_EXECUTION_IMPL_CUDA_EVENT_HPP
3
4#include "Kokkos_Core.hpp"
5
11
13
14template <>
15struct HasNonBlockingDispatch<Kokkos::Cuda> : std::true_type { };
16
17template <>
18struct Event<Kokkos::Cuda> {
19 cudaEvent_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_CUDA_SAFE_CALL(cudaEventDestroy(m_event));
31 }
32
33 void record(const Kokkos::Cuda& exec) {
34 if (m_event == nullptr) {
35 KOKKOS_IMPL_CUDA_SAFE_CALL(cudaEventCreateWithFlags(&m_event, cudaEventDisableTiming));
36 }
37 KOKKOS_IMPL_CUDA_SAFE_CALL(cudaEventRecord(m_event, exec.cuda_stream()));
38 }
39
40 void wait() const {
41 if (cudaEventQuery(m_event) != cudaSuccess) {
42 KOKKOS_IMPL_CUDA_SAFE_CALL(cudaEventSynchronize(m_event));
43 }
44 }
45};
46
47template <>
48void impl_wait(const Kokkos::Cuda& exec, const Event<Kokkos::Cuda>& event) {
49 KOKKOS_EXPECTS(bool(event.m_event));
50 KOKKOS_IMPL_CUDA_SAFE_CALL(cudaStreamWaitEvent(exec.cuda_stream(), event.m_event));
51}
52
53} // namespace Kokkos::Execution::Impl
54
55#endif // KOKKOS_EXECUTION_IMPL_CUDA_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
Event & operator=(const Event &)=delete
void record(const Kokkos::Cuda &exec)
Definition event.hpp:33
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