kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
check_scheduler_type.hpp
Go to the documentation of this file.
1
#ifndef KOKKOS_EXECUTION_TESTS_UTILS_CHECK_SCHEDULER_TYPE_HPP
2
#define KOKKOS_EXECUTION_TESTS_UTILS_CHECK_SCHEDULER_TYPE_HPP
3
4
#include "
kokkos-execution/stdexec.hpp
"
5
6
#include "
kokkos-execution/impl/attributes.hpp
"
7
#include "
kokkos-execution/impl/completion_signatures.hpp
"
8
#include "
kokkos-execution/impl/env.hpp
"
9
#include "
kokkos-execution/impl/sender_introspection.hpp
"
10
#include "
kokkos-execution/impl/type_traits.hpp
"
11
12
#include "
tests/utils/stdexec.hpp
"
13
19
20
namespace
Tests::Utils
{
21
22
template
<stdexec::sender Sndr,
typename
Tag, stdexec::scheduler Schd>
23
struct
CheckSchedulerTypeSender
;
24
25
template
<
typename
Tag, stdexec::scheduler Schd>
26
struct
check_scheduler_type_t
{
27
[[nodiscard]]
28
constexpr
auto
operator()
() const noexcept {
29
return
stdexec::__closure(*
this
);
30
}
31
32
template
<stdexec::sender Sndr>
33
[[nodiscard]]
34
constexpr
auto
operator()
(Sndr&& sndr)
const
{
35
return
CheckSchedulerTypeSender<Sndr, Tag, Schd>
{std::forward<Sndr>(sndr)};
36
}
37
};
38
39
template
<stdexec::sender Sndr,
typename
Tag, stdexec::scheduler Schd>
40
struct
CheckSchedulerTypeSender
{
41
using
sender_concept
= stdexec::sender_tag;
42
43
Sndr
sndr
;
// NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
44
45
KOKKOS_EXECUTION_COMPL_SIGS_KEEP
(
CheckSchedulerTypeSender
, Sndr)
46
47
template
<stdexec::__decays_to<CheckSchedulerTypeSender> Self, stdexec::receiver Rcvr>
48
[[nodiscard]]
49
constexpr
STDEXEC_EXPLICIT_THIS_BEGIN(
50
auto
connect
)(
this
Self&& self, Rcvr rcvr)
// NOLINT(cppcoreguidelines-missing-std-forward)
51
noexcept
(stdexec::__nothrow_connectable<
KOKKOS_EXECUTION_IMPL_MEMBER_CVREF_T
(Self,
sndr
), Rcvr&&>)
52
-> stdexec::connect_result_t<
KOKKOS_EXECUTION_IMPL_MEMBER_CVREF_T
(Self,
sndr
), Rcvr&&> {
53
static_assert
(
check_scheduler_type<Rcvr>
());
54
return
stdexec::connect(std::forward<Self>(self).
sndr
, std::move(rcvr));
55
}
56
STDEXEC_EXPLICIT_THIS_END(
connect
)
57
58
template
<stdexec::receiver Rcvr>
59
static
consteval
bool
check_scheduler_type
() {
61
if
constexpr
(
Tests::Utils::has_completion_scheduler_for<Sndr, Tag, stdexec::env_of_t<Rcvr>
>) {
62
using
schd_t =
Kokkos::Execution::Impl::completion_scheduler_of_t<Tag, Sndr, stdexec::env_of_t<Rcvr>
>;
63
static_assert
(
64
std::same_as<std::remove_cvref_t<schd_t>, Schd>,
65
"Scheduler type mismatch: completion scheduler doesn't match expected type."
);
66
return
true
;
67
}
69
else
if
constexpr
(stdexec::__queryable_with<stdexec::env_of_t<Rcvr>, stdexec::get_scheduler_t>) {
70
using
schd_t = stdexec::__query_result_t<stdexec::env_of_t<Rcvr>, stdexec::get_scheduler_t>;
71
static_assert
(
72
std::same_as<std::remove_cvref_t<schd_t>, Schd>,
73
"Scheduler type mismatch: receiver scheduler doesn't match expected type."
);
74
return
true
;
75
}
else
{
76
static_assert
(
sizeof
(Rcvr) == 0,
"No scheduler found."
);
77
return
false
;
78
}
79
}
80
81
KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV
(Sndr,
sndr
)
82
};
83
84
template
<
typename
Tag, stdexec::scheduler Schd>
85
inline
constexpr
check_scheduler_type_t<Tag, Schd>
check_scheduler_type
{};
86
87
}
// namespace Tests::Utils
88
89
#endif
// KOKKOS_EXECUTION_TESTS_UTILS_CHECK_SCHEDULER_TYPE_HPP
attributes.hpp
KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV
#define KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV(_type_, _obj_)
Definition
attributes.hpp:30
completion_signatures.hpp
KOKKOS_EXECUTION_COMPL_SIGS_KEEP
#define KOKKOS_EXECUTION_COMPL_SIGS_KEEP(_decayed_self_type_, _sndr_type_)
Definition
completion_signatures.hpp:43
Tests::Utils::has_completion_scheduler_for
Definition
stdexec.hpp:15
env.hpp
stdexec.hpp
Kokkos::Execution::Impl::completion_scheduler_of_t
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.
Definition
sender_introspection.hpp:18
Tests::Utils
Definition
atomic.hpp:59
Tests::Utils::check_scheduler_type
constexpr check_scheduler_type_t< Tag, Schd > check_scheduler_type
Definition
check_scheduler_type.hpp:85
sender_introspection.hpp
Tests::Utils::CheckSchedulerTypeSender
Definition
check_scheduler_type.hpp:40
Tests::Utils::CheckSchedulerTypeSender::check_scheduler_type
static consteval bool check_scheduler_type()
Definition
check_scheduler_type.hpp:59
Tests::Utils::CheckSchedulerTypeSender::sndr
Sndr sndr
Definition
check_scheduler_type.hpp:43
Tests::Utils::CheckSchedulerTypeSender::connect
device constexpr auto connect(_Ts &&... __args) &&noexcept(noexcept(__static_connect(std::move(*this), static_cast< _Ts && >(__args)...))) -> decltype(__static_connect(std::move(*this), static_cast< _Ts && >(__args)...))
Definition
check_scheduler_type.hpp:56
Tests::Utils::CheckSchedulerTypeSender::sender_concept
stdexec::sender_tag sender_concept
Definition
check_scheduler_type.hpp:41
Tests::Utils::check_scheduler_type_t
Definition
check_scheduler_type.hpp:26
Tests::Utils::check_scheduler_type_t::operator()
constexpr auto operator()(Sndr &&sndr) const
Definition
check_scheduler_type.hpp:34
Tests::Utils::check_scheduler_type_t::operator()
constexpr auto operator()() const noexcept
Definition
check_scheduler_type.hpp:28
stdexec.hpp
type_traits.hpp
KOKKOS_EXECUTION_IMPL_MEMBER_CVREF_T
#define KOKKOS_EXECUTION_IMPL_MEMBER_CVREF_T(_Self_, _member_)
Yields the type of member _member_ as accessed from expression _Self_, preserving the cv and ref qual...
Definition
type_traits.hpp:17
tests
utils
check_scheduler_type.hpp
Generated on
for kokkos-execution by
1.18.0