kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
then.hpp
Go to the documentation of this file.
1
#ifndef KOKKOS_EXECUTION_EXECUTION_SPACE_THEN_HPP
2
#define KOKKOS_EXECUTION_EXECUTION_SPACE_THEN_HPP
3
4
#include "
kokkos-execution/execution_space/execution_space_fwd.hpp
"
5
6
#include "
kokkos-execution/execution_space/parallel_for.hpp
"
7
#include "
kokkos-execution/execution_space/sender_concepts.hpp
"
8
#include "
kokkos-execution/impl/dispatch_label.hpp
"
9
#include "
kokkos-execution/impl/sender_introspection.hpp
"
10
11
namespace
Kokkos::Execution::ExecutionSpaceImpl
{
12
14
template
<
typename
Functor>
15
requires
(std::same_as<void, std::invoke_result_t<Functor>>)
16
struct
ThenWrapper
{
17
Functor
functor
;
// NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
18
19
template
<std::
int
egral T>
20
KOKKOS_FUNCTION
void
operator()
(
const
T)
const
{
21
functor
();
22
}
23
};
24
25
template
<>
26
struct
TransformSenderFor
<
stdexec
::then_t> {
27
template
<
typename
Sndr,
typename
Env>
28
using
policy_t
= Kokkos::RangePolicy<Impl::exec_of_t<Sndr, Env>, Kokkos::LaunchBounds<1>>;
29
30
template
<
typename
Env,
typename
Functor,
typename
Sndr>
31
using
trnsfrmd_sndr_t
=
32
ParallelForSender<stdexec::then_t, Sndr, std::string_view, ThenWrapper<Functor>
,
policy_t<Sndr, Env>
>;
33
34
template
<
typename
Env,
typename
Functor,
typename
Sndr>
35
requires
stdexec::__sends<stdexec::set_value_t, Sndr, Env>
36
auto
operator()
(
const
Env& env, stdexec::then_t, Functor&& functor, Sndr&& sndr)
const
37
noexcept
(std::is_nothrow_constructible_v<
38
trnsfrmd_sndr_t<Env, Functor, Sndr>
,
39
typename
trnsfrmd_sndr_t<Env, Functor, Sndr>::closure_t
&&,
40
Sndr&&
41
>) {
42
if
constexpr
(
execution_space_completing_sender<Sndr, Env>
) {
43
const
auto
schd = stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(sndr), env);
44
45
return
trnsfrmd_sndr_t<Env, Functor, Sndr>
{
46
{{
Impl::dispatch_label<Impl::exec_of_t<Sndr, Env>
,
": then"
>(),
47
ThenWrapper<Functor>
{std::forward<Functor>(functor)},
48
policy_t<Sndr, Env>
(schd.state->exec, 0, 1)}},
49
std::forward<Sndr>(sndr)};
50
}
else
{
51
return
no_execution_space_scheduler_in_env<stdexec::then_t, Sndr, Env>
();
52
}
53
}
54
};
55
56
}
// namespace Kokkos::Execution::ExecutionSpaceImpl
57
58
#endif
// KOKKOS_EXECUTION_EXECUTION_SPACE_THEN_HPP
Kokkos::Execution::ExecutionSpaceImpl::execution_space_completing_sender
Concept for a sender whose completion scheduler is Kokkos::Execution::ExecutionSpaceImpl::Scheduler.
Definition
sender_concepts.hpp:12
dispatch_label.hpp
parallel_for.hpp
sender_concepts.hpp
execution_space_fwd.hpp
Kokkos::Execution::ExecutionSpaceImpl
Definition
execution_space.hpp:22
Kokkos::Execution::ExecutionSpaceImpl::no_execution_space_scheduler_in_env
auto no_execution_space_scheduler_in_env() noexcept
Show a better compile diagnostic when there is no Kokkos::Execution::ExecutionSpaceImpl::Scheduler fo...
Definition
sender_concepts.hpp:31
Kokkos::Execution::Impl::dispatch_label
consteval std::string_view dispatch_label() noexcept
View the dispatch label as a std::string_view.
Definition
dispatch_label.hpp:47
stdexec
Definition
when_all.hpp:16
sender_introspection.hpp
Kokkos::Execution::ExecutionSpaceImpl::ParallelForSender
Definition
parallel_for.hpp:37
Kokkos::Execution::ExecutionSpaceImpl::ParallelForSender< stdexec::then_t, Sndr, std::string_view, ThenWrapper< Functor >, policy_t< Sndr, Env > >::closure_t
ParallelForClosure< std::string_view, Functor, ExecPolicy > closure_t
Definition
parallel_for.hpp:40
Kokkos::Execution::ExecutionSpaceImpl::ThenWrapper
Inspired by https://github.com/kokkos/kokkos/blob/69273c3a4e7b6adeb95066341ca201d62fe1e698/core/src/i...
Definition
then.hpp:16
Kokkos::Execution::ExecutionSpaceImpl::ThenWrapper::operator()
void operator()(const T) const
Definition
then.hpp:20
Kokkos::Execution::ExecutionSpaceImpl::ThenWrapper::functor
Functor functor
Definition
then.hpp:17
Kokkos::Execution::ExecutionSpaceImpl::TransformSenderFor< stdexec::then_t >::policy_t
Kokkos::RangePolicy< Impl::exec_of_t< Sndr, Env >, Kokkos::LaunchBounds< 1 > > policy_t
Definition
then.hpp:28
Kokkos::Execution::ExecutionSpaceImpl::TransformSenderFor< stdexec::then_t >::trnsfrmd_sndr_t
ParallelForSender< stdexec::then_t, Sndr, std::string_view, ThenWrapper< Functor >, policy_t< Sndr, Env > > trnsfrmd_sndr_t
Definition
then.hpp:31
Kokkos::Execution::ExecutionSpaceImpl::TransformSenderFor< stdexec::then_t >::operator()
auto operator()(const Env &env, stdexec::then_t, Functor &&functor, Sndr &&sndr) const noexcept(std::is_nothrow_constructible_v< trnsfrmd_sndr_t< Env, Functor, Sndr >, typename trnsfrmd_sndr_t< Env, Functor, Sndr >::closure_t &&, Sndr && >)
Definition
then.hpp:36
Kokkos::Execution::ExecutionSpaceImpl::TransformSenderFor
Definition
execution_space_fwd.hpp:12
kokkos-execution
execution_space
then.hpp
Generated on
for kokkos-execution by
1.18.0