22 using Kokkos::DynRankView;
26 #ifndef SACADO_HAS_NEW_KOKKOS_VIEW_IMPL
27 using Kokkos::dimension_scalar;
29 using Sacado::dimension_scalar;
31 using Kokkos::view_alloc;
32 using Kokkos::WithoutInitializing;
33 const unsigned derivative_dim_plus_one = 7;
39 typedef View<double**, Kokkos::DefaultExecutionSpace> view_type;
42 view_type v1(
"v1", 10, 4);
43 view_type v2(
"v2", 10, 4);
48 #ifndef SACADO_HAS_NEW_KOKKOS_VIEW_IMPL
49 using CommonValueType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::value_type;
50 using ScalarArrayType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::scalar_array_type;
52 using CommonValueType = double;
53 using ScalarArrayType = double;
56 auto cvt_for_ctorprop = Kokkos::common_view_alloc_prop(v1, v2);
59 typedef View< CommonValueType** > ViewCommonType;
60 ViewCommonType vct1( Kokkos::view_alloc(
"vct1", cvt_for_ctorprop), 10, 4 );
68 TEST_EQUALITY(check_eq_kokkos_type,
true);
69 TEST_EQUALITY(check_eq_scalar_double,
true);
74 typedef View<FadType**, Kokkos::DefaultExecutionSpace> view_type;
77 view_type v1(
"v1", 10, 4, derivative_dim_plus_one );
78 view_type v2(
"v2", 10, 4, derivative_dim_plus_one );
83 #ifndef SACADO_HAS_NEW_KOKKOS_VIEW_IMPL
84 using CommonValueType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::value_type;
85 using ScalarArrayType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::scalar_array_type;
91 auto cvt_for_ctorprop = Kokkos::common_view_alloc_prop(v1, v2);
94 typedef View< CommonValueType** > ViewCommonType;
95 ViewCommonType vct1( Kokkos::view_alloc(
"vct1", cvt_for_ctorprop), 10, 4 );
97 TEST_EQUALITY(dimension_scalar(vct1), derivative_dim_plus_one);
111 typedef View<FadType**, Kokkos::DefaultExecutionSpace> view_of_fad_type;
112 typedef View<double**, Kokkos::DefaultExecutionSpace> view_of_pod_type;
115 view_of_fad_type v1(
"v1", 10, 4, derivative_dim_plus_one );
116 view_of_pod_type v2(
"v2", 10, 4);
119 #ifndef SACADO_HAS_NEW_KOKKOS_VIEW_IMPL
120 using CommonValueType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::value_type;
121 using ScalarArrayType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::scalar_array_type;
127 auto cvt_for_ctorprop = Kokkos::common_view_alloc_prop(v1, v2);
129 typedef View< CommonValueType** > ViewCommonType;
130 ViewCommonType vct1( Kokkos::view_alloc(
"vct1", cvt_for_ctorprop), 10, 4 );
132 TEST_EQUALITY(dimension_scalar(vct1), derivative_dim_plus_one);
146 typedef DynRankView<FadType, Kokkos::DefaultExecutionSpace> view_type;
149 view_type v1(
"v1", 10, 4, derivative_dim_plus_one );
150 view_type v2(
"v2", 10, 4, derivative_dim_plus_one );
153 #ifndef SACADO_HAS_NEW_KOKKOS_VIEW_IMPL
154 using CommonValueType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::value_type;
155 using ScalarArrayType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::scalar_array_type;
161 auto cvt_for_ctorprop = Kokkos::common_view_alloc_prop(v1, v2);
164 typedef DynRankView< CommonValueType > ViewCommonType;
165 ViewCommonType vct1( Kokkos::view_alloc(
"vct1", cvt_for_ctorprop), 10, 4 );
167 TEST_EQUALITY(dimension_scalar(vct1), derivative_dim_plus_one);
175 TEST_EQUALITY(check_neq_kokkos_type,
false);
176 TEST_EQUALITY(check_eq_fad_type,
true);
177 TEST_EQUALITY(check_eq_scalar_double,
true);
182 typedef DynRankView<FadType, Kokkos::DefaultExecutionSpace> view_of_fad_type;
183 typedef DynRankView<double, Kokkos::DefaultExecutionSpace> view_of_pod_type;
186 view_of_fad_type v1(
"v1", 10, 4, derivative_dim_plus_one );
187 view_of_pod_type v2(
"v2", 10, 4);
190 #ifndef SACADO_HAS_NEW_KOKKOS_VIEW_IMPL
191 using CommonValueType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::value_type;
192 using ScalarArrayType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::scalar_array_type;
198 auto cvt_for_ctorprop = Kokkos::common_view_alloc_prop(v1, v2);
201 typedef DynRankView< CommonValueType > ViewCommonType;
202 ViewCommonType vct1( Kokkos::view_alloc(
"vct1", cvt_for_ctorprop), 10, 4 );
204 TEST_EQUALITY(dimension_scalar(vct1), derivative_dim_plus_one);
212 TEST_EQUALITY(check_neq_kokkos_type,
false);
213 TEST_EQUALITY(check_eq_fad_type,
true);
214 TEST_EQUALITY(check_eq_scalar_double,
true);
222 DynRankView<FadType>
a(
"a",10,4,13,derivative_dim_plus_one);
234 using d_type = Kokkos::DynRankView<FadType,Kokkos::LayoutRight>;
235 d_type d = createDynRankViewWithType<d_type>(
a,
"d",5,3,8);
237 TEST_EQUALITY(d.rank(),3);
242 View<FadType*>
a(
"a",8,derivative_dim_plus_one);
253 using d_type = Kokkos::DynRankView<FadType,Kokkos::LayoutRight>;
254 d_type d = createDynRankViewWithType<d_type>(
a,
"d",5,3,8);
256 TEST_EQUALITY(d.rank(),3);
261 View<FadType*>
a(
"a",8,derivative_dim_plus_one);
264 using b_type = Kokkos::View<FadType***>;
265 b_type b = createViewWithType<b_type>(
a,
"b",5,3,8);
268 b_type
c = createViewWithType<b_type>(
a,view_alloc(
"c",WithoutInitializing),5,3,8);
269 TEST_EQUALITY(dimension_scalar(c),derivative_dim_plus_one);
271 using d_type = Kokkos::View<FadType***,Kokkos::LayoutRight>;
272 d_type d = createViewWithType<d_type>(
a,
"d",5,3,8);
273 TEST_EQUALITY(dimension_scalar(d),derivative_dim_plus_one);
278 DynRankView<FadType>
a(
"a",10,4,13,derivative_dim_plus_one);
282 using b_type = Kokkos::View<FadType***>;
283 b_type b = createViewWithType<b_type>(
a,
"b",5,3,8);
286 b_type
c = createViewWithType<b_type>(
a,view_alloc(
"c",WithoutInitializing),5,3,8);
287 TEST_EQUALITY(dimension_scalar(c),derivative_dim_plus_one);
289 using d_type = Kokkos::View<FadType***,Kokkos::LayoutRight>;
290 d_type d = createViewWithType<d_type>(
a,
"d",5,3,8);
291 TEST_EQUALITY(dimension_scalar(d),derivative_dim_plus_one);
296 DynRankView<double>
a(
"a",10,4,13);
300 using b_type = Kokkos::DynRankView<FadType,Kokkos::LayoutRight>;
301 b_type b = createDynRankViewWithType<b_type>(
a,
"b",5,3,8);
303 TEST_EQUALITY(b.rank(),3);
308 DynRankView<double>
a(
"a",10,4,13);
319 DynRankView<double>
a(
"a",10,4,13);
330 DynRankView<FadType>
a(
"a",10,4,13,derivative_dim_plus_one);
341 Kokkos::View<double*>
a(
"a",5*3);
342 using b_type = Kokkos::View<double**,Kokkos::MemoryUnmanaged>;
343 b_type b = createViewWithType<b_type>(
a,a.data(),5,3);
351 Kokkos::View<FadType*>
a(
"a",5*3,derivative_dim_plus_one);
352 using b_type = Kokkos::View<FadType**,Kokkos::MemoryUnmanaged>;
353 b_type b = createViewWithType<b_type>(
a,a.data(),5,3);
361 Kokkos::DynRankView<double>
a(
"a",10,13);
362 auto b =
Kokkos::subview(a, std::make_pair(4,8), std::make_pair(5,11));
364 using b_type = decltype(b);
365 using c_type = decltype(
c);
366 using b_layout =
typename b_type::array_layout;
367 using c_layout =
typename c_type::array_layout;
368 using default_layout =
typename b_type::device_type::execution_space::array_layout;
369 const bool is_b_layout_stride =
371 const bool is_c_default_layout =
383 Kokkos::DynRankView<FadType>
a(
"a",10,13,derivative_dim_plus_one);
384 auto b =
Kokkos::subview(a, std::make_pair(4,8), std::make_pair(5,11));
386 using b_type = decltype(b);
387 using c_type = decltype(
c);
388 using b_layout =
typename b_type::array_layout;
389 using c_layout =
typename c_type::array_layout;
390 using default_layout =
typename b_type::device_type::execution_space::array_layout;
391 const bool is_b_layout_stride =
393 const bool is_c_default_layout =
405 int main(
int argc,
char* argv[] ) {
408 Kokkos::initialize();
KOKKOS_INLINE_FUNCTION auto subview(const View< D, Kokkos::LayoutContiguous< LayoutSrc, StrideSrc >, P...> &src, Args...args)
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.
TEUCHOS_UNIT_TEST(Conversion, IsConvertible)
static int runUnitTestsFromMain(int argc, char *argv[])
expr expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c *expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 c
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.
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.
#define TEST_EQUALITY(v1, v2)