Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_KokkosViewMPVectorUnitTest.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
13 
15 #include "Stokhos_Ensemble_Sizes.hpp"
16 
17 // For computing DeviceConfig
18 #include "Kokkos_Core.hpp"
19 
20 //
21 // Tests various View< Sacado::MP::Vector<...>,...> operations work
22 // as expected
23 //
24 
25 // Helper functions
26 
27 template <typename scalar, typename ordinal>
28 inline
29 scalar generate_vector_coefficient( const ordinal nFEM,
30  const ordinal nStoch,
31  const ordinal iColFEM,
32  const ordinal iStoch )
33 {
34  const scalar X_fem = 100.0 + scalar(iColFEM) / scalar(nFEM);
35  const scalar X_stoch = 1.0 + scalar(iStoch) / scalar(nStoch);
36  return X_fem + X_stoch;
37  //return 1.0;
38 }
39 
40 template <typename ViewType>
41 bool
42 checkVectorView(const ViewType& v,
43  Teuchos::FancyOStream& out) {
44  typedef ViewType view_type;
45  typedef typename view_type::size_type size_type;
46  typedef typename view_type::HostMirror host_view_type;
47  typedef typename host_view_type::array_type host_array_type;
49 
50  // Copy to host
51  host_view_type h_v = Kokkos::create_mirror_view(v);
52  Kokkos::deep_copy(h_v, v);
53  host_array_type h_a = h_v;
54 
55  size_type num_rows, num_cols;
56 
57  // For static, layout left, sacado dimension becomes first dimension
58  // instead of last
59  bool is_right = std::is_same< typename ViewType::array_layout,
60  Kokkos::LayoutRight >::value;
61  if (is_right) {
62  num_rows = h_a.extent(0);
63  num_cols = h_a.extent(1);
64  }
65  else {
66  num_rows = h_a.extent(1);
67  num_cols = h_a.extent(0);
68  }
69  bool success = true;
70  if (is_right) {
71  for (size_type i=0; i<num_rows; ++i) {
72  for (size_type j=0; j<num_cols; ++j) {
73  scalar_type val = h_a(i,j);
74  scalar_type val_expected =
75  generate_vector_coefficient<scalar_type>(
76  num_rows, num_cols, i, j);
77  TEUCHOS_TEST_EQUALITY(val, val_expected, out, success);
78  }
79  }
80  }
81  else {
82  for (size_type i=0; i<num_rows; ++i) {
83  for (size_type j=0; j<num_cols; ++j) {
84  scalar_type val = h_a(j,i);
85  scalar_type val_expected =
86  generate_vector_coefficient<scalar_type>(
87  num_rows, num_cols, i, j);
88  TEUCHOS_TEST_EQUALITY(val, val_expected, out, success);
89  }
90  }
91  }
92 
93  return success;
94 }
95 
96 template <typename ViewType>
97 bool
98 checkConstantVectorView(const ViewType& v,
99  const typename ViewType::value_type& v_expected,
100  Teuchos::FancyOStream& out) {
101  typedef ViewType view_type;
102  typedef typename view_type::size_type size_type;
103  typedef typename view_type::HostMirror host_view_type;
105 
106  // Copy to host
107  host_view_type h_v = Kokkos::create_mirror_view(v);
108  Kokkos::deep_copy(h_v, v);
109 
110  const size_type num_rows = h_v.extent(0);
111  const size_type num_cols = Kokkos::dimension_scalar(h_v);
112  bool success = true;
113  for (size_type i=0; i<num_rows; ++i) {
114  for (size_type j=0; j<num_cols; ++j) {
115  scalar_type val = h_v(i).coeff(j);
116  scalar_type val_expected = v_expected.coeff(j);
117  TEUCHOS_TEST_EQUALITY(val, val_expected, out, success);
118  }
119  }
120 
121  return success;
122 }
123 
124 template <typename DataType, typename LayoutType, typename ExecutionSpace>
125 struct ApplyView {
126  typedef Kokkos::View<DataType,LayoutType,ExecutionSpace> type;
127 };
128 
129 struct NoLayout {};
130 template <typename DataType, typename ExecutionSpace>
131 struct ApplyView<DataType,NoLayout,ExecutionSpace> {
132  typedef Kokkos::View<DataType,ExecutionSpace> type;
133 };
134 
135 //
136 // Tests
137 //
138 
139 const int global_num_rows = 11;
140 const int global_num_cols = STOKHOS_DEFAULT_ENSEMBLE_SIZE;
141 
142 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Kokkos_View_MP, Size, Storage, Layout )
143 {
144  typedef typename Storage::execution_space Device;
145  typedef Sacado::MP::Vector<Storage> Vector;
146  typedef typename ApplyView<Vector*,Layout,Device>::type ViewType;
147  typedef typename ViewType::size_type size_type;
148 
149  const size_type num_rows = global_num_rows;
150  const size_type num_cols = Storage::is_static ? Storage::static_size : global_num_cols;
151  ViewType v("view", num_rows, num_cols);
152  TEUCHOS_TEST_EQUALITY(v.size(), num_rows, out, success);
153 }
154 
155 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Kokkos_View_MP, DeepCopy, Storage, Layout )
156 {
157  typedef typename Storage::execution_space Device;
158  typedef typename Storage::value_type Scalar;
159  typedef Sacado::MP::Vector<Storage> Vector;
160  typedef typename ApplyView<Vector*,Layout,Device>::type ViewType;
161  typedef typename ViewType::size_type size_type;
162  typedef typename ViewType::HostMirror host_view_type;
163  typedef typename host_view_type::array_type host_array_type;
164 
165  const size_type num_rows = global_num_rows;
166  const size_type num_cols = Storage::is_static ? Storage::static_size : global_num_cols;
167  ViewType v("view", num_rows, num_cols);
168  host_view_type h_v = Kokkos::create_mirror_view(v);
169  host_array_type h_a = h_v;
170 
171  bool is_right = std::is_same< typename ViewType::array_layout,
172  Kokkos::LayoutRight >::value;
173  if (is_right) {
174  for (size_type i=0; i<num_rows; ++i)
175  for (size_type j=0; j<num_cols; ++j)
176  h_a(i,j) = generate_vector_coefficient<Scalar>(
177  num_rows, num_cols, i, j);
178  }
179  else {
180  for (size_type i=0; i<num_rows; ++i)
181  for (size_type j=0; j<num_cols; ++j)
182  h_a(j,i) = generate_vector_coefficient<Scalar>(
183  num_rows, num_cols, i, j);
184  }
185  Kokkos::deep_copy(v, h_v);
186 
187  success = checkVectorView(v, out);
188 }
189 
190 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Kokkos_View_MP, DeepCopy_ConstantScalar, Storage, Layout )
191 {
192  typedef typename Storage::execution_space Device;
193  typedef typename Storage::value_type Scalar;
194  typedef Sacado::MP::Vector<Storage> Vector;
195  typedef typename ApplyView<Vector*,Layout,Device>::type ViewType;
196  typedef typename ViewType::size_type size_type;
197 
198  const size_type num_rows = global_num_rows;
199  const size_type num_cols = Storage::is_static ? Storage::static_size : global_num_cols;
200  ViewType v("view", num_rows, num_cols);
201  Scalar val = 1.2345;
202 
203  Kokkos::deep_copy( v, val );
204 
205  success = checkConstantVectorView(v, Vector(num_cols, val), out);
206 }
207 
208 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Kokkos_View_MP, DeepCopy_ConstantVector, Storage, Layout )
209 {
210  typedef typename Storage::execution_space Device;
211  typedef typename Storage::value_type Scalar;
212  typedef Sacado::MP::Vector<Storage> Vector;
213  typedef typename ApplyView<Vector*,Layout,Device>::type ViewType;
214  typedef typename ViewType::size_type size_type;
215 
216  const size_type num_rows = global_num_rows;
217  const size_type num_cols = Storage::is_static ? Storage::static_size : global_num_cols;
218  ViewType v("view", num_rows, num_cols);
219  Scalar val = 1.2345;
220 
221  Kokkos::deep_copy( v, Vector(val) );
222 
223  success = checkConstantVectorView(v, Vector(num_cols, val), out);
224 }
225 
226 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Kokkos_View_MP, DeepCopy_ConstantVector2, Storage, Layout )
227 {
228  typedef typename Storage::execution_space Device;
229  typedef typename Storage::value_type Scalar;
230  typedef Sacado::MP::Vector<Storage> Vector;
231  typedef typename ApplyView<Vector*,Layout,Device>::type ViewType;
232  typedef typename ViewType::size_type size_type;
233 
234  const size_type num_rows = global_num_rows;
235  const size_type num_cols = Storage::is_static ? Storage::static_size : global_num_cols;
236  ViewType v("view", num_rows, num_cols);
237  Vector val(num_cols, 0.0);
238  for (size_type j=0; j<num_cols; ++j)
239  val.fastAccessCoeff(j) =
240  generate_vector_coefficient<Scalar>(num_rows, num_cols, size_type(0), j);
241 
242  Kokkos::deep_copy( v, val );
243 
244  success = checkConstantVectorView(v, val, out);
245 }
246 
247 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Kokkos_View_MP, DeepCopy_Subview_Range, Storage )
248 {
249  typedef typename Storage::execution_space Device;
250  typedef typename Storage::value_type Scalar;
251  typedef Sacado::MP::Vector<Storage> Vector;
252  typedef typename ApplyView<Vector**,Kokkos::LayoutLeft,Device>::type ViewType;
253  typedef typename ViewType::size_type size_type;
254  typedef typename ViewType::HostMirror host_view_type;
255 
256  const size_type num_rows1 = global_num_rows;
257  const size_type num_rows2 = global_num_rows*2;
258  const size_type num_cols = 5;
259  const size_type num_vec =
260  Storage::is_static ? Storage::static_size : global_num_cols;
261  ViewType v1("view1", num_rows1, num_cols, num_vec);
262  ViewType v2("view2", num_rows2, num_cols, num_vec);
263 
264  for (size_type j=0; j<num_cols; ++j) {
265  std::pair<size_type,size_type> rows( 0, num_rows1 );
266  ViewType v1s = Kokkos::subview( v1, rows, std::pair<size_t,size_t> (j,j+1) );
267  ViewType v2s = Kokkos::subview( v2, rows, std::pair<size_t,size_t> (j,j+1) );
268  Kokkos::deep_copy( v1s, Scalar(j+1) );
269  Kokkos::deep_copy( v2s, v1s );
270  }
271 
272  // Check
273  success = true;
274  host_view_type hv2 = Kokkos::create_mirror_view( v2 );
275  Kokkos::deep_copy( hv2, v2 );
276  for (size_type j=0; j<num_cols; ++j) {
277  for (size_type i=0; i<num_rows1; ++i) {
278  for (size_type k=0; k<num_vec; ++k) {
279  Scalar val = hv2(i,j).fastAccessCoeff(k);
280  Scalar val_expected = j+1;
281  TEUCHOS_TEST_EQUALITY(val, val_expected, out, success);
282  }
283  }
284  for (size_type i=num_rows1; i<num_rows2; ++i) {
285  for (size_type k=0; k<num_vec; ++k) {
286  Scalar val = hv2(i,j).fastAccessCoeff(k);
287  Scalar val_expected = 0;
288  TEUCHOS_TEST_EQUALITY(val, val_expected, out, success);
289  }
290  }
291  }
292 }
293 
294 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Kokkos_View_MP, DeepCopy_HostArray, Storage, Layout )
295 {
296  typedef typename Storage::execution_space Device;
297  typedef typename Storage::value_type Scalar;
298  typedef Sacado::MP::Vector<Storage> Vector;
299  typedef typename ApplyView<Vector*,Layout,Device>::type ViewType;
300  typedef typename ViewType::size_type size_type;
301  typedef typename ViewType::HostMirror host_view_type;
302  typedef typename host_view_type::array_type host_array_type;
303 
304  const size_type num_rows = global_num_rows;
305  const size_type num_cols = Storage::is_static ? Storage::static_size : global_num_cols;
306  ViewType v("view", num_rows, num_cols);
307  host_array_type h_a = Kokkos::create_mirror_view(v);
308 
309  bool is_right = std::is_same< typename ViewType::array_layout,
310  Kokkos::LayoutRight >::value;
311  if (is_right) {
312  for (size_type i=0; i<num_rows; ++i)
313  for (size_type j=0; j<num_cols; ++j)
314  h_a(i,j) = generate_vector_coefficient<Scalar>(
315  num_rows, num_cols, i, j);
316  }
317  else {
318  for (size_type i=0; i<num_rows; ++i)
319  for (size_type j=0; j<num_cols; ++j)
320  h_a(j,i) = generate_vector_coefficient<Scalar>(
321  num_rows, num_cols, i, j);
322  }
323  Kokkos::deep_copy(v, h_a);
324 
325  success = checkVectorView(v, out);
326 }
327 
328 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Kokkos_View_MP, DeepCopy_DeviceArray, Storage, Layout )
329 {
330  typedef typename Storage::execution_space Device;
331  typedef typename Storage::value_type Scalar;
332  typedef Sacado::MP::Vector<Storage> Vector;
333  typedef typename ApplyView<Vector*,Layout,Device>::type ViewType;
334  typedef typename ViewType::size_type size_type;
335  typedef typename ViewType::HostMirror host_view_type;
336  typedef typename host_view_type::array_type host_array_type;
337  typedef typename ViewType::array_type array_type;
338 
339  const size_type num_rows = global_num_rows;
340  const size_type num_cols = Storage::is_static ? Storage::static_size : global_num_cols;
341  ViewType v("view", num_rows, num_cols);
342  host_view_type h_v = Kokkos::create_mirror_view(v);
343  host_array_type h_a = h_v;
344  array_type a = v;
345 
346  for (size_type i=0; i<num_rows; ++i)
347  for (size_type j=0; j<num_cols; ++j)
348  h_a(i,j) = generate_vector_coefficient<Scalar>(
349  num_rows, num_cols, i, j);
350  Kokkos::deep_copy(a, h_v);
351 
352  success = checkVectorView(v, out);
353 }
354 
355 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Kokkos_View_MP, Unmanaged, Storage, Layout )
356 {
357  typedef typename Storage::execution_space Device;
358  typedef typename Storage::value_type Scalar;
359  typedef Sacado::MP::Vector<Storage> Vector;
360  typedef typename ApplyView<Vector*,Layout,Device>::type ViewType;
361  typedef typename ViewType::size_type size_type;
362  typedef typename ViewType::HostMirror host_view_type;
363  typedef typename host_view_type::array_type host_array_type;
364 
365  const size_type num_rows = global_num_rows;
366  const size_type num_cols = Storage::is_static ? Storage::static_size : global_num_cols;
367  ViewType v("view", num_rows, num_cols);
368  host_view_type h_v = Kokkos::create_mirror_view(v);
369  host_array_type h_a = h_v;
370 
371  bool is_right = std::is_same< typename ViewType::array_layout,
372  Kokkos::LayoutRight >::value;
373  if (is_right) {
374  for (size_type i=0; i<num_rows; ++i)
375  for (size_type j=0; j<num_cols; ++j)
376  h_a(i,j) = generate_vector_coefficient<Scalar>(
377  num_rows, num_cols, i, j);
378  }
379  else {
380  for (size_type i=0; i<num_rows; ++i)
381  for (size_type j=0; j<num_cols; ++j)
382  h_a(j,i) = generate_vector_coefficient<Scalar>(
383  num_rows, num_cols, i, j);
384  }
385  Kokkos::deep_copy(v, h_v);
386 
387  // Create unmanaged view
388  ViewType v2(v.data(), num_rows, num_cols);
389 
390  success = checkVectorView(v2, out);
391 }
392 
393 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Kokkos_View_MP, PartitionHost, Storage, Layout )
394 {
395  typedef typename Storage::execution_space Device;
396  typedef typename Storage::value_type Scalar;
397  typedef Sacado::MP::Vector<Storage> Vector;
398  typedef typename ApplyView<Vector*,Layout,Device>::type ViewType;
399  typedef typename ViewType::size_type size_type;
400  typedef typename ViewType::HostMirror host_view_type;
401 
402  const size_type num_rows = global_num_rows;
403  const size_type num_cols = Storage::static_size;
404  ViewType v("view", num_rows, num_cols);
405  host_view_type h_v = Kokkos::create_mirror_view(v);
406 
407  const size_type num_cols_part = num_cols/2;
408  auto h_v1 = Kokkos::partition<num_cols_part>(h_v, 0);
409  auto h_v2 = Kokkos::partition<num_cols_part>(h_v, num_cols_part);
410 
411  for (size_type i=0; i<num_rows; ++i) {
412  for (size_type j=0; j<num_cols_part; ++j) {
413  h_v1(i).fastAccessCoeff(j) = generate_vector_coefficient<Scalar>(
414  num_rows, num_cols, i, j);
415  h_v2(i).fastAccessCoeff(j) = generate_vector_coefficient<Scalar>(
416  num_rows, num_cols, i, j+num_cols_part);
417  }
418  }
419  Kokkos::deep_copy(v, h_v);
420 
421  success = checkVectorView(v, out);
422 }
423 
424 /*
425 // This test does not work because we can't call deep_copy on partitioned views
426 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Kokkos_View_MP, PartitionDevice, Storage, Layout )
427 {
428  typedef typename Storage::execution_space Device;
429  typedef typename Storage::value_type Scalar;
430  typedef Sacado::MP::Vector<Storage> Vector;
431  typedef typename ApplyView<Vector*,Layout,Device>::type ViewType;
432  typedef typename ViewType::size_type size_type;
433 
434  // This test requires static storage, so it always passes if it isn't
435  if (!Storage::is_static) {
436  success = true;
437  return;
438  }
439 
440  const size_type num_rows = global_num_rows;
441  const size_type num_cols = Storage::static_size;
442  ViewType v("view", num_rows, num_cols);
443 
444  const size_type num_cols_part = num_cols/2;
445  auto v1 = Kokkos::partition<num_cols_part>(v, 0);
446  auto v2 = Kokkos::partition<num_cols_part>(v, num_cols_part);
447 
448  typename decltype(v1)::HostMirror h_v1 = Kokkos::create_mirror_view(v1);
449  typename decltype(v2)::HostMirror h_v2 = Kokkos::create_mirror_view(v2);
450 
451  for (size_type i=0; i<num_rows; ++i) {
452  for (size_type j=0; j<num_cols_part; ++j) {
453  h_v1(i).fastAccessCoeff(j) = generate_vector_coefficient<Scalar>(
454  num_rows, num_cols, i, j);
455  h_v2(i).fastAccessCoeff(j) = generate_vector_coefficient<Scalar>(
456  num_rows, num_cols, i, j+num_cols_part);
457  }
458  }
459  Kokkos::deep_copy(v1, h_v1);
460  Kokkos::deep_copy(v2, h_v2);
461 
462  success = checkVectorView(v, out);
463 }
464 */
465 
466 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Kokkos_View_MP, Flatten, Storage, Layout )
467 {
468  typedef typename Storage::execution_space Device;
469  typedef typename Storage::value_type Scalar;
470  typedef Sacado::MP::Vector<Storage> Vector;
471  typedef typename ApplyView<Vector*,Layout,Device>::type ViewType;
472  typedef typename ViewType::size_type size_type;
473  typedef typename Kokkos::FlatArrayType<ViewType>::type flat_view_type;
474  typedef typename flat_view_type::HostMirror host_flat_view_type;
475 
476  const size_type num_rows = global_num_rows;
477  const size_type num_cols = Storage::is_static ? Storage::static_size : global_num_cols;
478  ViewType v("view", num_rows, num_cols);
479 
480  // Create flattened view
481  flat_view_type flat_v = v;
482  host_flat_view_type h_flat_v = Kokkos::create_mirror_view(flat_v);
483  for (size_type i=0; i<num_rows; ++i)
484  for (size_type j=0; j<num_cols; ++j)
485  h_flat_v(i*num_cols+j) = generate_vector_coefficient<Scalar>(
486  num_rows, num_cols, i, j);
487  Kokkos::deep_copy(flat_v, h_flat_v);
488 
489  success = checkVectorView(v, out);
490 }
491 
492 namespace Test {
493 
494 template< class ViewType >
497 
500 
502  ViewType m_v ;
503 
504  MPVectorAtomicFunctor( const ViewType & v , const scalar_type & s ) : m_v( v ), m_s( s )
505  {
506  Kokkos::parallel_for( m_v.extent(0) , *this );
507  }
508 
509  KOKKOS_INLINE_FUNCTION
510  void operator()( int i ) const
511  {
512  vector_type v( m_s );
513  atomic_assign( & m_v(i) , v );
514  }
515 };
516 
517 }
518 
519 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Kokkos_View_MP, DeviceAtomic, Storage, Layout )
520 {
521  typedef typename Storage::execution_space Device;
522  typedef typename Storage::value_type Scalar;
523  typedef Sacado::MP::Vector<Storage> Vector;
524  typedef typename ApplyView<Vector*,Layout,Device>::type ViewType;
525  typedef typename ViewType::size_type size_type;
526 
527  const size_type num_rows = global_num_rows;
528  const size_type num_cols = Storage::is_static ? Storage::static_size : global_num_cols;
529  ViewType v("view", num_rows, num_cols);
530  Scalar val = 1.2345;
531 
532  (void) Test::MPVectorAtomicFunctor<ViewType>( v , val );
533 
534  success = checkConstantVectorView(v, val, out);
535 }
536 
537 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Kokkos_View_MP, AssignData, Storage, Layout )
538 {
539  typedef typename Storage::execution_space Device;
540  typedef typename Storage::value_type Scalar;
541  typedef Sacado::MP::Vector<Storage> Vector;
542  typedef typename ApplyView<Vector*,Layout,Device>::type ViewType;
543  typedef typename ViewType::size_type size_type;
544 
545  const size_type num_rows = global_num_rows;
546  const size_type num_cols = Storage::is_static ? Storage::static_size : global_num_cols;
547  ViewType v1("view1", num_rows, num_cols);
548  ViewType v2("view2", num_rows, num_cols);
549  Scalar val1 = 1.234;
550  Scalar val2 = 5.678;
551  Kokkos::deep_copy(v1, val1);
552  Kokkos::deep_copy(v2, val2);
553 
554  auto s1 = Kokkos::subview(v1, std::make_pair(0, 1));
555  auto s2 = Kokkos::subview(v2, std::make_pair(0, 1));
556 
557  s1.assign_data(s2.data());
558 
559  success = checkConstantVectorView(s1, val2, out);
560 }
561 
562 
563 #define VIEW_MP_VECTOR_TESTS_STORAGE_LAYOUT( STORAGE, LAYOUT ) \
564  TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
565  Kokkos_View_MP, Size, STORAGE, LAYOUT ) \
566  TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
567  Kokkos_View_MP, DeepCopy, STORAGE, LAYOUT ) \
568  TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
569  Kokkos_View_MP, DeepCopy_ConstantScalar, STORAGE, LAYOUT ) \
570  TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
571  Kokkos_View_MP, DeepCopy_ConstantVector, STORAGE, LAYOUT ) \
572  TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
573  Kokkos_View_MP, DeepCopy_ConstantVector2, STORAGE, LAYOUT ) \
574  TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
575  Kokkos_View_MP, Unmanaged, STORAGE, LAYOUT ) \
576  TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
577  Kokkos_View_MP, Flatten, STORAGE, LAYOUT ) \
578  TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
579  Kokkos_View_MP, AssignData, STORAGE, LAYOUT )
580 
581 // Some tests the fail, or fail to compile
582 
583  /*
584  // These don't compile as there are no deep_copy overloads between
585  // static view spec and its array_type. That could be done, but
586  // would require some additional work to ensure the shapes match.
587  // It is simple enough to create an array_type view, so deep copying
588  // between matching views isn't much more trouble.
589  TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
590  Kokkos_View_MP, DeepCopy_HostArray, STORAGE, LAYOUT ) \
591  TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
592  Kokkos_View_MP, DeepCopy_DeviceArray, STORAGE, LAYOUT )
593  */
594 
595 #define VIEW_MP_VECTOR_TESTS_STORAGE( STORAGE ) \
596  using Kokkos::LayoutLeft; \
597  using Kokkos::LayoutRight; \
598  VIEW_MP_VECTOR_TESTS_STORAGE_LAYOUT(STORAGE, NoLayout) \
599  VIEW_MP_VECTOR_TESTS_STORAGE_LAYOUT(STORAGE, LayoutLeft) \
600  VIEW_MP_VECTOR_TESTS_STORAGE_LAYOUT(STORAGE, LayoutRight) \
601  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \
602  Kokkos_View_MP, DeepCopy_Subview_Range, STORAGE )
603 
604 // Removing the DynamicStorage tests since we don't use it for anything real,
605 // and it doesn't necessarily work without UVM
606 #define VIEW_MP_VECTOR_TESTS_ORDINAL_SCALAR_DEVICE( ORDINAL, SCALAR, DEVICE ) \
607  typedef Stokhos::StaticFixedStorage<ORDINAL,SCALAR,global_num_cols,DEVICE> SFS; \
608  VIEW_MP_VECTOR_TESTS_STORAGE( SFS ) \
609  TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
610  Kokkos_View_MP, PartitionHost, SFS, NoLayout ) \
611  TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
612  Kokkos_View_MP, PartitionHost, SFS, LayoutLeft ) \
613  TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
614  Kokkos_View_MP, PartitionHost, SFS, LayoutRight )
615 
616 #define VIEW_MP_VECTOR_TESTS_DEVICE( DEVICE ) \
617  VIEW_MP_VECTOR_TESTS_ORDINAL_SCALAR_DEVICE( int, double, DEVICE )
bool checkConstantVectorView(const ViewType &v, const typename ViewType::value_type &v_expected, Teuchos::FancyOStream &out)
KOKKOS_INLINE_FUNCTION void operator()(int i) const
Kokkos::DefaultExecutionSpace execution_space
scalar generate_vector_coefficient(const ordinal nFEM, const ordinal nStoch, const ordinal iColFEM, const ordinal iStoch)
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< View< T, P...> >::value, unsigned >::type dimension_scalar(const View< T, P...> &view)
vector_type::storage_type::value_type scalar_type
bool checkVectorView(const ViewType &v, Teuchos::FancyOStream &out)
TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL(Kokkos_SG_SpMv, CrsProductTensorCijk, Scalar, Device)
KOKKOS_INLINE_FUNCTION void atomic_assign(volatile Sacado::UQ::PCE< Storage > *const dest, const Sacado::UQ::PCE< Storage > &src)
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
expr val()
#define TEUCHOS_TEST_EQUALITY(v1, v2, out, success)
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(Kokkos_CrsMatrix_MP, ReplaceValues, MatrixScalar)
SparseArrayIterator< index_iterator, value_iterator >::value_reference value(const SparseArrayIterator< index_iterator, value_iterator > &it)
Kokkos::View< DataType, LayoutType, ExecutionSpace > type
Stokhos::CrsMatrix< ValueType, Device, Layout >::HostMirror create_mirror_view(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)
MPVectorAtomicFunctor(const ViewType &v, const scalar_type &s)