kokkos-execution 0.0.1
Loading...
Searching...
No Matches
maxloc.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_MAXLOC_HPP
2#define KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_MAXLOC_HPP
3
4#include "Kokkos_Macros.hpp"
5#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
6import kokkos.core;
7#else
8# include "Kokkos_Core.hpp"
9#endif
10
11namespace Tests::Utils::Functors {
12
14template <typename DataType>
15struct MaxLoc {
16 typename DataType::const_type data;
17
18 template <std::integral IndexType, typename ValueType>
19 KOKKOS_FUNCTION void operator()(const IndexType index, ValueType& current) const noexcept {
20 if (data(index) > current.val) {
21 current.val = data(index);
22 current.loc = index;
23 }
24 }
25};
26
27} // namespace Tests::Utils::Functors
28
29#endif // KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_MAXLOC_HPP
Can be used in a parallel_reduce to find the greater of the values in data alongside its index.
Definition maxloc.hpp:15
DataType::const_type data
Definition maxloc.hpp:16
void operator()(const IndexType index, ValueType &current) const noexcept
Definition maxloc.hpp:19