22 using Kokkos::DynRankView;
26 using Kokkos::dimension_scalar;
27 using Kokkos::view_alloc;
28 using Kokkos::WithoutInitializing;
29 const unsigned derivative_dim_plus_one = 7;
35 typedef View<double**, Kokkos::DefaultExecutionSpace> view_type;
38 view_type v1(
"v1", 10, 4);
39 view_type v2(
"v2", 10, 4);
42 using CommonValueType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::value_type;
43 using ScalarArrayType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::scalar_array_type;
45 auto cvt_for_ctorprop = Kokkos::common_view_alloc_prop(v1, v2);
48 typedef View< CommonValueType** > ViewCommonType;
49 ViewCommonType vct1( Kokkos::view_alloc(
"vct1", cvt_for_ctorprop), 10, 4 );
57 TEST_EQUALITY(check_eq_kokkos_type,
true);
58 TEST_EQUALITY(check_eq_scalar_double,
true);
63 typedef View<FadType**, Kokkos::DefaultExecutionSpace> view_type;
66 view_type v1(
"v1", 10, 4, derivative_dim_plus_one );
67 view_type v2(
"v2", 10, 4, derivative_dim_plus_one );
70 using CommonValueType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::value_type;
71 using ScalarArrayType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::scalar_array_type;
73 auto cvt_for_ctorprop = Kokkos::common_view_alloc_prop(v1, v2);
76 typedef View< CommonValueType** > ViewCommonType;
77 ViewCommonType vct1( Kokkos::view_alloc(
"vct1", cvt_for_ctorprop), 10, 4 );
79 TEST_EQUALITY(dimension_scalar(vct1), derivative_dim_plus_one);
93 typedef View<FadType**, Kokkos::DefaultExecutionSpace> view_of_fad_type;
94 typedef View<double**, Kokkos::DefaultExecutionSpace> view_of_pod_type;
97 view_of_fad_type v1(
"v1", 10, 4, derivative_dim_plus_one );
98 view_of_pod_type v2(
"v2", 10, 4);
101 using CommonValueType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::value_type;
102 using ScalarArrayType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::scalar_array_type;
104 auto cvt_for_ctorprop = Kokkos::common_view_alloc_prop(v1, v2);
107 typedef View< CommonValueType** > ViewCommonType;
108 ViewCommonType vct1( Kokkos::view_alloc(
"vct1", cvt_for_ctorprop), 10, 4 );
110 TEST_EQUALITY(dimension_scalar(vct1), derivative_dim_plus_one);
124 typedef DynRankView<FadType, Kokkos::DefaultExecutionSpace> view_type;
127 view_type v1(
"v1", 10, 4, derivative_dim_plus_one );
128 view_type v2(
"v2", 10, 4, derivative_dim_plus_one );
131 using CommonValueType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::value_type;
132 using ScalarArrayType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::scalar_array_type;
134 auto cvt_for_ctorprop = Kokkos::common_view_alloc_prop(v1, v2);
137 typedef DynRankView< CommonValueType > ViewCommonType;
138 ViewCommonType vct1( Kokkos::view_alloc(
"vct1", cvt_for_ctorprop), 10, 4 );
140 TEST_EQUALITY(dimension_scalar(vct1), derivative_dim_plus_one);
148 TEST_EQUALITY(check_neq_kokkos_type,
false);
149 TEST_EQUALITY(check_eq_fad_type,
true);
150 TEST_EQUALITY(check_eq_scalar_double,
true);
155 typedef DynRankView<FadType, Kokkos::DefaultExecutionSpace> view_of_fad_type;
156 typedef DynRankView<double, Kokkos::DefaultExecutionSpace> view_of_pod_type;
159 view_of_fad_type v1(
"v1", 10, 4, derivative_dim_plus_one );
160 view_of_pod_type v2(
"v2", 10, 4);
163 using CommonValueType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::value_type;
164 using ScalarArrayType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::scalar_array_type;
166 auto cvt_for_ctorprop = Kokkos::common_view_alloc_prop(v1, v2);
169 typedef DynRankView< CommonValueType > ViewCommonType;
170 ViewCommonType vct1( Kokkos::view_alloc(
"vct1", cvt_for_ctorprop), 10, 4 );
172 TEST_EQUALITY(dimension_scalar(vct1), derivative_dim_plus_one);
180 TEST_EQUALITY(check_neq_kokkos_type,
false);
181 TEST_EQUALITY(check_eq_fad_type,
true);
182 TEST_EQUALITY(check_eq_scalar_double,
true);
190 DynRankView<FadType>
a(
"a",10,4,13,derivative_dim_plus_one);
202 using d_type = Kokkos::DynRankView<FadType,Kokkos::LayoutRight>;
203 d_type d = createDynRankViewWithType<d_type>(
a,
"d",5,3,8);
205 TEST_EQUALITY(d.rank(),3);
210 View<FadType*>
a(
"a",8,derivative_dim_plus_one);
221 using d_type = Kokkos::DynRankView<FadType,Kokkos::LayoutRight>;
222 d_type d = createDynRankViewWithType<d_type>(
a,
"d",5,3,8);
224 TEST_EQUALITY(d.rank(),3);
229 View<FadType*>
a(
"a",8,derivative_dim_plus_one);
232 using b_type = Kokkos::View<FadType***>;
233 b_type b = createViewWithType<b_type>(
a,
"b",5,3,8);
236 b_type
c = createViewWithType<b_type>(
a,view_alloc(
"c",WithoutInitializing),5,3,8);
237 TEST_EQUALITY(dimension_scalar(c),derivative_dim_plus_one);
239 using d_type = Kokkos::View<FadType***,Kokkos::LayoutRight>;
240 d_type d = createViewWithType<d_type>(
a,
"d",5,3,8);
241 TEST_EQUALITY(dimension_scalar(d),derivative_dim_plus_one);
246 DynRankView<FadType>
a(
"a",10,4,13,derivative_dim_plus_one);
250 using b_type = Kokkos::View<FadType***>;
251 b_type b = createViewWithType<b_type>(
a,
"b",5,3,8);
254 b_type
c = createViewWithType<b_type>(
a,view_alloc(
"c",WithoutInitializing),5,3,8);
255 TEST_EQUALITY(dimension_scalar(c),derivative_dim_plus_one);
257 using d_type = Kokkos::View<FadType***,Kokkos::LayoutRight>;
258 d_type d = createViewWithType<d_type>(
a,
"d",5,3,8);
259 TEST_EQUALITY(dimension_scalar(d),derivative_dim_plus_one);
264 DynRankView<double>
a(
"a",10,4,13);
268 using b_type = Kokkos::DynRankView<FadType,Kokkos::LayoutRight>;
269 b_type b = createDynRankViewWithType<b_type>(
a,
"b",5,3,8);
271 TEST_EQUALITY(b.rank(),3);
276 DynRankView<double>
a(
"a",10,4,13);
287 DynRankView<double>
a(
"a",10,4,13);
298 DynRankView<FadType>
a(
"a",10,4,13,derivative_dim_plus_one);
309 Kokkos::View<double*>
a(
"a",5*3);
310 using b_type = Kokkos::View<double**,Kokkos::MemoryUnmanaged>;
311 b_type b = createViewWithType<b_type>(
a,a.data(),5,3);
319 Kokkos::View<FadType*>
a(
"a",5*3,derivative_dim_plus_one);
320 using b_type = Kokkos::View<FadType**,Kokkos::MemoryUnmanaged>;
321 b_type b = createViewWithType<b_type>(
a,a.data(),5,3);
329 Kokkos::DynRankView<double>
a(
"a",10,13);
330 auto b = Kokkos::subview(a, std::make_pair(4,8), std::make_pair(5,11));
332 using b_type = decltype(b);
333 using c_type = decltype(
c);
334 using b_layout =
typename b_type::array_layout;
335 using c_layout =
typename c_type::array_layout;
336 using default_layout =
typename b_type::device_type::execution_space::array_layout;
337 const bool is_b_layout_stride =
339 const bool is_c_default_layout =
351 Kokkos::DynRankView<FadType>
a(
"a",10,13,derivative_dim_plus_one);
352 auto b = Kokkos::subview(a, std::make_pair(4,8), std::make_pair(5,11));
354 using b_type = decltype(b);
355 using c_type = decltype(
c);
356 using b_layout =
typename b_type::array_layout;
357 using c_layout =
typename c_type::array_layout;
358 using default_layout =
typename b_type::device_type::execution_space::array_layout;
359 const bool is_b_layout_stride =
361 const bool is_c_default_layout =
373 int main(
int argc,
char* argv[] ) {
376 Kokkos::initialize();
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)