kokkos-utils
0.0.1
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_Core.hpp"
5
6
#include "
kokkos-utils/view/extents.hpp
"
7
8
using
execution_space
= Kokkos::DefaultExecutionSpace;
9
21
22
namespace
Kokkos::utils::tests::view
23
{
24
25
constexpr
size_t
dim_1
= 5,
dim_2
= 3,
dim_3
= 6,
dim_4
= 9;
26
28
TEST
(
view
, extents_rank_0)
29
{
30
const
Kokkos::View<double, execution_space> view_0(
"rank-0 view"
);
31
32
static_assert
(
utils::view::extents
(view_0) ==
Kokkos::Array<size_t, 0>
{});
33
}
34
36
TEST
(
view
, extents_rank_1)
37
{
38
const
Kokkos::View<double[dim_1], execution_space> view_1_static(
"rank-1 view with static extent"
);
39
const
Kokkos::View<double* , execution_space> view_1_dynami(
"rank-1 view with dynamic extent"
,
dim_1
);
40
41
ASSERT_EQ(
utils::view::extents
(view_1_static),
Kokkos::Array
{
dim_1
});
42
ASSERT_EQ(
utils::view::extents
(view_1_dynami),
Kokkos::Array
{
dim_1
});
43
}
44
46
TEST
(
view
, extents_rank_2)
47
{
48
const
Kokkos::View<double[dim_1][dim_2], execution_space> view_2_static(
"rank-2 view with static extents"
);
49
const
Kokkos::View<double** , execution_space> view_2_dynami(
"rank-2 view with dynamic extents"
,
dim_1
,
dim_2
);
50
const
Kokkos::View<double*[dim_2] , execution_space> view_2_mixed (
"rank-2 view with mixed extents"
,
dim_1
);
51
52
ASSERT_EQ(
utils::view::extents
(view_2_static), (
Kokkos::Array
{
dim_1
,
dim_2
}));
53
ASSERT_EQ(
utils::view::extents
(view_2_dynami), (
Kokkos::Array
{
dim_1
,
dim_2
}));
54
ASSERT_EQ(
utils::view::extents
(view_2_mixed ), (
Kokkos::Array
{
dim_1
,
dim_2
}));
55
}
56
58
TEST
(
view
, extents_rank_3)
59
{
60
const
Kokkos::View<double[dim_1][dim_2][dim_3], execution_space> view_3_static(
"rank-3 view of static extents"
);
61
const
Kokkos::View<double*** , execution_space> view_3_dynami(
"rank-3 view of dynamic extents"
,
dim_1
,
dim_2
,
dim_3
);
62
const
Kokkos::View<double*[dim_2][dim_3] , execution_space> view_3_mixed (
"rank-3 view of mixed extents"
,
dim_1
);
63
64
ASSERT_EQ(
utils::view::extents
(view_3_static), (
Kokkos::Array
{
dim_1
,
dim_2
,
dim_3
}));
65
ASSERT_EQ(
utils::view::extents
(view_3_dynami), (
Kokkos::Array
{
dim_1
,
dim_2
,
dim_3
}));
66
ASSERT_EQ(
utils::view::extents
(view_3_mixed ), (
Kokkos::Array
{
dim_1
,
dim_2
,
dim_3
}));
67
}
68
70
TEST
(
view
, extents_rank_4)
71
{
72
const
Kokkos::View<double[dim_1][dim_2][dim_3][dim_4], execution_space> view_4_static(
"rank-4 view of static extents"
);
73
74
ASSERT_EQ(
utils::view::extents
(view_4_static), (
Kokkos::Array
{
dim_1
,
dim_2
,
dim_3
,
dim_4
}));
75
}
76
77
}
// namespace Kokkos::utils::tests::view
extents.hpp
Kokkos::utils::tests::view
Definition
test_extents.cpp:23
Kokkos::utils::tests::view::dim_3
constexpr size_t dim_3
Definition
test_extents.cpp:25
Kokkos::utils::tests::view::dim_2
constexpr size_t dim_2
Definition
test_extents.cpp:25
Kokkos::utils::tests::view::dim_4
constexpr size_t dim_4
Definition
test_extents.cpp:25
Kokkos::utils::tests::view::TEST
TEST(view, extents_rank_0)
Definition
test_extents.cpp:28
Kokkos::utils::tests::view::dim_1
constexpr size_t dim_1
Definition
test_extents.cpp:25
Kokkos::utils::view::extents
KOKKOS_FUNCTION constexpr auto extents(const ViewType &view)
Get all extents of view.
Definition
extents.hpp:34
Kokkos::Array
execution_space
Kokkos::DefaultExecutionSpace execution_space
Definition
test_InsertOp.cpp:8
tests
view
test_extents.cpp
Generated on Wed Jun 25 2025 05:46:48 for kokkos-utils by
1.13.2