kokkos-utils
0.0.7
Toggle main menu visibility
Loading...
Searching...
No Matches
test_extents.cpp
Go to the documentation of this file.
1
#include "gmock/gmock.h"
2
#include "gtest/gtest.h"
3
4
#include "Kokkos_Macros.hpp"
5
#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
6
import
kokkos.core;
7
#else
8
#include "Kokkos_Core.hpp"
9
#endif
10
11
#include "
kokkos-utils/view/extents.hpp
"
12
13
using
execution_space
= Kokkos::DefaultExecutionSpace;
14
26
27
namespace
Kokkos::utils::tests::view
28
{
29
30
constexpr
size_t
dim_1
= 5,
dim_2
= 3,
dim_3
= 6,
dim_4
= 9;
31
33
TEST
(
view
, extents_rank_0)
34
{
35
const
Kokkos::View<double, execution_space> view_0(
"rank-0 view"
);
36
37
static_assert
(
utils::view::extents
(view_0) == Kokkos::Array<size_t, 0>{});
38
}
39
41
TEST
(
view
, extents_rank_1)
42
{
43
const
Kokkos::View<double[dim_1], execution_space> view_1_static(
"rank-1 view with static extent"
);
44
const
Kokkos::View<double* , execution_space> view_1_dynami(
"rank-1 view with dynamic extent"
,
dim_1
);
45
46
ASSERT_EQ(
utils::view::extents
(view_1_static), Kokkos::Array{
dim_1
});
47
ASSERT_EQ(
utils::view::extents
(view_1_dynami), Kokkos::Array{
dim_1
});
48
}
49
51
TEST
(
view
, extents_rank_2)
52
{
53
const
Kokkos::View<double[dim_1][dim_2], execution_space> view_2_static(
"rank-2 view with static extents"
);
54
const
Kokkos::View<double** , execution_space> view_2_dynami(
"rank-2 view with dynamic extents"
,
dim_1
,
dim_2
);
55
const
Kokkos::View<double*[dim_2] , execution_space> view_2_mixed (
"rank-2 view with mixed extents"
,
dim_1
);
56
57
ASSERT_EQ(
utils::view::extents
(view_2_static), (Kokkos::Array{
dim_1
,
dim_2
}));
58
ASSERT_EQ(
utils::view::extents
(view_2_dynami), (Kokkos::Array{
dim_1
,
dim_2
}));
59
ASSERT_EQ(
utils::view::extents
(view_2_mixed ), (Kokkos::Array{
dim_1
,
dim_2
}));
60
}
61
63
TEST
(
view
, extents_rank_3)
64
{
65
const
Kokkos::View<double[dim_1][dim_2][dim_3], execution_space> view_3_static(
"rank-3 view of static extents"
);
66
const
Kokkos::View<double*** , execution_space> view_3_dynami(
"rank-3 view of dynamic extents"
,
dim_1
,
dim_2
,
dim_3
);
67
const
Kokkos::View<double*[dim_2][dim_3] , execution_space> view_3_mixed (
"rank-3 view of mixed extents"
,
dim_1
);
68
69
ASSERT_EQ(
utils::view::extents
(view_3_static), (Kokkos::Array{
dim_1
,
dim_2
,
dim_3
}));
70
ASSERT_EQ(
utils::view::extents
(view_3_dynami), (Kokkos::Array{
dim_1
,
dim_2
,
dim_3
}));
71
ASSERT_EQ(
utils::view::extents
(view_3_mixed ), (Kokkos::Array{
dim_1
,
dim_2
,
dim_3
}));
72
}
73
75
TEST
(
view
, extents_rank_4)
76
{
77
const
Kokkos::View<double[dim_1][dim_2][dim_3][dim_4], execution_space> view_4_static(
"rank-4 view of static extents"
);
78
79
ASSERT_EQ(
utils::view::extents
(view_4_static), (Kokkos::Array{
dim_1
,
dim_2
,
dim_3
,
dim_4
}));
80
}
81
82
}
// namespace Kokkos::utils::tests::view
extents.hpp
Kokkos::utils::tests::view
Definition
test_extents.cpp:28
Kokkos::utils::tests::view::dim_3
constexpr size_t dim_3
Definition
test_extents.cpp:30
Kokkos::utils::tests::view::dim_2
constexpr size_t dim_2
Definition
test_extents.cpp:30
Kokkos::utils::tests::view::dim_4
constexpr size_t dim_4
Definition
test_extents.cpp:30
Kokkos::utils::tests::view::TEST
TEST(view, extents_rank_0)
Definition
test_extents.cpp:33
Kokkos::utils::tests::view::dim_1
constexpr size_t dim_1
Definition
test_extents.cpp:30
Kokkos::utils::view::extents
KOKKOS_FUNCTION constexpr auto extents(const ViewType &view)
Get all extents of view.
Definition
extents.hpp:34
execution_space
Kokkos::DefaultExecutionSpace execution_space
Definition
test_InsertOp.cpp:13
tests
view
test_extents.cpp
Generated on
for kokkos-utils by
1.18.0