10 #ifndef KOKKOS_VIEW_FACTORY_HPP
11 #define KOKKOS_VIEW_FACTORY_HPP
13 #include <type_traits>
25 template <
class ... ViewPack>
30 typedef typename View::value_type
type;
33 template <
class View,
class ... ViewPack>
36 typename View::value_type,
51 template <
class ... ViewPack>
58 template<
class ... Args>
59 struct IsCtorProp<Kokkos::Impl::ViewCtorProp<Args...>> : std::true_type{};
61 template <
class ResultView,
class CtorProp,
class ... Dims>
65 const Dims ... dims) {
67 using nc_value_type =
typename ResultView::non_const_value_type;
72 constexpr
unsigned rank =
sizeof...(Dims);
75 static_assert( rank <= 7,
"Invalid rank...too many dimension arguments" );
78 typename ResultView::array_layout layout(dims...);
81 layout.dimension[rank] = dimension_scalar(views...);
86 if (!is_scalar && layout.dimension[rank] == 0)
87 layout.dimension[rank] = 1;
91 constexpr
unsigned r = is_scalar ? rank : rank + 1;
92 layout = Impl::reconstructLayout(layout, r);
95 #ifdef SACADO_HAS_NEW_KOKKOS_VIEW_IMPL
97 size_t fad_size = dimension_scalar(views...);
98 if (fad_size == 0) fad_size = 1;
99 if (!is_scalar) layout.dimension[rank] = is_dyn_rank ? KOKKOS_INVALID_INDEX : KOKKOS_IMPL_CTOR_DEFAULT_ARG;
102 return ResultView(Kokkos::Impl::with_properties_if_unset(prop, Kokkos::Impl::AccessorArg_t{fad_size}), layout);
104 if constexpr (std::is_pointer_v<CtorProp> && !std::is_convertible_v<CtorProp, const char*>) {
105 return ResultView(Kokkos::view_wrap(prop, Kokkos::Impl::AccessorArg_t{fad_size}), layout);
107 return ResultView(Kokkos::view_alloc(prop, Kokkos::Impl::AccessorArg_t{fad_size}), layout);
111 return ResultView(prop, layout);
114 return ResultView(prop, layout);
121 template <
typename ResultViewType,
typename InputViewType,
typename CtorProp,
123 typename std::enable_if<
125 ResultViewType>::type
127 const CtorProp& prop,
131 return view_factory::template create_view<ResultViewType>(
a,prop,dims...);
137 template <
typename InputView>
147 typename std::conditional<
152 Kokkos::DynRankView<input_value, result_layout, input_device>;
158 template <
typename InputViewType,
typename CtorProp,
typename ... Dims >
159 typename std::enable_if<
164 const CtorProp& prop,
168 return createDynRankViewWithType<ResultViewType>(
a, prop, dims...);
172 template <
typename ResultViewType,
typename InputViewType,
typename CtorProp,
174 typename std::enable_if<
176 ResultViewType>::type
178 const CtorProp& prop,
182 return view_factory::template create_view<ResultViewType>(
a,prop,dims...);
typename InputView::device_type input_device
std::enable_if< is_view< InputViewType >::value||is_dyn_rank_view< InputViewType >::value, typename Impl::ResultDynRankView< InputViewType >::type >::type createDynRankView(const InputViewType &a, const CtorProp &prop, const Dims...dims)
Wrapper to simplify use of Sacado ViewFactory.
typename std::conditional< std::is_same< input_layout, Kokkos::LayoutStride >::value, default_layout, input_layout >::type result_layout
Impl::ViewFactoryType< ViewPack...>::type value_type
typename input_device::execution_space::array_layout default_layout
Sacado::Promote< typename View::value_type, typename ViewFactoryType< ViewPack...>::type >::type type
std::enable_if< is_view< InputViewType >::value||is_dyn_rank_view< InputViewType >::value, ResultViewType >::type createDynRankViewWithType(const InputViewType &a, const CtorProp &prop, const Dims...dims)
Wrapper to simplify use of Sacado ViewFactory.
Kokkos::DynRankView< input_value, result_layout, input_device > type
typename InputView::array_layout input_layout
std::enable_if< is_view< InputViewType >::value||is_dyn_rank_view< InputViewType >::value, ResultViewType >::type createViewWithType(const InputViewType &a, const CtorProp &prop, const Dims...dims)
Wrapper to simplify use of Sacado ViewFactory.
static ResultView create_view(const ViewPack &...views, const CtorProp &prop, const Dims...dims)
typename InputView::non_const_value_type input_value
Base template specification for IsScalarType.