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_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
18template <typename ViewType>
19struct SumIndices {
20 ViewType data;
21
22 template <std::integral T>
23 KOKKOS_FUNCTION void operator()(const T index) const {
24 Kokkos::atomic_add(data.data(), index);
25 }
26
27 template <Kokkos::TeamHandle TeamHandleType>
28 KOKKOS_FUNCTION void operator()(const TeamHandleType& team_handle) const {
29 const auto start_index = team_handle.league_rank() * team_handle.team_size();
30 Kokkos::parallel_for(
31 Kokkos::TeamThreadRange(team_handle, team_handle.team_size()),
32 [&]<std::integral T>(const T index) { Kokkos::atomic_add(data.data(), start_index + index); });
33 }
34};
35
37#define BULK_SUM_INDICES(_size_, _data_) \
38 stdexec::bulk( \
39 stdexec::par, \
40 _size_, \
41 Tests::Utils::Functors::SumIndices<std::remove_cvref_t<decltype(_data_)>>{.data = _data_})
42
43} // namespace Tests::Utils::Functors
44
45#endif // KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_SUM_INDICES_HPP
void operator()(const TeamHandleType &team_handle) const
void operator()(const T index) const