kokkos-execution 0.0.1
Loading...
Searching...
No Matches
increment.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_INCREMENT_HPP
2#define KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_INCREMENT_HPP
3
4#include <type_traits>
5
7
8#include "Kokkos_Core.hpp"
9
11
13
14namespace Tests::Utils::Functors {
15
17template <Kokkos::utils::concepts::ViewOfRank<0> ViewType, bool MayThrow = true, bool Atomic = false>
18struct Increment {
19 typename ViewType::non_const_type data;
20
21 KOKKOS_FUNCTION
22 void operator()() const noexcept(!MayThrow) requires(Atomic == false)
23 {
24 ++data();
25 }
26
27 KOKKOS_FUNCTION
28 void operator()() const noexcept(!MayThrow) requires(Atomic == true)
29 {
31 }
32};
33
35#define THEN_INCREMENT(_data_) \
36 stdexec::then(Tests::Utils::Functors::Increment<std::remove_cvref_t<decltype(_data_)>, true, false>{.data = _data_})
37
39#define THEN_INCREMENT_ATOMIC(_data_) \
40 stdexec::then(Tests::Utils::Functors::Increment<std::remove_cvref_t<decltype(_data_)>, true, true>{.data = _data_})
41
42} // namespace Tests::Utils::Functors
43
44#endif // KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_INCREMENT_HPP
void atomic_add(T *ptr, const T val)
Atomically add val to *ptr using system scope and relaxed memory order.
Definition atomic.hpp:34
void operator()() const noexcept(!MayThrow)
Definition increment.hpp:22
ViewType::non_const_type data
Definition increment.hpp:19
void operator()() const noexcept(!MayThrow)
Definition increment.hpp:28