kokkos-execution
0.0.1
Toggle main menu visibility
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
6
#include "
kokkos-execution/stdexec.hpp
"
7
8
#include "Kokkos_Core.hpp"
9
10
#include "
kokkos-utils/concepts/View.hpp
"
11
12
#include "
tests/utils/atomic.hpp
"
13
14
namespace
Tests::Utils::Functors
{
15
17
template
<
18
Kokkos::utils::concepts::ViewOfRank<0> ViewType,
19
bool
MayThrow =
true
,
20
bool
Atomic =
false
,
21
typename
MemoryScope = desul::MemoryScopeDevice
22
>
23
struct
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
{
35
Tests::Utils::atomic_fetch_add<MemoryScope, desul::MemoryOrderRelaxed, typename ViewType::non_const_value_type>
(
36
data
.data(), 1);
37
}
38
};
39
40
template
<
41
Kokkos::utils::concepts::ViewOfRank<0>
ViewType,
42
bool
MayThrow =
true
,
43
typename
MemoryScope = desul::MemoryScopeDevice
44
>
45
struct
FetchIncrement
{
46
typename
ViewType::non_const_type
counter
,
value
;
47
48
KOKKOS_FUNCTION
49
void
operator()
() const noexcept(!MayThrow) {
50
value
() =
Tests::Utils::atomic_fetch_add
<
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
atomic.hpp
Kokkos::utils::concepts::ViewOfRank
View.hpp
stdexec.hpp
Tests::Utils::Functors
Definition
counter.hpp:6
Tests::Utils::atomic_fetch_add
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
Tests::Utils::Functors::FetchIncrement
Definition
increment.hpp:45
Tests::Utils::Functors::FetchIncrement::value
ViewType::non_const_type value
Definition
increment.hpp:46
Tests::Utils::Functors::FetchIncrement::counter
ViewType::non_const_type counter
Definition
increment.hpp:46
Tests::Utils::Functors::FetchIncrement::operator()
void operator()() const noexcept(!MayThrow)
Definition
increment.hpp:49
Tests::Utils::Functors::Increment
Increment data.
Definition
increment.hpp:23
Tests::Utils::Functors::Increment::operator()
void operator()() const noexcept(!MayThrow)
Definition
increment.hpp:27
Tests::Utils::Functors::Increment::data
ViewType::non_const_type data
Definition
increment.hpp:24
Tests::Utils::Functors::Increment::operator()
void operator()() const noexcept(!MayThrow)
Definition
increment.hpp:33
tests
utils
functors
increment.hpp
Generated on
for kokkos-execution by
1.18.0