16#ifndef TRUSTArr_kokkos_TPP_included
17#define TRUSTArr_kokkos_TPP_included
19#include <TRUSTArray.h>
25template<
typename _TYPE_,
typename _SIZE_>
30 bool flattened = check_flattened<_SHAPE_>();
34 _SIZE_ dimension_tot_0 = flattened ? this->size_array() : this->dimension_tot(0);
37 return { dimension_tot_0,
38 nb_dim_ > 1 ? this->dimension_tot(1) : 0,
39 nb_dim_ > 2 ? this->dimension_tot(2) : 0,
40 nb_dim_ > 3 ? this->dimension_tot(3) : 0
46template<
typename _TYPE_,
typename _SIZE_>
51 const auto& device_view = get_device_view<_SHAPE_>();
53 auto dims = this->getDims<_SHAPE_>();
56 if(device_view.data() == addrOnDevice(*
this) &&
57 (
long) device_view.extent(0) == dims[0] &&
58 (_SHAPE_ >= 2 && (
long) device_view.extent(1) == dims[1]) &&
59 (_SHAPE_ >= 3 && (
long) device_view.extent(2) == dims[2]) &&
60 (_SHAPE_ >= 4 && (
long) device_view.extent(3) == dims[3]) )
64 auto& mutable_device_view =
const_cast<DeviceView<_TYPE_, _SHAPE_>&
>(device_view);
65 mutable_device_view = createView<DeviceView<_TYPE_, _SHAPE_>, _TYPE_, _SHAPE_, _SIZE_>(
const_cast<_TYPE_ *
>(addrOnDevice(*
this)), dims);
70template<
typename _TYPE_,
typename _SIZE_>
76 bool is_array = std::string(
typeid(*this).name()).find(
"TRUSTArray") != std::string::npos;;
77 assert(not(is_array && _SHAPE_>1));
81 assert((not(this->nb_dim_>1 && _SHAPE_>1 && _SHAPE_ != this->nb_dim_)));
93template<
typename _TYPE_,
typename _SIZE_>
94template<
int _SHAPE_,
typename EXEC_SPACE>
95inline std::enable_if_t<is_default_exec_space<EXEC_SPACE>, ConstView<_TYPE_,_SHAPE_> >
98 this->
template init_device_view<_SHAPE_>();
100 return get_device_view<_SHAPE_>();
104template<
typename _TYPE_,
typename _SIZE_>
105template<
int _SHAPE_,
typename EXEC_SPACE>
106inline std::enable_if_t<gpu_enabled_is_host_exec_space<EXEC_SPACE>, ConstHostView<_TYPE_,_SHAPE_> >
109 auto dims = this->getDims<_SHAPE_>();
110 return createView<ConstHostView<_TYPE_, _SHAPE_>, _TYPE_, _SHAPE_, _SIZE_>(this->addr(), dims);
116template<
typename _TYPE_,
typename _SIZE_>
117template<
int _SHAPE_,
typename EXEC_SPACE>
118inline std::enable_if_t<is_default_exec_space<EXEC_SPACE>, View<_TYPE_,_SHAPE_> >
121 this->
template init_device_view<_SHAPE_>();
122 computeOnTheDevice(*
this);
123 return get_device_view<_SHAPE_>();
127template<
typename _TYPE_,
typename _SIZE_>
128template<
int _SHAPE_,
typename EXEC_SPACE>
129inline std::enable_if_t<gpu_enabled_is_host_exec_space<EXEC_SPACE>, HostView<_TYPE_,_SHAPE_> >
132 auto dims = this->getDims<_SHAPE_>();
133 return createView<HostView<_TYPE_, _SHAPE_>, _TYPE_, _SHAPE_, _SIZE_>(this->addr(), dims);
138template<
typename _TYPE_,
typename _SIZE_>
139template<
int _SHAPE_,
typename EXEC_SPACE>
140inline std::enable_if_t<is_default_exec_space<EXEC_SPACE>, View<_TYPE_,_SHAPE_> >
143 this->
template init_device_view<_SHAPE_>();
144 computeOnTheDevice(*
this);
145 return get_device_view<_SHAPE_>();
148template<
typename _TYPE_,
typename _SIZE_>
149template<
int _SHAPE_,
typename EXEC_SPACE>
150inline std::enable_if_t<gpu_enabled_is_host_exec_space<EXEC_SPACE>, HostView<_TYPE_,_SHAPE_> >
153 auto dims = this->getDims<_SHAPE_>();
154 return createView<HostView<_TYPE_, _SHAPE_>, _TYPE_, _SHAPE_, _SIZE_>(this->addr(), dims);
Represents a an array of int/int64/double/... values.