kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
make_policy.hpp
Go to the documentation of this file.
1
#ifndef KOKKOS_EXECUTION_IMPL_MAKE_POLICY_HPP
2
#define KOKKOS_EXECUTION_IMPL_MAKE_POLICY_HPP
3
4
#include "
kokkos-execution/stdexec.hpp
"
5
6
#include "Kokkos_Macros.hpp"
7
#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
8
import
kokkos.core;
9
import
kokkos.core_impl;
10
#else
11
# include "Kokkos_Core.hpp"
12
#endif
13
14
#include "
kokkos-execution/impl/iteration_space.hpp
"
15
#include "
kokkos-execution/impl/properties.hpp
"
16
17
namespace
Kokkos::Execution::Impl
{
18
20
template
<
typename
ExecPolicy,
typename
Exec>
21
concept
updatable_to
= Kokkos::ExecutionPolicy<ExecPolicy> && std::same_as<Exec, typename ExecPolicy::execution_space>
22
&&
requires
(
const
ExecPolicy& policy,
const
Exec& exec) {
23
ExecPolicy{Kokkos::Impl::PolicyUpdate{}, policy, exec};
24
};
25
32
template
<Kokkos::ExecutionSpace Exec,
typename
... Properties>
33
struct
make_policy_t
{
34
[[nodiscard]]
35
auto
operator()
(
const
Exec& exec)
const
noexcept
-> Kokkos::SinglePolicy<Exec, Properties...> {
36
return
{exec};
37
}
38
39
template
<extents Extents>
40
requires
(Extents::rank() == 1)
41
[[nodiscard]]
42
auto
operator
()(
const
Exec& exec,
const
Extents&
extents
)
const
noexcept
43
-> Kokkos::RangePolicy<Exec, Properties...> {
44
return
{exec, 0,
extents
.extent(0)};
45
}
46
47
template
<range_slice_with_default_str
id
e RangeSlice>
48
[[nodiscard]]
49
auto
operator()
(
const
Exec& exec,
const
RangeSlice& rgsl)
const
noexcept
50
-> Kokkos::RangePolicy<Exec, Properties...> {
51
return
{exec, rgsl.first, rgsl.last};
52
}
53
54
template
<updatable_to<Exec> ExecPolicy>
55
requires
(
sizeof
...(Properties) == 0)
56
[[nodiscard]]
57
auto
operator
()(
const
Exec& exec,
const
ExecPolicy& policy)
const
noexcept
-> ExecPolicy {
58
return
ExecPolicy{Kokkos::Impl::PolicyUpdate{}, policy, exec};
59
}
60
61
static
Exec
default_instance
() noexcept {
62
return
Exec{};
63
}
64
65
template
<
typename
... Args>
66
requires
(!Kokkos::ExecutionSpace<std::remove_cvref_t<Args>> && ...)
67
[[nodiscard]]
68
auto
operator()
(Args&&... args)
const
69
STDEXEC_AUTO_RETURN(this->
operator
()(
default_instance
(), std::forward<Args>(args)...))
70
};
71
72
template
<Kokkos::ExecutionSpace Exec,
typename
... Properties>
73
inline
constexpr
make_policy_t
<Exec, Properties...>
make_policy
{};
74
75
template
<
typename
MakePolicy,
typename
... Args>
76
requires
stdexec::__is_instance_of<std::remove_cvref_t<MakePolicy>, make_policy_t>
77
using
make_policy_result_t
= std::invoke_result_t<
const
MakePolicy&, Args...>;
78
79
}
// namespace Kokkos::Execution::Impl
80
81
#endif
// KOKKOS_EXECUTION_IMPL_MAKE_POLICY_HPP
Kokkos::Execution::Impl::extents
Definition
iteration_space.hpp:17
Kokkos::Execution::Impl::updatable_to
Only the execution space instance, not its type, can be bound late.
Definition
make_policy.hpp:21
iteration_space.hpp
properties.hpp
stdexec.hpp
Kokkos::Execution::Impl
Definition
attributes.hpp:6
Kokkos::Execution::Impl::make_policy
constexpr make_policy_t< Exec, Properties... > make_policy
Definition
make_policy.hpp:73
Kokkos::Execution::Impl::make_policy_result_t
std::invoke_result_t< const MakePolicy &, Args... > make_policy_result_t
Definition
make_policy.hpp:77
Kokkos::Execution::Impl::make_policy_t
Utility functions that wrap constructors of Kokkos execution policies.
Definition
make_policy.hpp:33
Kokkos::Execution::Impl::make_policy_t::operator()
auto operator()(Args &&... args) const noexcept(noexcept(this->operator()(default_instance(), std::forward< Args >(args)...))) -> decltype(this->operator()(default_instance(), std::forward< Args >(args)...))
Definition
make_policy.hpp:68
Kokkos::Execution::Impl::make_policy_t::default_instance
static Exec default_instance() noexcept
Definition
make_policy.hpp:61
Kokkos::Execution::Impl::make_policy_t::operator()
auto operator()(const Exec &exec) const noexcept -> Kokkos::SinglePolicy< Exec, Properties... >
Definition
make_policy.hpp:35
Kokkos::Execution::Impl::make_policy_t::operator()
auto operator()(const Exec &exec, const RangeSlice &rgsl) const noexcept -> Kokkos::RangePolicy< Exec, Properties... >
Definition
make_policy.hpp:49
kokkos-execution
impl
make_policy.hpp
Generated on
for kokkos-execution by
1.18.0