kokkos-execution 0.0.1
Loading...
Searching...
No Matches
get_exec.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_EXECUTION_SPACE_GET_EXEC_HPP
2#define KOKKOS_EXECUTION_EXECUTION_SPACE_GET_EXEC_HPP
3
4#include "Kokkos_Core.hpp"
5
7
9
16 : public stdexec::__query<get_exec_t>
17 , stdexec::forwarding_query_t {
18 using stdexec::__query<get_exec_t>::operator();
19};
20
21inline constexpr get_exec_t get_exec{};
22
30template <Kokkos::ExecutionSpace Exec>
32 Exec const * m_exec_ptr;
33
34 explicit constexpr ExecutionSpaceRef(const Exec& exec) noexcept
35 : m_exec_ptr(&exec) {
36 }
37
39 ExecutionSpaceRef(const ExecutionSpaceRef&) noexcept = default;
40 ExecutionSpaceRef& operator=(const ExecutionSpaceRef&) noexcept = default;
41 ExecutionSpaceRef(ExecutionSpaceRef&&) noexcept = default;
42 ExecutionSpaceRef& operator=(ExecutionSpaceRef&&) noexcept = default;
43 ~ExecutionSpaceRef() noexcept = default;
44
45 const Exec& get() const noexcept {
46 return *m_exec_ptr;
47 }
48
49 friend constexpr auto operator<=>(const ExecutionSpaceRef&, const ExecutionSpaceRef&) noexcept = default;
50
51 [[nodiscard]]
52 constexpr const ExecutionSpaceRef& query(const get_exec_t&) const noexcept {
53 return *this;
54 }
55};
56
57// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
58#define KOKKOS_EXECUTION_UPSERT_EXEC_TYPE(_exec_type_, _rcvr_type_) \
59 Impl::upsert_in_env_or_join_t< \
60 Kokkos::Execution::ExecutionSpaceImpl::get_exec_t, \
61 stdexec::__fwd_env_t<stdexec::env_of_t<_rcvr_type_>>, \
62 Kokkos::Execution::ExecutionSpaceImpl::ExecutionSpaceRef<_exec_type_> \
63 >
64
65// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
66#define KOKKOS_EXECUTION_UPSERT_EXEC(_exec_type_, _exec_, _rcvr_type_, _rcvr_) \
67 [[nodiscard]] \
68 constexpr auto get_env() const noexcept -> KOKKOS_EXECUTION_UPSERT_EXEC_TYPE(_exec_type_, _rcvr_type_) { \
69 return Impl::upsert_in_env_or_join( \
70 Kokkos::Execution::ExecutionSpaceImpl::get_exec, \
71 stdexec::__fwd_env(stdexec::get_env(_rcvr_)), \
72 Kokkos::Execution::ExecutionSpaceImpl::ExecutionSpaceRef{_exec_}); \
73 }
74
75} // namespace Kokkos::Execution::ExecutionSpaceImpl
76
77#endif // KOKKOS_EXECUTION_EXECUTION_SPACE_GET_EXEC_HPP
ExecutionSpaceRef & operator=(const ExecutionSpaceRef &) noexcept=default
constexpr ExecutionSpaceRef(const Exec &exec) noexcept
Definition get_exec.hpp:34
constexpr const ExecutionSpaceRef & query(const get_exec_t &) const noexcept
Definition get_exec.hpp:52
friend constexpr auto operator<=>(const ExecutionSpaceRef &, const ExecutionSpaceRef &) noexcept=default
ExecutionSpaceRef(const ExecutionSpaceRef &) noexcept=default
ExecutionSpaceRef(ExecutionSpaceRef &&) noexcept=default