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_HPX_EVENT_HPP
2
#define KOKKOS_EXECUTION_IMPL_HPX_EVENT_HPP
3
4
#include "Kokkos_Core.hpp"
5
11
12
#if !defined(KOKKOS_ENABLE_IMPL_HPX_ASYNC_DISPATCH)
13
# error "This is not supported."
14
#endif
15
16
namespace
Kokkos::Execution::Impl
{
17
18
template
<>
19
struct
HasNonBlockingDispatch
<
Kokkos
::Experimental::HPX> : std::true_type { };
20
32
template
<>
33
struct
Event
<
Kokkos
::Experimental::HPX> {
34
using
sndr_t
= hpx::execution::experimental::unique_any_sender<>;
35
36
mutable
std::optional<sndr_t>
m_sender
;
37
uint64_t
m_event_id
= invalid_event_id;
38
39
Event
() =
default
;
40
Event
(
const
Event
&) =
delete
;
41
Event
&
operator=
(
const
Event
&) =
delete
;
42
Event
(
Event
&&) noexcept = delete;
43
Event
& operator=(
Event
&&) noexcept = delete;
44
~
Event
() = default;
45
47
void
record
(const
Kokkos
::Experimental::HPX& exec) {
48
KOKKOS_EXPECTS(!
m_sender
.has_value());
49
50
auto
& instance_data = exec.impl_get_instance_data();
51
52
const
std::scoped_lock<hpx::spinlock> lock(instance_data.m_sender_mutex);
53
54
m_sender
= std::move(instance_data.m_sender);
55
56
instance_data.m_sender =
sndr_t
(hpx::execution::experimental::just());
57
}
58
71
void
wait
()
const
{
72
if
(
m_sender
.has_value()) {
73
hpx::this_thread::experimental::sync_wait(std::move(*
m_sender
));
74
m_sender
= std::nullopt;
75
}
76
}
77
};
78
79
template
<Kokkos::ExecutionSpace... Exec>
80
requires
(std::same_as<Exec, Kokkos::Experimental::HPX> && ...)
81
void
impl_wait
(const
Event
<
Kokkos
::Experimental::HPX>&
event
, const
Event
<Exec>&... events) {
82
KOKKOS_EXPECTS(
event
.m_sender.has_value() && (events.m_sender.has_value() && ...));
83
84
hpx::this_thread::experimental::sync_wait(
85
hpx::execution::experimental::when_all(std::move(*
event
.m_sender), std::move(*events.m_sender)...));
86
88
event
.m_sender = std::nullopt;
89
((events.m_sender = std::nullopt), ...);
90
}
91
92
template
<Kokkos::ExecutionSpace... ExecFrom>
93
requires
(std::same_as<ExecFrom, Kokkos::Experimental::HPX> && ...)
94
void
impl_wait
(const
Kokkos
::Experimental::HPX& exec, const
Event
<ExecFrom>&... events) {
95
KOKKOS_EXPECTS((events.m_sender.has_value() && ...));
96
97
auto
& instance_data = exec.impl_get_instance_data();
98
99
const
std::scoped_lock<hpx::spinlock> lock(instance_data.m_sender_mutex);
100
101
auto
& sndr = instance_data.m_sender;
102
sndr = hpx::execution::experimental::when_all(std::move(sndr), std::move(*events.m_sender)...);
103
105
((events.m_sender = std::nullopt), ...);
106
}
107
108
}
// namespace Kokkos::Execution::Impl
109
110
#endif
// KOKKOS_EXECUTION_IMPL_HPX_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::Experimental::HPX >::Event
Event(Event &&) noexcept=delete
Kokkos::Execution::Impl::Event< Kokkos::Experimental::HPX >::Event
Event()=default
Kokkos::Execution::Impl::Event< Kokkos::Experimental::HPX >::Event
Event(const Event &)=delete
Kokkos::Execution::Impl::Event< Kokkos::Experimental::HPX >::m_event_id
uint64_t m_event_id
Definition
event.hpp:37
Kokkos::Execution::Impl::Event< Kokkos::Experimental::HPX >::m_sender
std::optional< sndr_t > m_sender
Definition
event.hpp:36
Kokkos::Execution::Impl::Event< Kokkos::Experimental::HPX >::sndr_t
hpx::execution::experimental::unique_any_sender<> sndr_t
Definition
event.hpp:34
Kokkos::Execution::Impl::Event< Kokkos::Experimental::HPX >::record
void record(const Kokkos::Experimental::HPX &exec)
Steal the head of the underlying sender, and store it in m_sender.
Definition
event.hpp:47
Kokkos::Execution::Impl::Event< Kokkos::Experimental::HPX >::wait
void wait() const
Definition
event.hpp:71
Kokkos::Execution::Impl::Event< Kokkos::Experimental::HPX >::operator=
Event & operator=(const Event &)=delete
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
HPX
event.hpp
Generated on
for kokkos-execution by
1.18.0