41 using Kokkos::DynRankView;
45 using Kokkos::dimension_scalar;
46 using Kokkos::view_alloc;
47 using Kokkos::WithoutInitializing;
48 const unsigned derivative_dim_plus_one = 7;
54 typedef View<double**, Kokkos::DefaultExecutionSpace> view_type;
57 view_type v1(
"v1", 10, 4);
58 view_type v2(
"v2", 10, 4);
61 using CommonValueType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::value_type;
62 using ScalarArrayType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::scalar_array_type;
64 auto cvt_for_ctorprop = Kokkos::common_view_alloc_prop(v1, v2);
67 typedef View< CommonValueType** > ViewCommonType;
68 ViewCommonType vct1( Kokkos::view_alloc(
"vct1", cvt_for_ctorprop), 10, 4 );
70 TEST_EQUALITY(vct1.extent(0), v1.extent(0));
71 TEST_EQUALITY(vct1.extent(1), v1.extent(1));
72 TEST_EQUALITY(vct1.extent(2), v1.extent(2));
73 TEST_EQUALITY( Kokkos::dimension_scalar(vct1), 0);
74 bool check_eq_kokkos_type = std::is_same < CommonValueType, ScalarArrayType >::value;
75 bool check_eq_scalar_double = std::is_same < double, ScalarArrayType >::value;
76 TEST_EQUALITY(check_eq_kokkos_type,
true);
77 TEST_EQUALITY(check_eq_scalar_double,
true);
82 typedef View<FadType**, Kokkos::DefaultExecutionSpace> view_type;
85 view_type v1(
"v1", 10, 4, derivative_dim_plus_one );
86 view_type v2(
"v2", 10, 4, derivative_dim_plus_one );
89 using CommonValueType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::value_type;
90 using ScalarArrayType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::scalar_array_type;
92 auto cvt_for_ctorprop = Kokkos::common_view_alloc_prop(v1, v2);
95 typedef View< CommonValueType** > ViewCommonType;
96 ViewCommonType vct1( Kokkos::view_alloc(
"vct1", cvt_for_ctorprop), 10, 4 );
98 TEST_EQUALITY(dimension_scalar(vct1), derivative_dim_plus_one);
99 TEST_EQUALITY(vct1.extent(0), v1.extent(0));
100 TEST_EQUALITY(vct1.extent(1), v1.extent(1));
101 TEST_EQUALITY(vct1.extent(2), v1.extent(2));
102 bool check_neq_kokkos_type = std::is_same < CommonValueType, ScalarArrayType >::value;
103 bool check_eq_fad_type = std::is_same < CommonValueType, FadType >::value;
104 bool check_eq_scalar_double = std::is_same < double, ScalarArrayType >::value;
105 TEST_EQUALITY(check_neq_kokkos_type,
false);
106 TEST_EQUALITY(check_eq_fad_type,
true);
107 TEST_EQUALITY(check_eq_scalar_double,
true);
112 typedef View<FadType**, Kokkos::DefaultExecutionSpace> view_of_fad_type;
113 typedef View<double**, Kokkos::DefaultExecutionSpace> view_of_pod_type;
116 view_of_fad_type v1(
"v1", 10, 4, derivative_dim_plus_one );
117 view_of_pod_type v2(
"v2", 10, 4);
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;
123 auto cvt_for_ctorprop = Kokkos::common_view_alloc_prop(v1, v2);
126 typedef View< CommonValueType** > ViewCommonType;
127 ViewCommonType vct1( Kokkos::view_alloc(
"vct1", cvt_for_ctorprop), 10, 4 );
129 TEST_EQUALITY(dimension_scalar(vct1), derivative_dim_plus_one);
130 TEST_EQUALITY(vct1.extent(0), v1.extent(0));
131 TEST_EQUALITY(vct1.extent(1), v1.extent(1));
132 TEST_EQUALITY(vct1.extent(2), v1.extent(2));
133 bool check_neq_kokkos_type = std::is_same < CommonValueType, ScalarArrayType >::value;
134 bool check_eq_fad_type = std::is_same < CommonValueType, FadType >::value;
135 bool check_eq_scalar_double = std::is_same < double, ScalarArrayType >::value;
136 TEST_EQUALITY(check_neq_kokkos_type,
false);
137 TEST_EQUALITY(check_eq_fad_type,
true);
138 TEST_EQUALITY(check_eq_scalar_double,
true);
143 typedef DynRankView<FadType, Kokkos::DefaultExecutionSpace> view_type;
146 view_type v1(
"v1", 10, 4, derivative_dim_plus_one );
147 view_type v2(
"v2", 10, 4, derivative_dim_plus_one );
150 using CommonValueType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::value_type;
151 using ScalarArrayType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::scalar_array_type;
153 auto cvt_for_ctorprop = Kokkos::common_view_alloc_prop(v1, v2);
156 typedef DynRankView< CommonValueType > ViewCommonType;
157 ViewCommonType vct1( Kokkos::view_alloc(
"vct1", cvt_for_ctorprop), 10, 4 );
159 TEST_EQUALITY(dimension_scalar(vct1), derivative_dim_plus_one);
160 TEST_EQUALITY(vct1.extent(0), v1.extent(0));
161 TEST_EQUALITY(vct1.extent(1), v1.extent(1));
162 TEST_EQUALITY(vct1.extent(2), v1.extent(2));
163 TEST_EQUALITY(Kokkos::rank(vct1), 2);
164 bool check_neq_kokkos_type = std::is_same < CommonValueType, ScalarArrayType >::value;
165 bool check_eq_fad_type = std::is_same < CommonValueType, FadType >::value;
166 bool check_eq_scalar_double = std::is_same < double, ScalarArrayType >::value;
167 TEST_EQUALITY(check_neq_kokkos_type,
false);
168 TEST_EQUALITY(check_eq_fad_type,
true);
169 TEST_EQUALITY(check_eq_scalar_double,
true);
174 typedef DynRankView<FadType, Kokkos::DefaultExecutionSpace> view_of_fad_type;
175 typedef DynRankView<double, Kokkos::DefaultExecutionSpace> view_of_pod_type;
178 view_of_fad_type v1(
"v1", 10, 4, derivative_dim_plus_one );
179 view_of_pod_type v2(
"v2", 10, 4);
182 using CommonValueType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::value_type;
183 using ScalarArrayType =
typename decltype( Kokkos::common_view_alloc_prop( v1, v2 ) )::scalar_array_type;
185 auto cvt_for_ctorprop = Kokkos::common_view_alloc_prop(v1, v2);
188 typedef DynRankView< CommonValueType > ViewCommonType;
189 ViewCommonType vct1( Kokkos::view_alloc(
"vct1", cvt_for_ctorprop), 10, 4 );
191 TEST_EQUALITY(dimension_scalar(vct1), derivative_dim_plus_one);
192 TEST_EQUALITY(vct1.extent(0), v1.extent(0));
193 TEST_EQUALITY(vct1.extent(1), v1.extent(1));
194 TEST_EQUALITY(vct1.extent(2), v1.extent(2));
195 TEST_EQUALITY(Kokkos::rank(vct1), 2);
196 bool check_neq_kokkos_type = std::is_same < CommonValueType, ScalarArrayType >::value;
197 bool check_eq_fad_type = std::is_same < CommonValueType, FadType >::value;
198 bool check_eq_scalar_double = std::is_same < double, ScalarArrayType >::value;
199 TEST_EQUALITY(check_neq_kokkos_type,
false);
200 TEST_EQUALITY(check_eq_fad_type,
true);
201 TEST_EQUALITY(check_eq_scalar_double,
true);
209 DynRankView<FadType>
a(
"a",10,4,13,derivative_dim_plus_one);
210 TEST_EQUALITY(dimension_scalar(
a),derivative_dim_plus_one);
211 TEST_EQUALITY(
a.rank(),3);
213 auto b = createDynRankView(
a,
"b",5,3,8);
214 TEST_EQUALITY(dimension_scalar(b),derivative_dim_plus_one);
215 TEST_EQUALITY(b.rank(),3);
217 auto c = createDynRankView(
a,view_alloc(
"c",WithoutInitializing),5,3,8);
218 TEST_EQUALITY(dimension_scalar(
c),derivative_dim_plus_one);
219 TEST_EQUALITY(
c.rank(),3);
221 using d_type = Kokkos::DynRankView<FadType,Kokkos::LayoutRight>;
222 d_type d = createDynRankViewWithType<d_type>(
a,
"d",5,3,8);
223 TEST_EQUALITY(dimension_scalar(d),derivative_dim_plus_one);
224 TEST_EQUALITY(d.rank(),3);
229 View<FadType*>
a(
"a",8,derivative_dim_plus_one);
230 TEST_EQUALITY(dimension_scalar(
a),derivative_dim_plus_one);
232 auto b = createDynRankView(
a,
"b",5,3,8);
233 TEST_EQUALITY(dimension_scalar(b),derivative_dim_plus_one);
234 TEST_EQUALITY(b.rank(),3);
236 auto c = createDynRankView(
a,view_alloc(
"c",WithoutInitializing),5,3,8);
237 TEST_EQUALITY(dimension_scalar(
c),derivative_dim_plus_one);
238 TEST_EQUALITY(
c.rank(),3);
240 using d_type = Kokkos::DynRankView<FadType,Kokkos::LayoutRight>;
241 d_type d = createDynRankViewWithType<d_type>(
a,
"d",5,3,8);
242 TEST_EQUALITY(dimension_scalar(d),derivative_dim_plus_one);
243 TEST_EQUALITY(d.rank(),3);
248 View<FadType*>
a(
"a",8,derivative_dim_plus_one);
249 TEST_EQUALITY(dimension_scalar(
a),derivative_dim_plus_one);
251 using b_type = Kokkos::View<FadType***>;
252 b_type b = createViewWithType<b_type>(
a,
"b",5,3,8);
253 TEST_EQUALITY(dimension_scalar(b),derivative_dim_plus_one);
255 b_type
c = createViewWithType<b_type>(
a,view_alloc(
"c",WithoutInitializing),5,3,8);
256 TEST_EQUALITY(dimension_scalar(
c),derivative_dim_plus_one);
258 using d_type = Kokkos::View<FadType***,Kokkos::LayoutRight>;
259 d_type d = createViewWithType<d_type>(
a,
"d",5,3,8);
260 TEST_EQUALITY(dimension_scalar(d),derivative_dim_plus_one);
265 DynRankView<FadType>
a(
"a",10,4,13,derivative_dim_plus_one);
266 TEST_EQUALITY(dimension_scalar(
a),derivative_dim_plus_one);
267 TEST_EQUALITY(
a.rank(),3);
269 using b_type = Kokkos::View<FadType***>;
270 b_type b = createViewWithType<b_type>(
a,
"b",5,3,8);
271 TEST_EQUALITY(dimension_scalar(b),derivative_dim_plus_one);
273 b_type
c = createViewWithType<b_type>(
a,view_alloc(
"c",WithoutInitializing),5,3,8);
274 TEST_EQUALITY(dimension_scalar(
c),derivative_dim_plus_one);
276 using d_type = Kokkos::View<FadType***,Kokkos::LayoutRight>;
277 d_type d = createViewWithType<d_type>(
a,
"d",5,3,8);
278 TEST_EQUALITY(dimension_scalar(d),derivative_dim_plus_one);
283 DynRankView<double>
a(
"a",10,4,13);
284 TEST_EQUALITY(dimension_scalar(
a),0);
285 TEST_EQUALITY(
a.rank(),3);
287 using b_type = Kokkos::DynRankView<FadType,Kokkos::LayoutRight>;
288 b_type b = createDynRankViewWithType<b_type>(
a,
"b",5,3,8);
289 TEST_EQUALITY(dimension_scalar(b),1);
290 TEST_EQUALITY(b.rank(),3);
295 DynRankView<double>
a(
"a",10,4,13);
296 TEST_EQUALITY(dimension_scalar(
a),0);
297 TEST_EQUALITY(
a.rank(),3);
299 auto b = createDynRankView(
a,
"b",5,3,8);
300 TEST_EQUALITY(dimension_scalar(b),0);
301 TEST_EQUALITY(b.rank(),3);
306 DynRankView<double>
a(
"a",10,4,13);
307 TEST_EQUALITY(dimension_scalar(
a),0);
308 TEST_EQUALITY(
a.rank(),3);
310 auto b = createDynRankView(
a,
"b");
311 TEST_EQUALITY(dimension_scalar(b),0);
312 TEST_EQUALITY(b.rank(),0);
317 DynRankView<FadType>
a(
"a",10,4,13,derivative_dim_plus_one);
318 TEST_EQUALITY(dimension_scalar(
a),derivative_dim_plus_one);
319 TEST_EQUALITY(
a.rank(),3);
321 auto b = createDynRankView(
a,
"b");
322 TEST_EQUALITY(dimension_scalar(b),derivative_dim_plus_one);
323 TEST_EQUALITY(b.rank(),0);
328 Kokkos::View<double*>
a(
"a",5*3);
329 using b_type = Kokkos::View<double**,Kokkos::MemoryUnmanaged>;
330 b_type b = createViewWithType<b_type>(
a,
a.data(),5,3);
331 TEST_EQUALITY(b.extent(0),5);
332 TEST_EQUALITY(b.extent(1),3);
333 TEST_EQUALITY(dimension_scalar(b),0);
338 Kokkos::View<FadType*>
a(
"a",5*3,derivative_dim_plus_one);
339 using b_type = Kokkos::View<FadType**,Kokkos::MemoryUnmanaged>;
340 b_type b = createViewWithType<b_type>(
a,
a.data(),5,3);
341 TEST_EQUALITY(b.extent(0),5);
342 TEST_EQUALITY(b.extent(1),3);
343 TEST_EQUALITY(dimension_scalar(b),derivative_dim_plus_one);
348 Kokkos::DynRankView<double>
a(
"a",10,13);
349 auto b = Kokkos::subview(
a, std::make_pair(4,8), std::make_pair(5,11));
350 auto c = createDynRankView(b,
"c",5,3);
351 using b_type =
decltype(b);
352 using c_type =
decltype(
c);
353 using b_layout =
typename b_type::array_layout;
354 using c_layout =
typename c_type::array_layout;
355 using default_layout =
typename b_type::device_type::execution_space::array_layout;
356 const bool is_b_layout_stride =
357 std::is_same<b_layout,Kokkos::LayoutStride>::value;
358 const bool is_c_default_layout =
359 std::is_same<c_layout,default_layout>::value;
360 TEST_EQUALITY(is_b_layout_stride,
true);
361 TEST_EQUALITY(is_c_default_layout,
true);
362 TEST_EQUALITY(
c.rank(),2);
363 TEST_EQUALITY(
c.extent(0),5);
364 TEST_EQUALITY(
c.extent(1),3);
365 TEST_EQUALITY(dimension_scalar(b),0);
370 Kokkos::DynRankView<FadType>
a(
"a",10,13,derivative_dim_plus_one);
371 auto b = Kokkos::subview(
a, std::make_pair(4,8), std::make_pair(5,11));
372 auto c = createDynRankView(b,
"c",5,3);
373 using b_type =
decltype(b);
374 using c_type =
decltype(
c);
375 using b_layout =
typename b_type::array_layout;
376 using c_layout =
typename c_type::array_layout;
377 using default_layout =
typename b_type::device_type::execution_space::array_layout;
378 const bool is_b_layout_stride =
379 std::is_same<b_layout,Kokkos::LayoutStride>::value;
380 const bool is_c_default_layout =
381 std::is_same<c_layout,default_layout>::value;
382 TEST_EQUALITY(is_b_layout_stride,
true);
383 TEST_EQUALITY(is_c_default_layout,
true);
384 TEST_EQUALITY(
c.rank(),2);
385 TEST_EQUALITY(
c.extent(0),5);
386 TEST_EQUALITY(
c.extent(1),3);
387 TEST_EQUALITY(dimension_scalar(b),derivative_dim_plus_one);