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 <
18 Kokkos::utils::concepts::ViewOfRank<0> ViewType,
19 bool MayThrow = true,
20 bool Atomic = false,
21 typename MemoryScope = desul::MemoryScopeDevice
22>
23struct Increment {
24 typename ViewType::non_const_type data;
25
26 KOKKOS_FUNCTION
27 void operator()() const noexcept(!MayThrow) requires(Atomic == false)
28 {
29 ++data();
30 }
31
32 KOKKOS_FUNCTION
33 void operator()() const noexcept(!MayThrow) requires(Atomic == true)
34 {
36 data.data(), 1);
37 }
38};
39
40template <
42 bool MayThrow = true,
43 typename MemoryScope = desul::MemoryScopeDevice
44>
46 typename ViewType::non_const_type counter, value;
47
48 KOKKOS_FUNCTION
49 void operator()() const noexcept(!MayThrow) {
51 MemoryScope,
52 desul::MemoryOrderRelaxed,
53 typename ViewType::non_const_value_type
54 >(counter.data(), 1);
55 }
56};
57
59#define THEN_INCREMENT(_data_) \
60 stdexec::then(Tests::Utils::Functors::Increment<std::remove_cvref_t<decltype(_data_)>, true, false>{.data = _data_})
61
63#define THEN_INCREMENT_ATOMIC(_scope_, _data_) \
64 stdexec::then( \
65 Tests::Utils::Functors::Increment< \
66 std::remove_cvref_t<decltype(_data_)>, \
67 true, \
68 true, \
69 desul::MemoryScope##_scope_ \
70 >{.data = _data_})
71
72} // namespace Tests::Utils::Functors
73
74#endif // KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_INCREMENT_HPP
auto atomic_fetch_add(T *ptr, const T val)
Same effect as Kokkos::atomic_fetch_add, given memory scope and order.
Definition atomic.hpp:63
ViewType::non_const_type value
Definition increment.hpp:46
ViewType::non_const_type counter
Definition increment.hpp:46
void operator()() const noexcept(!MayThrow)
Definition increment.hpp:49
void operator()() const noexcept(!MayThrow)
Definition increment.hpp:27
ViewType::non_const_type data
Definition increment.hpp:24
void operator()() const noexcept(!MayThrow)
Definition increment.hpp:33