kokkos-execution 0.0.1
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
8
9#include "Kokkos_Macros.hpp"
10#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
11import kokkos.core;
12#else
13# include "Kokkos_Core.hpp"
14#endif
15
16namespace Tests::Utils::Functors {
17
20 template <std::integral T, typename U>
21 KOKKOS_FUNCTION void operator()(const T index, U& value) const noexcept {
22 value += index;
23 }
24};
25
35template <Kokkos::ExecutionSpace Exec, typename ValueType>
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
Similar to ReduceIndices, with a team policy.
typename Kokkos::TeamPolicy< Exec >::member_type team_handle_t
void operator()(const team_handle_t &team_handle, ValueType &value) const
void operator()(const T index, U &value) const noexcept