kokkos-utils
0.0.5
Toggle main menu visibility
Loading...
Searching...
No Matches
test_InsertOp.cpp
Go to the documentation of this file.
1
#include "gtest/gtest.h"
2
3
#include "Kokkos_Core.hpp"
4
5
#include "
kokkos-utils/atomics/InsertOp.hpp
"
6
#include "
kokkos-utils/concepts/View.hpp
"
7
8
using
execution_space
= Kokkos::DefaultExecutionSpace;
9
20
21
namespace
Kokkos::utils::tests::atomics
22
{
23
24
template
<concepts::View view_t>
25
struct
InsertMinTest
26
{
27
view_t
data
;
28
int
trials
= 0;
29
utils::atomics::InsertMin
inserter
{};
30
31
template
<
typename
Exec>
32
void
apply
(
const
Exec& exec)
const
33
{
34
Kokkos::parallel_for(
35
"atomics::InsertMin"
,
36
Kokkos::RangePolicy<execution_space>(exec, 0,
trials
),
37
*
this
38
);
39
}
40
41
template
<std::
int
egral T>
42
KOKKOS_FUNCTION
43
void
operator()
(
const
T trial)
const
44
{
45
inserter
.
op
(
data
, 0,
trials
- trial - 2);
46
inserter
.
op
(
data
, 1, 2);
47
}
48
};
49
51
TEST
(
atomics
, InsertMin)
52
{
53
using
view_t = Kokkos::View<int*, execution_space>;
54
55
constexpr
int
trials = 150;
56
57
const
execution_space
exec {};
58
59
const
view_t data(Kokkos::view_alloc(exec,
"data"
), 2);
60
61
InsertMinTest
{.data = data, .trials = trials}.
apply
(exec);
62
exec.fence();
63
64
const
auto
mirror = Kokkos::create_mirror_view_and_copy(Kokkos::DefaultHostExecutionSpace{}, data);
65
66
ASSERT_EQ(mirror(0), -1);
67
ASSERT_EQ(mirror(1), 0);
68
}
69
70
}
// namespace Kokkos::utils::tests::atomics
InsertOp.hpp
View.hpp
Kokkos::utils::tests::atomics
Definition
test_InsertOp.cpp:22
Kokkos::utils::tests::atomics::TEST
TEST(atomics, InsertMin)
Definition
test_InsertOp.cpp:51
Kokkos::utils::atomics::InsertMin
Insert an element in a view at a specific index using Kokkos::atomic_min.
Definition
InsertOp.hpp:17
Kokkos::utils::atomics::InsertMin::op
KOKKOS_FUNCTION void op(const ViewType &values, const IndexType index, ValueType &&value) const
Definition
InsertOp.hpp:20
Kokkos::utils::tests::atomics::InsertMinTest
Definition
test_InsertOp.cpp:26
Kokkos::utils::tests::atomics::InsertMinTest::data
view_t data
Definition
test_InsertOp.cpp:27
Kokkos::utils::tests::atomics::InsertMinTest::apply
void apply(const Exec &exec) const
Definition
test_InsertOp.cpp:32
Kokkos::utils::tests::atomics::InsertMinTest::trials
int trials
Definition
test_InsertOp.cpp:28
Kokkos::utils::tests::atomics::InsertMinTest::inserter
utils::atomics::InsertMin inserter
Definition
test_InsertOp.cpp:29
Kokkos::utils::tests::atomics::InsertMinTest::operator()
KOKKOS_FUNCTION void operator()(const T trial) const
Definition
test_InsertOp.cpp:43
execution_space
Kokkos::DefaultExecutionSpace execution_space
Definition
test_InsertOp.cpp:8
tests
atomics
test_InsertOp.cpp
Generated on
for kokkos-utils by
1.18.0