kokkos-execution 0.0.1
Loading...
Searching...
No Matches
sum_indices.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_SUM_INDICES_HPP
2#define KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_SUM_INDICES_HPP
3
4#include <concepts>
5#include <type_traits>
6
8
9#include "Kokkos_Core.hpp"
10
11namespace Tests::Utils::Functors {
12
13template <typename ViewType>
14struct SumIndices {
15 ViewType data;
16
17 template <std::integral T>
18 KOKKOS_FUNCTION void operator()(const T index) const {
19 Kokkos::atomic_add(data.data(), index);
20 }
21
22 template <Kokkos::TeamHandle TeamHandleType>
23 KOKKOS_FUNCTION void operator()(const TeamHandleType& team_handle) const {
24 const auto start_index = team_handle.league_rank() * team_handle.team_size();
25 Kokkos::parallel_for(
26 Kokkos::TeamThreadRange(team_handle, team_handle.team_size()),
27 [&]<std::integral T>(const T index) { Kokkos::atomic_add(data.data(), start_index + index); });
28 }
29};
30
32#define BULK_SUM_INDICES(_size_, _data_) \
33 stdexec::bulk( \
34 stdexec::par, \
35 _size_, \
36 Tests::Utils::Functors::SumIndices<std::remove_cvref_t<decltype(_data_)>>{.data = _data_})
37
38} // namespace Tests::Utils::Functors
39
40#endif // KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_SUM_INDICES_HPP
void operator()(const TeamHandleType &team_handle) const
void operator()(const T index) const