kokkos-execution 0.0.1
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
17
18template <>
19struct HasNonBlockingDispatch<Kokkos::Experimental::HPX> : std::true_type { };
20
21template <>
22struct Event<Kokkos::Experimental::HPX> {
23 mutable std::optional<Kokkos::Experimental::HPX> m_exec = std::nullopt;
25
26 Event() = default;
27 Event(const Event&) = delete;
28 Event& operator=(const Event&) = delete;
29 Event(Event&&) noexcept = delete;
30 Event& operator=(Event&&) noexcept = delete;
31 ~Event() = default;
32
33 void record(const Kokkos::Experimental::HPX& exec) {
34 m_exec = exec;
35 }
36
52 void wait() const {
53 if (m_exec.has_value()) {
54 auto& instance_data = m_exec->impl_get_instance_data();
55
56 {
57 const std::lock_guard<hpx::spinlock> lock(instance_data.m_sender_mutex);
58
59 auto& sndr = instance_data.m_sender;
60 hpx::this_thread::experimental::sync_wait(std::move(sndr));
61 sndr = hpx::execution::experimental::unique_any_sender<>(hpx::execution::experimental::just());
62 }
63
64 m_exec = std::nullopt;
65 }
66 }
67};
68
69} // namespace Kokkos::Execution::Impl
70
71#endif // KOKKOS_EXECUTION_IMPL_HPX_EVENT_HPP
static constexpr auto invalid_event_id
Definition event.hpp:49
std::optional< Kokkos::Experimental::HPX > m_exec
Definition event.hpp:23
void record(const Kokkos::Experimental::HPX &exec)
Definition event.hpp:33
Determine if the Kokkos backend has non-blocking dispatch.
Definition event.hpp:43