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 );
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);
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;
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);
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;
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);
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);
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);
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);
240 using d_type = Kokkos::DynRankView<FadType,Kokkos::LayoutRight>;
241 d_type d = createDynRankViewWithType<d_type>(
a,
"d",5,3,8);
243 TEST_EQUALITY(d.rank(),3);
248 View<FadType*>
a(
"a",8,derivative_dim_plus_one);
251 using b_type = Kokkos::View<FadType***>;
252 b_type b = createViewWithType<b_type>(
a,
"b",5,3,8);
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);
269 using b_type = Kokkos::View<FadType***>;
270 b_type b = createViewWithType<b_type>(
a,
"b",5,3,8);
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);
287 using b_type = Kokkos::DynRankView<FadType,Kokkos::LayoutRight>;
288 b_type b = createDynRankViewWithType<b_type>(
a,
"b",5,3,8);
290 TEST_EQUALITY(b.rank(),3);
295 DynRankView<double>
a(
"a",10,4,13);
306 DynRankView<double>
a(
"a",10,4,13);
317 DynRankView<FadType>
a(
"a",10,4,13,derivative_dim_plus_one);
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);
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);
348 Kokkos::DynRankView<double>
a(
"a",10,13);
349 auto b = Kokkos::subview(a, std::make_pair(4,8), std::make_pair(5,11));
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;
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));
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;
392 int main(
int argc,
char* argv[] ) {
395 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)