kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
counter.hpp
Go to the documentation of this file.
1
#ifndef KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_COUNTER_HPP
2
#define KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_COUNTER_HPP
3
4
#include "Kokkos_Core.hpp"
5
6
namespace
Tests::Utils::Functors
{
7
9
struct
Counter
{
10
static
inline
std::atomic<unsigned int>
default_constructions
{0};
11
static
inline
std::atomic<unsigned int>
destructions
{0};
12
static
inline
std::atomic<unsigned int>
copy_constructions
{0};
13
static
inline
std::atomic<unsigned int>
copy_assignments
{0};
14
static
inline
std::atomic<unsigned int>
move_constructions
{0};
15
static
inline
std::atomic<unsigned int>
move_assignments
{0};
16
17
static
inline
std::atomic<unsigned int>
next_id
{0};
18
19
unsigned
int
id
{0};
20
21
Counter
() noexcept
22
:
id
(
next_id
.fetch_add(1, std::memory_order_relaxed)) {
23
default_constructions
.fetch_add(1, std::memory_order_relaxed);
24
}
25
26
~Counter
() noexcept {
27
destructions
.fetch_add(1, std::memory_order_relaxed);
28
}
29
30
Counter
(
const
Counter
&) noexcept
31
:
id
(
next_id
.fetch_add(1, std::memory_order_relaxed)) {
32
copy_constructions
.fetch_add(1, std::memory_order_relaxed);
33
}
34
35
Counter
&
operator=
(
const
Counter
&)
noexcept
{
36
copy_assignments
.fetch_add(1, std::memory_order_relaxed);
37
return
*
this
;
38
}
39
40
Counter
(
Counter
&&) noexcept
41
:
id
(
next_id
.fetch_add(1, std::memory_order_relaxed)) {
42
move_constructions
.fetch_add(1, std::memory_order_relaxed);
43
}
44
45
Counter
&
operator=
(
Counter
&&) noexcept {
46
move_assignments
.fetch_add(1, std::memory_order_relaxed);
47
return
*
this
;
48
}
49
50
template
<
typename
... Args>
51
KOKKOS_FUNCTION
void
operator()
(Args&&...) const noexcept {
52
}
53
54
static
void
reset
() {
55
default_constructions
= 0;
56
destructions
= 0;
57
copy_constructions
= 0;
58
copy_assignments
= 0;
59
move_constructions
= 0;
60
move_assignments
= 0;
61
}
62
};
63
64
}
// namespace Tests::Utils::Functors
65
66
#endif
// KOKKOS_EXECUTION_TESTS_UTILS_FUNCTORS_COUNTER_HPP
Tests::Utils::Functors
Definition
counter.hpp:6
Tests::Utils::Functors::Counter::move_assignments
static std::atomic< unsigned int > move_assignments
Definition
counter.hpp:15
Tests::Utils::Functors::Counter::copy_constructions
static std::atomic< unsigned int > copy_constructions
Definition
counter.hpp:12
Tests::Utils::Functors::Counter::Counter
Counter() noexcept
Definition
counter.hpp:21
Tests::Utils::Functors::Counter::~Counter
~Counter() noexcept
Definition
counter.hpp:26
Tests::Utils::Functors::Counter::operator=
Counter & operator=(Counter &&) noexcept
Definition
counter.hpp:45
Tests::Utils::Functors::Counter::destructions
static std::atomic< unsigned int > destructions
Definition
counter.hpp:11
Tests::Utils::Functors::Counter::reset
static void reset()
Definition
counter.hpp:54
Tests::Utils::Functors::Counter::operator()
void operator()(Args &&...) const noexcept
Definition
counter.hpp:51
Tests::Utils::Functors::Counter::Counter
Counter(Counter &&) noexcept
Definition
counter.hpp:40
Tests::Utils::Functors::Counter::next_id
static std::atomic< unsigned int > next_id
Definition
counter.hpp:17
Tests::Utils::Functors::Counter::default_constructions
static std::atomic< unsigned int > default_constructions
Definition
counter.hpp:10
Tests::Utils::Functors::Counter::id
unsigned int id
Definition
counter.hpp:19
Tests::Utils::Functors::Counter::move_constructions
static std::atomic< unsigned int > move_constructions
Definition
counter.hpp:14
Tests::Utils::Functors::Counter::copy_assignments
static std::atomic< unsigned int > copy_assignments
Definition
counter.hpp:13
Tests::Utils::Functors::Counter::operator=
Counter & operator=(const Counter &) noexcept
Definition
counter.hpp:35
Tests::Utils::Functors::Counter::Counter
Counter(const Counter &) noexcept
Definition
counter.hpp:30
tests
utils
functors
counter.hpp
Generated on
for kokkos-execution by
1.18.0