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_Macros.hpp"
5
#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
6
import
kokkos.core;
7
# include "Kokkos_Assert.hpp"
8
#else
9
# include "Kokkos_Core.hpp"
10
#endif
11
17
18
#if !defined(KOKKOS_ENABLE_IMPL_HPX_ASYNC_DISPATCH)
19
# error "This is not supported."
20
#endif
21
22
namespace
Kokkos::Execution::Impl
{
23
24
template
<>
25
struct
HasNonBlockingDispatch
<
Kokkos
::Experimental::HPX> : std::true_type { };
26
38
template
<>
39
struct
Event
<
Kokkos
::Experimental::HPX> {
40
using
sndr_t
= hpx::execution::experimental::unique_any_sender<>;
41
42
mutable
std::optional<sndr_t>
m_sender
;
43
uint64_t
m_event_id
= invalid_event_id;
44
45
Event
() =
default
;
46
Event
(
const
Event
&) =
delete
;
47
Event
&
operator=
(
const
Event
&) =
delete
;
48
Event
(
Event
&&) noexcept = delete;
49
Event
& operator=(
Event
&&) noexcept = delete;
50
~
Event
() = default;
51
53
void
record
(const
Kokkos
::Experimental::HPX& exec) {
54
KOKKOS_EXPECTS(!
m_sender
.has_value());
55
56
auto
& instance_data = exec.impl_get_instance_data();
57
58
const
std::scoped_lock<hpx::spinlock> lock(instance_data.m_sender_mutex);
59
60
m_sender
= std::move(instance_data.m_sender);
61
62
instance_data.m_sender =
sndr_t
(hpx::execution::experimental::just());
63
}
64
77
void
wait
()
const
{
78
if
(
m_sender
.has_value()) {
79
hpx::this_thread::experimental::sync_wait(std::move(*
m_sender
));
80
m_sender
= std::nullopt;
81
}
82
}
83
};
84
85
template
<Kokkos::ExecutionSpace... Exec>
86
requires
(std::same_as<Exec, Kokkos::Experimental::HPX> && ...)
87
void
impl_wait
(const
Event
<
Kokkos
::Experimental::HPX>&
event
, const
Event
<Exec>&... events) {
88
KOKKOS_EXPECTS(
event
.m_sender.has_value() && (events.m_sender.has_value() && ...));
89
90
hpx::this_thread::experimental::sync_wait(
91
hpx::execution::experimental::when_all(std::move(*
event
.m_sender), std::move(*events.m_sender)...));
92
94
event
.m_sender = std::nullopt;
95
((events.m_sender = std::nullopt), ...);
96
}
97
98
template
<Kokkos::ExecutionSpace... ExecFrom>
99
requires
(std::same_as<ExecFrom, Kokkos::Experimental::HPX> && ...)
100
void
impl_wait
(const
Kokkos
::Experimental::HPX& exec, const
Event
<ExecFrom>&... events) {
101
KOKKOS_EXPECTS((events.m_sender.has_value() && ...));
102
103
auto
& instance_data = exec.impl_get_instance_data();
104
105
const
std::scoped_lock<hpx::spinlock> lock(instance_data.m_sender_mutex);
106
107
auto
& sndr = instance_data.m_sender;
108
sndr = hpx::execution::experimental::when_all(std::move(sndr), std::move(*events.m_sender)...);
109
111
((events.m_sender = std::nullopt), ...);
112
}
113
114
}
// namespace Kokkos::Execution::Impl
115
116
#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:31
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:60
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:43
Kokkos::Execution::Impl::Event< Kokkos::Experimental::HPX >::m_sender
std::optional< sndr_t > m_sender
Definition
event.hpp:42
Kokkos::Execution::Impl::Event< Kokkos::Experimental::HPX >::sndr_t
hpx::execution::experimental::unique_any_sender<> sndr_t
Definition
event.hpp:40
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:53
Kokkos::Execution::Impl::Event< Kokkos::Experimental::HPX >::wait
void wait() const
Definition
event.hpp:77
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:115
Kokkos::Execution::Impl::HasNonBlockingDispatch
Determine if the Kokkos backend has non-blocking dispatch.
Definition
event.hpp:50
kokkos-execution
impl
HPX
event.hpp
Generated on
for kokkos-execution by
1.18.0