kokkos-execution
0.0.1
Toggle main menu visibility
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
12
namespace
Kokkos::Execution::Impl
{
13
14
template
<>
15
struct
HasNonBlockingDispatch
<
Kokkos
::Cuda> : std::true_type { };
16
17
template
<>
18
struct
Event
<
Kokkos
::Cuda> {
19
cudaEvent_t
m_event
=
nullptr
;
20
uint64_t
m_event_id
= invalid_event_id;
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
[[nodiscard]]
47
constexpr
cudaEvent_t
cuda_event
() const noexcept {
48
return
m_event
;
49
}
50
};
51
52
template
<Kokkos::ExecutionSpace... ExecFrom>
53
requires
(std::same_as<ExecFrom, Kokkos::Cuda> && ...)
54
void
impl_wait
(const
Kokkos
::Cuda& exec, const
Event
<ExecFrom>&... events) {
55
const
auto
do_impl_wait = [&exec](
const
auto
&
event
) {
56
KOKKOS_EXPECTS(
bool
(
event
.cuda_event()));
57
KOKKOS_IMPL_CUDA_SAFE_CALL(cudaStreamWaitEvent(exec.cuda_stream(),
event
.cuda_event()));
58
};
59
(do_impl_wait(events), ...);
60
}
61
62
}
// namespace Kokkos::Execution::Impl
63
64
#endif
// KOKKOS_EXECUTION_IMPL_CUDA_EVENT_HPP
Kokkos::Execution::Impl::event
Constrain an EventType type to be a valid event type for Exec execution space type.
Definition
event.hpp:26
Kokkos::Execution::Impl
Definition
attributes.hpp:6
Kokkos::Execution::Impl::impl_wait
void impl_wait(const Kokkos::Cuda &exec, const Event< ExecFrom > &... events)
Definition
event.hpp:54
Kokkos
Kokkos::Execution::Impl::Event< Kokkos::Cuda >::wait
void wait() const
Definition
event.hpp:40
Kokkos::Execution::Impl::Event< Kokkos::Cuda >::cuda_event
constexpr cudaEvent_t cuda_event() const noexcept
Definition
event.hpp:47
Kokkos::Execution::Impl::Event< Kokkos::Cuda >::operator=
Event & operator=(const Event &)=delete
Kokkos::Execution::Impl::Event< Kokkos::Cuda >::Event
Event(Event &&) noexcept=delete
Kokkos::Execution::Impl::Event< Kokkos::Cuda >::Event
Event()=default
Kokkos::Execution::Impl::Event< Kokkos::Cuda >::Event
Event(const Event &)=delete
Kokkos::Execution::Impl::Event< Kokkos::Cuda >::record
void record(const Kokkos::Cuda &exec)
Definition
event.hpp:33
Kokkos::Execution::Impl::Event< Kokkos::Cuda >::m_event
cudaEvent_t m_event
Definition
event.hpp:19
Kokkos::Execution::Impl::Event< Kokkos::Cuda >::m_event_id
uint64_t m_event_id
Definition
event.hpp:20
Kokkos::Execution::Impl::Event
An event that can be recorded on an execution space instance.
Definition
event.hpp:110
Kokkos::Execution::Impl::HasNonBlockingDispatch
Determine if the Kokkos backend has non-blocking dispatch.
Definition
event.hpp:45
kokkos-execution
impl
Cuda
event.hpp
Generated on
for kokkos-execution by
1.18.0