kokkos-execution
0.0.1
Toggle main menu visibility
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
7
#include "
kokkos-execution/stdexec.hpp
"
8
9
#include "Kokkos_Core.hpp"
10
11
namespace
Tests::Utils::Functors
{
12
13
template
<
typename
ViewType>
14
struct
SumIndices
{
15
ViewType
data
;
16
17
template
<std::
int
egral 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
stdexec.hpp
Tests::Utils::Functors
Definition
counter.hpp:6
Tests::Utils::Functors::SumIndices
Definition
sum_indices.hpp:14
Tests::Utils::Functors::SumIndices::operator()
void operator()(const TeamHandleType &team_handle) const
Definition
sum_indices.hpp:23
Tests::Utils::Functors::SumIndices::operator()
void operator()(const T index) const
Definition
sum_indices.hpp:18
Tests::Utils::Functors::SumIndices::data
ViewType data
Definition
sum_indices.hpp:15
tests
utils
functors
sum_indices.hpp
Generated on
for kokkos-execution by
1.18.0