kokkos-execution 0.0.1
Loading...
Searching...
No Matches
get_exec.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_IMPL_GET_EXEC_HPP
2#define KOKKOS_EXECUTION_IMPL_GET_EXEC_HPP
3
4#include "Kokkos_Macros.hpp"
5#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
6import kokkos.core;
7#else
8# include "Kokkos_Core.hpp"
9#endif
10
12
14
20struct get_exec_t : public stdexec::__query<get_exec_t> {
21 using stdexec::__query<get_exec_t>::operator();
22};
23
24inline constexpr get_exec_t get_exec{};
25
26template <typename... Args>
27struct ExecOf;
28
30template <stdexec::sender Sndr, typename... Env>
31struct ExecOf<Sndr, Env...> {
32 using type = typename completion_scheduler_of_t<stdexec::set_value_t, Sndr, Env...>::execution_space;
33};
34
36template <stdexec::__queryable_with<get_exec_t> T>
37struct ExecOf<T> {
38 using type = typename std::remove_cvref_t<stdexec::__query_result_t<T, get_exec_t>>::execution_space;
39};
40
41template <typename... Args>
42using exec_of_t = typename ExecOf<Args...>::type;
43
51template <Kokkos::ExecutionSpace Exec>
53 using execution_space = Exec;
54
56
57 explicit constexpr ExecutionSpaceRef(const execution_space& exec) noexcept
58 : m_exec_ptr(&exec) {
59 }
60
62 ExecutionSpaceRef(const ExecutionSpaceRef&) noexcept = default;
63 ExecutionSpaceRef& operator=(const ExecutionSpaceRef&) noexcept = default;
64 ExecutionSpaceRef(ExecutionSpaceRef&&) noexcept = default;
65 ExecutionSpaceRef& operator=(ExecutionSpaceRef&&) noexcept = default;
66 ~ExecutionSpaceRef() noexcept = default;
67
68 const execution_space& get() const noexcept {
69 return *m_exec_ptr;
70 }
71
72 friend constexpr auto operator<=>(const ExecutionSpaceRef&, const ExecutionSpaceRef&) noexcept = default;
73
74 [[nodiscard]]
75 constexpr const ExecutionSpaceRef& query(const get_exec_t&) const noexcept {
76 return *this;
77 }
78};
79
80} // namespace Kokkos::Execution::Impl
81
82#endif // KOKKOS_EXECUTION_IMPL_GET_EXEC_HPP
std::invoke_result_t< stdexec::get_completion_scheduler_t< Tag >, stdexec::env_of_t< Sndr >, Env... > completion_scheduler_of_t
Retrieve the completion scheduler for a given completion tag.
constexpr get_exec_t get_exec
Definition get_exec.hpp:24
typename ExecOf< Args... >::type exec_of_t
Definition get_exec.hpp:42
typename completion_scheduler_of_t< stdexec::set_value_t, Sndr, Env... >::execution_space type
Definition get_exec.hpp:32
typename std::remove_cvref_t< stdexec::__query_result_t< T, get_exec_t > >::execution_space type
Definition get_exec.hpp:38
ExecutionSpaceRef & operator=(const ExecutionSpaceRef &) noexcept=default
ExecutionSpaceRef(const ExecutionSpaceRef &) noexcept=default
ExecutionSpaceRef(ExecutionSpaceRef &&) noexcept=default
friend constexpr auto operator<=>(const ExecutionSpaceRef &, const ExecutionSpaceRef &) noexcept=default
const execution_space & get() const noexcept
Definition get_exec.hpp:68
constexpr ExecutionSpaceRef(const execution_space &exec) noexcept
Definition get_exec.hpp:57
constexpr const ExecutionSpaceRef & query(const get_exec_t &) const noexcept
Definition get_exec.hpp:75
Kokkos::DefaultExecutionSpace execution_space