1#ifndef KOKKOS_EXECUTION_IMPL_HPX_EVENT_HPP
2#define KOKKOS_EXECUTION_IMPL_HPX_EVENT_HPP
4#include "Kokkos_Core.hpp"
12#if !defined(KOKKOS_ENABLE_IMPL_HPX_ASYNC_DISPATCH)
13# error "This is not supported."
34 using sndr_t = hpx::execution::experimental::unique_any_sender<>;
48 KOKKOS_EXPECTS(!
m_sender.has_value());
50 auto& instance_data = exec.impl_get_instance_data();
52 const std::scoped_lock<hpx::spinlock> lock(instance_data.m_sender_mutex);
54 m_sender = std::move(instance_data.m_sender);
56 instance_data.m_sender =
sndr_t(hpx::execution::experimental::just());
73 hpx::this_thread::experimental::sync_wait(std::move(*
m_sender));
79template <Kokkos::ExecutionSpace... Exec>
80requires(std::same_as<Exec, Kokkos::Experimental::HPX> && ...)
82 KOKKOS_EXPECTS(
event.m_sender.has_value() && (events.m_sender.has_value() && ...));
84 hpx::this_thread::experimental::sync_wait(
85 hpx::execution::experimental::when_all(std::move(*
event.m_sender), std::move(*events.m_sender)...));
88 event.m_sender = std::nullopt;
89 ((events.m_sender = std::nullopt), ...);
92template <Kokkos::ExecutionSpace... ExecFrom>
93requires(std::same_as<ExecFrom, Kokkos::Experimental::HPX> && ...)
95 KOKKOS_EXPECTS((events.m_sender.has_value() && ...));
97 auto& instance_data = exec.impl_get_instance_data();
99 const std::scoped_lock<hpx::spinlock> lock(instance_data.m_sender_mutex);
101 auto& sndr = instance_data.m_sender;
102 sndr = hpx::execution::experimental::when_all(std::move(sndr), std::move(*events.m_sender)...);
105 ((events.m_sender = std::nullopt), ...);
Constrain an EventType type to be a valid event type for Exec execution space type.
static constexpr auto invalid_event_id
void impl_wait(const Kokkos::Cuda &exec, const Event< ExecFrom > &... events)
Event(Event &&) noexcept=delete
Event(const Event &)=delete
std::optional< sndr_t > m_sender
hpx::execution::experimental::unique_any_sender<> sndr_t
void record(const Kokkos::Experimental::HPX &exec)
Steal the head of the underlying sender, and store it in m_sender.
Event & operator=(const Event &)=delete
An event that can be recorded on an execution space instance.
Determine if the Kokkos backend has non-blocking dispatch.