16#ifndef View_Types_included
17#define View_Types_included
23template<
typename T,
int _SHAPE_>
struct InnerType {
using TYPE = void; };
36using unmanaged_memory = Kokkos::MemoryTraits<Kokkos::Unmanaged>;
38template<
typename T,
int _SHAPE_>
39using DeviceView = Kokkos::View<typename InnerType<T, _SHAPE_>::TYPE, Kokkos::LayoutRight, unmanaged_memory>;
42using host_mirror_space = Kokkos::HostSpace;
45using execution_space = DeviceView<double, 1>::execution_space;
48using range_1D = Kokkos::RangePolicy<execution_space>;
49using range_2D = Kokkos::MDRangePolicy<execution_space, Kokkos::Rank<2>>;
50using range_3D = Kokkos::MDRangePolicy<execution_space, Kokkos::Rank<3>>;
53typedef std::conditional< \
54std::is_same<execution_space, Kokkos::DefaultExecutionSpace>::value , \
55DeviceView<double,1>::memory_space, host_mirror_space>::type \
63template<
typename T,
int _SHAPE_>
64using View = Kokkos::View<typename InnerType<T, _SHAPE_>::TYPE,
typename DeviceView<T,_SHAPE_>::array_layout, memory_space, unmanaged_memory>;
67template<
typename T,
int _SHAPE_>
68using HostView = Kokkos::View<typename InnerType<T, _SHAPE_>::TYPE,
typename DeviceView<T,_SHAPE_>::array_layout, host_mirror_space, unmanaged_memory>;
69template<
typename T,
int _SHAPE_>
70using ConstView = Kokkos::View<typename ConstInnerType<T, _SHAPE_>::TYPE,
typename DeviceView<T,_SHAPE_>::array_layout, memory_space, unmanaged_memory>;
71template<
typename T,
int _SHAPE_>
72using ConstHostView = Kokkos::View<typename ConstInnerType<T, _SHAPE_>::TYPE,
typename DeviceView<T,_SHAPE_>::array_layout, host_mirror_space, unmanaged_memory>;
75template<
typename T,
int _SHAPE_>
76using RandomAccessView = Kokkos::View<typename ConstInnerType<T, _SHAPE_>::TYPE,
typename DeviceView<T,_SHAPE_>::array_layout, memory_space, Kokkos::MemoryRandomAccess>;
79using IntArrView = View<int, 1>;
80using DoubleArrView = View<double, 1>;
81using TIDArrView = View<trustIdType, 1>;
83using CIntArrView = ConstView<int, 1>;
84using CDoubleArrView = ConstView<double, 1>;
85using CTIDArrView = ConstView<trustIdType, 1>;
87using IntTabView = View<int, 2>;
88using IntTabView3 = View<int, 3>;
89using IntTabView4 = View<int, 4>;
90using CTIDTabView = ConstView<trustIdType, 2>;
91using DoubleTabView = View<double, 2>;
92using DoubleTabView3 = View<double, 3>;
93using DoubleTabView4 = View<double, 4>;
95using CIntTabView = ConstView<int, 2>;
96using CIntTabView3 = ConstView<int, 3>;
97using CIntTabView4 = ConstView<int, 4>;
98using CDoubleTabView = ConstView<double, 2>;
99using CDoubleTabView3 = ConstView<double, 3>;
100using CDoubleTabView4 = ConstView<double, 4>;
103using IntArrHostView = HostView<int, 1>;
104using DoubleArrHostView = HostView<double, 1>;
106using CIntArrHostView = ConstHostView<int, 1>;
107using CDoubleArrHostView = ConstHostView<double, 1>;
109using IntTabHostView = HostView<int, 2>;
110using IntTabHostView3 = HostView<int, 3>;
111using IntTabHostView4 = HostView<int, 4>;
112using DoubleTabHostView = HostView<double, 2>;
113using DoubleTabHostView3 = HostView<double, 3>;
114using DoubleTabHostView4 = HostView<double, 4>;
116using CIntTabHostView = ConstHostView<int, 2>;
117using CIntTabHostView3 = ConstHostView<int, 3>;
118using CIntTabHostView4 = ConstHostView<int, 4>;
119using CDoubleTabHostView = ConstHostView<double, 2>;
120using CDoubleTabHostView3 = ConstHostView<double, 3>;
121using CDoubleTabHostView4 = ConstHostView<double, 4>;
125template <
typename ViewType,
typename _TYPE_,
int _SHAPE_,
typename _SIZE_>
128template <
typename ViewType,
typename _TYPE_,
typename _SIZE_>
131 static ViewType
create(_TYPE_* ptr,
const std::array<_SIZE_, 4>& dims)
133 return ViewType(ptr, dims[0]);
136template <
typename ViewType,
typename _TYPE_,
typename _SIZE_>
139 static ViewType
create(_TYPE_* ptr,
const std::array<_SIZE_, 4>& dims)
141 return ViewType(ptr, dims[0], dims[1]);
144template <
typename ViewType,
typename _TYPE_,
typename _SIZE_>
147 static ViewType
create(_TYPE_* ptr,
const std::array<_SIZE_, 4>& dims)
149 return ViewType(ptr, dims[0], dims[1], dims[2]);
152template <
typename ViewType,
typename _TYPE_,
typename _SIZE_>
155 static ViewType
create(_TYPE_* ptr,
const std::array<_SIZE_, 4>& dims)
157 return ViewType(ptr, dims[0], dims[1], dims[2], dims[3]);
160template <
typename ViewType,
typename _TYPE_,
int _SHAPE_,
typename _SIZE_>
161inline ViewType createView(_TYPE_* ptr,
const std::array<_SIZE_, 4>& dims)
163 static_assert(_SHAPE_ >= 1 && _SHAPE_ <= 4,
"Invalid _SHAPE_!");
166template <
typename ViewType,
typename _TYPE_,
int _SHAPE_,
typename _SIZE_>
167inline ViewType createView(
const _TYPE_* ptr,
const std::array<_SIZE_, 4>& dims)
169 static_assert(_SHAPE_ >= 1 && _SHAPE_ <= 4,
"Invalid _SHAPE_!");
172extern void kokkos_self_test();
176template<
int _SHAPE_>
using IntView = IntTab;
177template<
int _SHAPE_>
using DoubleView = DoubleTab;
179#define KOKKOS_INLINE_FUNCTION inline
static ViewType create(_TYPE_ *ptr, const std::array< _SIZE_, 4 > &dims)
static ViewType create(_TYPE_ *ptr, const std::array< _SIZE_, 4 > &dims)
static ViewType create(_TYPE_ *ptr, const std::array< _SIZE_, 4 > &dims)
static ViewType create(_TYPE_ *ptr, const std::array< _SIZE_, 4 > &dims)