kokkos-utils 0.0.7
Loading...
Searching...
No Matches
test_View.cpp
Go to the documentation of this file.
1#include <tuple>
2
3#include "gtest/gtest.h"
4
5#include "Kokkos_Macros.hpp"
6#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
7import kokkos.core;
8#else
9#include "Kokkos_Core.hpp"
10#endif
11
13
14using execution_space = Kokkos::DefaultExecutionSpace;
15
26
28{
29
32{
33 using view_1d_t = Kokkos::View<int[5] , execution_space>;
34 using view_2d_t = Kokkos::View<int[5][5], execution_space>;
35
38}
39
41TEST(concepts, ViewOfInstanceOf)
42{
44
45 static_assert( ViewOfInstanceOf<Kokkos::View<std::tuple<int> , execution_space>, std::tuple>);
46 static_assert( ViewOfInstanceOf<Kokkos::View<std::tuple<int>*, execution_space>, std::tuple>);
47 static_assert(! ViewOfInstanceOf<Kokkos::View<std::tuple<int>*, execution_space>, Kokkos::IndexType>);
48}
49
51TEST(concepts, ViewOf)
52{
54
55 static_assert( ViewOf<Kokkos::View<double , execution_space>, double>);
56 static_assert( ViewOf<Kokkos::View<double[5] , execution_space>, double>);
57 static_assert( ViewOf<Kokkos::View<double* , execution_space>, double>);
58 static_assert( ViewOf<Kokkos::View<double** , execution_space>, double>);
59 static_assert( ViewOf<Kokkos::View<const double*, execution_space>, const double>);
60 static_assert(! ViewOf<Kokkos::View<const double*, execution_space>, double>);
61 static_assert(! ViewOf<Kokkos::View<int , execution_space>, double>);
62 static_assert(! ViewOf< double , double>);
63}
64
66TEST(concepts, ViewOfRank)
67{
69
70 using int_0d_view_t = Kokkos::View<int , execution_space>;
71 using int_1d_view_t = Kokkos::View<int* , execution_space>;
72 using int_2d_view_t = Kokkos::View<int**, execution_space>;
73
74 static_assert( ViewOfRank<int_0d_view_t, 0>);
75 static_assert(! ViewOfRank<int_0d_view_t, 1>);
76
77 static_assert( ViewOfRank<int_1d_view_t, 1>);
78 static_assert(! ViewOfRank<int_1d_view_t, 2>);
79
80 static_assert(! ViewOfRank<int_2d_view_t, 1>);
81 static_assert( ViewOfRank<int_2d_view_t, 2>);
82}
83
85TEST(concepts, ModifiableView)
86{
88
89 using double_view_t = Kokkos::View< double*, execution_space>;
90 using const_double_view_t = Kokkos::View<const double*, execution_space>;
91
92 static_assert( ModifiableView< double_view_t>);
93 static_assert(! ModifiableView<const_double_view_t>);
94}
95
96} // namespace Kokkos::utils::tests::concepts
Specify that a type is a modifiable Kokkos::View.
Definition View.hpp:23
Specify that a type is a Kokkos::View, whose value type is an instance of a given class template U.
Definition View.hpp:31
Specify that a type is a Kokkos::View of given rank Rank.
Definition View.hpp:19
Specify that a type is a Kokkos::View with value type ValueType.
Definition View.hpp:27
Specify that a type is a Kokkos::View.
Definition View.hpp:15
Kokkos::DefaultExecutionSpace execution_space