kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
reduce_indices.hpp
Go to the documentation of this file.
1
#ifndef KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_REDUCE_INDICES_HPP
2
#define KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_REDUCE_INDICES_HPP
3
4
#include <concepts>
5
#include <type_traits>
6
7
#include "
kokkos-execution/stdexec.hpp
"
8
9
#include "Kokkos_Macros.hpp"
10
#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
11
import
kokkos.core;
12
#else
13
# include "Kokkos_Core.hpp"
14
#endif
15
16
namespace
Tests::Utils::Functors
{
17
19
struct
ReduceIndices
{
20
template
<std::
int
egral T,
typename
U>
21
KOKKOS_FUNCTION
void
operator()
(
const
T index, U& value)
const
noexcept
{
22
value += index;
23
}
24
};
25
35
template
<Kokkos::ExecutionSpace Exec,
typename
ValueType>
36
struct
ReduceIndicesWithTeam
{
37
using
team_handle_t
=
typename
Kokkos::TeamPolicy<Exec>::member_type;
38
39
KOKKOS_FUNCTION
void
operator()
(
const
team_handle_t
& team_handle, ValueType& value)
const
{
40
const
auto
start_index = team_handle.league_rank() * team_handle.team_size();
41
Kokkos::parallel_for(
42
Kokkos::TeamThreadRange(team_handle, team_handle.team_size()),
43
[&]<std::integral T>(
const
T index) { value += start_index + index; });
44
}
45
};
46
47
}
// namespace Tests::Utils::Functors
48
49
#endif
// KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_REDUCE_INDICES_HPP
stdexec.hpp
Tests::Utils::Functors
Definition
counter.hpp:11
Tests::Utils::Functors::ReduceIndicesWithTeam
Similar to ReduceIndices, with a team policy.
Definition
reduce_indices.hpp:36
Tests::Utils::Functors::ReduceIndicesWithTeam::team_handle_t
typename Kokkos::TeamPolicy< Exec >::member_type team_handle_t
Definition
reduce_indices.hpp:37
Tests::Utils::Functors::ReduceIndicesWithTeam::operator()
void operator()(const team_handle_t &team_handle, ValueType &value) const
Definition
reduce_indices.hpp:39
Tests::Utils::Functors::ReduceIndices
Reduce indices.
Definition
reduce_indices.hpp:19
Tests::Utils::Functors::ReduceIndices::operator()
void operator()(const T index, U &value) const noexcept
Definition
reduce_indices.hpp:21
tests
utils
functors
reduce_indices.hpp
Generated on
for kokkos-execution by
1.18.0