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_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
18
template
<
typename
ViewType>
19
struct
SumIndices
{
20
ViewType
data
;
21
22
template
<std::
int
egral 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
stdexec.hpp
Tests::Utils::Functors
Definition
counter.hpp:11
Tests::Utils::Functors::SumIndices
Definition
sum_indices.hpp:19
Tests::Utils::Functors::SumIndices::operator()
void operator()(const TeamHandleType &team_handle) const
Definition
sum_indices.hpp:28
Tests::Utils::Functors::SumIndices::operator()
void operator()(const T index) const
Definition
sum_indices.hpp:23
Tests::Utils::Functors::SumIndices::data
ViewType data
Definition
sum_indices.hpp:20
tests
utils
functors
sum_indices.hpp
Generated on
for kokkos-execution by
1.18.0