Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_KokkosCrsMatrixMPVectorUnitTest.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 
12 
14 #include "Stokhos_Ensemble_Sizes.hpp"
17 
18 // For computing DeviceConfig
19 #include "Kokkos_Core.hpp"
20 
21 // Helper functions
22 template< typename IntType >
23 inline
24 IntType map_fem_graph_coord( const IntType& N,
25  const IntType& i,
26  const IntType& j,
27  const IntType& k )
28 {
29  return k + N * ( j + N * i );
30 }
31 
32 template < typename ordinal >
33 inline
34 ordinal generate_fem_graph( ordinal N,
35  std::vector< std::vector<ordinal> >& graph )
36 {
37  graph.resize( N * N * N, std::vector<ordinal>() );
38 
39  ordinal total = 0;
40 
41  for ( int i = 0; i < (int) N; ++i ) {
42  for ( int j = 0; j < (int) N; ++j ) {
43  for ( int k = 0; k < (int) N; ++k ) {
44 
45  const ordinal row = map_fem_graph_coord((int)N,i,j,k);
46 
47  graph[row].reserve(27);
48 
49  for ( int ii = -1; ii < 2; ++ii ) {
50  for ( int jj = -1; jj < 2; ++jj ) {
51  for ( int kk = -1; kk < 2; ++kk ) {
52  if ( 0 <= i + ii && i + ii < (int) N &&
53  0 <= j + jj && j + jj < (int) N &&
54  0 <= k + kk && k + kk < (int) N ) {
55  ordinal col = map_fem_graph_coord((int)N,i+ii,j+jj,k+kk);
56 
57  graph[row].push_back(col);
58  }
59  }}}
60  total += graph[row].size();
61  }}}
62 
63  return total;
64 }
65 
66 template <typename scalar, typename ordinal>
67 inline
68 scalar generate_matrix_coefficient( const ordinal nFEM,
69  const ordinal nStoch,
70  const ordinal iRowFEM,
71  const ordinal iColFEM,
72  const ordinal iStoch )
73 {
74  const scalar A_fem = ( 10.0 + scalar(iRowFEM) / scalar(nFEM) ) +
75  ( 5.0 + scalar(iColFEM) / scalar(nFEM) );
76 
77  const scalar A_stoch = ( 1.0 + scalar(iStoch) / scalar(nStoch) );
78 
79  return A_fem + A_stoch;
80  //return 1.0;
81 }
82 
83 template <typename scalar, typename ordinal>
84 inline
85 scalar generate_vector_coefficient( const ordinal nFEM,
86  const ordinal nStoch,
87  const ordinal iColFEM,
88  const ordinal iStoch )
89 {
90  const scalar X_fem = 100.0 + scalar(iColFEM) / scalar(nFEM);
91  const scalar X_stoch = 1.0 + scalar(iStoch) / scalar(nStoch);
92  return X_fem + X_stoch;
93  //return 1.0;
94 }
95 
96 // Reasonable tolerances for common precisions
97 template <typename Scalar> struct ScalarTol {};
98 template <> struct ScalarTol<float> { static float tol() { return 1e-4; } };
99 template <> struct ScalarTol<double> { static double tol() { return 1e-10; } };
100 
101 // Compare two rank-2 views for equality, to given precision
102 template <typename array_type, typename scalar_type>
103 bool compare_rank_2_views(const array_type& y,
104  const array_type& y_exp,
105  const scalar_type rel_tol,
106  const scalar_type abs_tol,
108 {
109  typedef typename array_type::size_type size_type;
110  typename array_type::HostMirror hy = Kokkos::create_mirror_view(y);
111  typename array_type::HostMirror hy_exp = Kokkos::create_mirror_view(y_exp);
112  Kokkos::deep_copy(hy, y);
113  Kokkos::deep_copy(hy_exp, y_exp);
114 
115  size_type num_rows = y.extent(0);
116  size_type num_cols = y.extent(1);
117  bool success = true;
118  for (size_type i=0; i<num_rows; ++i) {
119  for (size_type j=0; j<num_cols; ++j) {
120  scalar_type diff = std::abs( hy(i,j) - hy_exp(i,j) );
121  scalar_type tol = rel_tol*std::abs(hy_exp(i,j)) + abs_tol;
122  bool s = diff < tol;
123  out << "y_expected(" << i << "," << j << ") - "
124  << "y(" << i << "," << j << ") = " << hy_exp(i,j)
125  << " - " << hy(i,j) << " == "
126  << diff << " < " << tol << " : ";
127  if (s)
128  out << "passed";
129  else
130  out << "failed";
131  out << std::endl;
132  success = success && s;
133  }
134  }
135 
136  return success;
137 }
138 
139 // Helper function to build a diagonal matrix
140 template <typename MatrixType>
141 MatrixType
143  typename MatrixType::ordinal_type mp_vector_size) {
144  typedef typename MatrixType::ordinal_type ordinal_type;
145  typedef typename MatrixType::StaticCrsGraphType matrix_graph_type;
146  typedef typename MatrixType::values_type matrix_values_type;
147 
148  std::vector< std::vector<ordinal_type> > graph(nrow);
149  for (ordinal_type i=0; i<nrow; ++i)
150  graph[i] = std::vector<ordinal_type>(1, i);
151  ordinal_type graph_length = nrow;
152 
153  matrix_graph_type matrix_graph =
154  Kokkos::create_staticcrsgraph<matrix_graph_type>("graph", graph);
155  matrix_values_type matrix_values =
156  matrix_values_type("values", graph_length, mp_vector_size);
157 
158  MatrixType matrix("matrix", nrow, matrix_values, matrix_graph);
159  return matrix;
160 }
161 
162 //
163 // Tests
164 //
165 
166 // Kernel to set diagonal of a matrix to prescribed values
167 template <typename MatrixType>
170  typedef typename MatrixType::size_type size_type;
173 
174  const MatrixType m_matrix;
175  ReplaceDiagonalValuesKernel(const MatrixType matrix) : m_matrix(matrix) {};
176 
177  // Replace diagonal entry for row 'i' with a value
178  KOKKOS_INLINE_FUNCTION
179  void operator() (const size_type i) const {
180  const ordinal_type row = i;
181  const ordinal_type col = i;
182  value_type val = value_type(row);
183  m_matrix.replaceValues(row, &col, 1, &val, false, true);
184  }
185 
186  // Kernel launch
187  static void apply(const MatrixType matrix) {
188  const size_type nrow = matrix.numRows();
189  Kokkos::parallel_for( nrow, ReplaceDiagonalValuesKernel(matrix) );
190  }
191 
192  // Check the result is as expected
193  static bool check(const MatrixType matrix,
194  Teuchos::FancyOStream& out) {
195  typedef typename MatrixType::values_type matrix_values_type;
196  typename matrix_values_type::HostMirror host_matrix_values =
197  Kokkos::create_mirror_view(matrix.values);
198  Kokkos::deep_copy(host_matrix_values, matrix.values);
199  const ordinal_type nrow = matrix.numRows();
200  const ordinal_type vec_size = Kokkos::dimension_scalar(host_matrix_values);
201  bool success = true;
202  for (ordinal_type row=0; row<nrow; ++row) {
203  bool s = compareVecs(host_matrix_values(row),
204  "matrix_values(row)",
205  value_type(vec_size, row),
206  "value_type(row)",
207  0.0, 0.0, out);
208  success = success && s;
209  }
210  return success;
211  }
212 };
213 
214 // Kernel to add values to the diagonal of a matrix
215 template <typename MatrixType>
218  typedef typename MatrixType::size_type size_type;
221 
222  const MatrixType m_matrix;
223  AddDiagonalValuesKernel(const MatrixType matrix) : m_matrix(matrix) {};
224 
225  // Replace diagonal entry for row 'i' with a value
226  KOKKOS_INLINE_FUNCTION
227  void operator() (const size_type i) const {
228  const ordinal_type row = i;
229  const ordinal_type col = i;
230  value_type val = value_type(row);
231  m_matrix.sumIntoValues(row, &col, 1, &val, false, true);
232  }
233 
234  // Kernel launch
235  static void apply(const MatrixType matrix) {
236  const size_type nrow = matrix.numRows();
237  Kokkos::parallel_for( nrow, AddDiagonalValuesKernel(matrix) );
238  }
239 
240  // Check the result is as expected
241  static bool check(const MatrixType matrix,
242  Teuchos::FancyOStream& out) {
243  typedef typename MatrixType::values_type matrix_values_type;
244  typename matrix_values_type::HostMirror host_matrix_values =
245  Kokkos::create_mirror_view(matrix.values);
246  Kokkos::deep_copy(host_matrix_values, matrix.values);
247  const ordinal_type nrow = matrix.numRows();
248  const ordinal_type vec_size = Kokkos::dimension_scalar(host_matrix_values);
249  bool success = true;
250  for (ordinal_type row=0; row<nrow; ++row) {
251  bool s = compareVecs(host_matrix_values(row),
252  "matrix_values(row)",
253  value_type(vec_size, row),
254  "value_type(row)",
255  0.0, 0.0, out);
256  success = success && s;
257  }
258  return success;
259  }
260 };
261 
262 // Kernel to add values to the diagonal of a matrix where each thread
263 // adds to the same row (checks atomic really works)
264 template <typename MatrixType>
267  typedef typename MatrixType::size_type size_type;
270 
271  const MatrixType m_matrix;
272  AddDiagonalValuesAtomicKernel(const MatrixType matrix) : m_matrix(matrix) {};
273 
274  // Replace diagonal entry for row 'i' with a value
275  KOKKOS_INLINE_FUNCTION
276  void operator() (const size_type i) const {
277  const ordinal_type row = 0;
278  const ordinal_type col = 0;
280  m_matrix.sumIntoValues(row, &col, 1, &val, false, true);
281  }
282 
283  // Kernel launch
284  static void apply(const MatrixType matrix) {
285  const size_type nrow = matrix.numRows();
286  Kokkos::parallel_for( nrow, AddDiagonalValuesAtomicKernel(matrix) );
287  }
288 
289  // Check the result is as expected
290  static bool check(const MatrixType matrix,
291  Teuchos::FancyOStream& out) {
292  typedef typename MatrixType::values_type matrix_values_type;
293  typename matrix_values_type::HostMirror host_matrix_values =
294  Kokkos::create_mirror_view(matrix.values);
295  Kokkos::deep_copy(host_matrix_values, matrix.values);
296  const ordinal_type nrow = matrix.numRows();
297  const ordinal_type vec_size = Kokkos::dimension_scalar(host_matrix_values);
298  bool success = true;
299  for (ordinal_type row=0; row<nrow; ++row) {
300  value_type val;
301  if (row == 0)
302  val = value_type( vec_size, nrow*(nrow-1)/2 );
303  else
304  val = value_type( vec_size, 0.0 );
305  bool s = compareVecs(host_matrix_values(row),
306  "matrix_values(row)",
307  val,
308  "val",
309  0.0, 0.0, out);
310  success = success && s;
311  }
312  return success;
313  }
314 };
315 
316 const unsigned VectorSize = STOKHOS_DEFAULT_ENSEMBLE_SIZE;
317 
319  Kokkos_CrsMatrix_MP, ReplaceValues, MatrixScalar )
320 {
321  typedef typename MatrixScalar::ordinal_type Ordinal;
323  typedef Kokkos::Device<execution_space, typename execution_space::memory_space> Device;
324  typedef KokkosSparse::CrsMatrix<MatrixScalar,Ordinal,Device> Matrix;
325 
326  // Build diagonal matrix
327  Ordinal nrow = 10;
328  Matrix matrix = buildDiagonalMatrix<Matrix>(nrow, VectorSize);
329 
330  // Launch our kernel
332  kernel::apply(matrix);
333 
334  // Check the result
335  success = kernel::check(matrix, out);
336 }
337 
339  Kokkos_CrsMatrix_MP, SumIntoValues, MatrixScalar )
340 {
341  typedef typename MatrixScalar::ordinal_type Ordinal;
343  typedef Kokkos::Device<execution_space, typename execution_space::memory_space> Device;
344  typedef KokkosSparse::CrsMatrix<MatrixScalar,Ordinal,Device> Matrix;
345 
346  // Build diagonal matrix
347  Ordinal nrow = 10;
348  Matrix matrix = buildDiagonalMatrix<Matrix>(nrow, VectorSize);
349 
350  // Launch our kernel
351  typedef AddDiagonalValuesKernel<Matrix> kernel;
352  kernel::apply(matrix);
353 
354  // Check the result
355  success = kernel::check(matrix, out);
356 }
357 
359  Kokkos_CrsMatrix_MP, SumIntoValuesAtomic, MatrixScalar )
360 {
361  typedef typename MatrixScalar::ordinal_type Ordinal;
363  typedef Kokkos::Device<execution_space, typename execution_space::memory_space> Device;
364  typedef KokkosSparse::CrsMatrix<MatrixScalar,Ordinal,Device> Matrix;
365 
366  // Build diagonal matrix
367  Ordinal nrow = 10;
368  Matrix matrix = buildDiagonalMatrix<Matrix>(nrow, VectorSize);
369 
370  // Launch our kernel
372  kernel::apply(matrix);
373 
374  // Check the result
375  success = kernel::check(matrix, out);
376 }
377 
378 
379 // Some Stokhos unit tests use View types with a static rank
380 // In this case, dimensions should only be passed for the dynamic rank(s)
381 // These routines are specialized to select the appropriate View ctor
382 template < class ViewType, class OrdinalType, size_t I >
384  static ViewType create_view( const std::string & name, const OrdinalType & fem_length, const OrdinalType & stoch_length ) {
385  return ViewType(name, fem_length, stoch_length);
386  }
387 };
388 
389 template <class ViewType, class OrdinalType>
390 struct RankTypeSelector <ViewType,OrdinalType,1> {
391  static ViewType create_view( const std::string & name, const OrdinalType & fem_length, const OrdinalType & stoch_length ) {
392  (void) stoch_length; // unused if dyn_rank == 1; cast to void to silence compiler warnings
393  return ViewType(name, fem_length);
394  }
395 };
396 
397 template <class ViewType, class OrdinalType>
398 struct RankTypeSelector <ViewType,OrdinalType,0> {
399  static ViewType create_view( const std::string & name, const OrdinalType & fem_length, const OrdinalType & stoch_length ) {
400  (void) stoch_length; // unused if dyn_rank == 1; cast to void to silence compiler warnings
401  (void) fem_length; // unused if dyn_rank == 1; cast to void to silence compiler warnings
402  return ViewType(name);
403  }
404 };
405 
406 
407 template <typename VectorType, typename Multiply>
409  const typename VectorType::ordinal_type stoch_length,
410  KokkosSparse::DeviceConfig dev_config,
411  Multiply multiply_op,
413 {
414  typedef typename VectorType::ordinal_type ordinal_type;
415  typedef typename VectorType::value_type scalar_type;
416  typedef typename VectorType::storage_type storage_type;
418  typedef Kokkos::Device<execution_space, typename execution_space::memory_space> device_type;
419  typedef Kokkos::LayoutRight Layout;
420  typedef Kokkos::View< VectorType*, Layout, execution_space > block_vector_type;
421  typedef KokkosSparse::CrsMatrix< VectorType, ordinal_type, device_type > block_matrix_type;
422  typedef typename block_matrix_type::StaticCrsGraphType matrix_graph_type;
423  typedef typename block_matrix_type::values_type matrix_values_type;
424 
425  // Check ensemble_length == storage_type::static_size for static storage
427  storage_type::is_static && storage_type::static_size != stoch_length,
428  std::logic_error,
429  "Static storage size must equal ensemble size");
430 
431  // Generate FEM graph:
432  ordinal_type fem_length = nGrid * nGrid * nGrid;
433  std::vector< std::vector<ordinal_type> > fem_graph;
434  ordinal_type fem_graph_length = generate_fem_graph( nGrid, fem_graph );
435 
436  //------------------------------
437  // Generate input multivector:
438 
439  // FIXME: Experimental view needs to be fixed so that construct is called
440  // when not initializing
441  // block_vector_type x =
442  // block_vector_type(Kokkos::ViewAllocateWithoutInitializing("x"), fem_length, stoch_length);
443  // block_vector_type y =
444  // block_vector_type(Kokkos::ViewAllocateWithoutInitializing("y"), fem_length, stoch_length);
445 
446  block_vector_type x =
447  block_vector_type("x", fem_length, stoch_length);
448  block_vector_type y =
449  block_vector_type("y", fem_length, stoch_length);
450 
451  typename block_vector_type::HostMirror hx = Kokkos::create_mirror_view( x );
452  typename block_vector_type::HostMirror hy = Kokkos::create_mirror_view( y );
453 
454  // View the block vector as an array of the embedded intrinsic type.
455  typename block_vector_type::HostMirror::array_type hax = hx ;
456  typename block_vector_type::HostMirror::array_type hay = hy ;
457 
458  for (ordinal_type iRowFEM=0; iRowFEM<fem_length; ++iRowFEM) {
459  for (ordinal_type iRowStoch=0; iRowStoch<stoch_length; ++iRowStoch) {
460  hax(iRowFEM,iRowStoch) =
461  generate_vector_coefficient<scalar_type>(
462  fem_length, stoch_length, iRowFEM, iRowStoch );
463  hay(iRowFEM,iRowStoch) = 0.0;
464  }
465  }
466 
467  Kokkos::deep_copy( x, hx );
468  Kokkos::deep_copy( y, hy );
469 
470  //------------------------------
471  // Generate block matrix
472 
473  matrix_graph_type matrix_graph =
474  Kokkos::create_staticcrsgraph<matrix_graph_type>(
475  std::string("test crs graph"), fem_graph);
476  // FIXME:
477  // matrix_values_type matrix_values =
478  // matrix_values_type(
479  // Kokkos::ViewAllocateWithoutInitializing("matrix"), fem_graph_length, stoch_length);
480  matrix_values_type matrix_values =
481  matrix_values_type("matrix", fem_graph_length, stoch_length);
482  block_matrix_type matrix(
483  "block_matrix", fem_length, matrix_values, matrix_graph);
484  matrix.dev_config = dev_config;
485 
486  typename matrix_values_type::HostMirror hM =
487  Kokkos::create_mirror_view( matrix.values );
488 
489  typename matrix_values_type::HostMirror::array_type haM = hM ;
490 
491  for (ordinal_type iRowFEM=0, iEntryFEM=0; iRowFEM<fem_length; ++iRowFEM) {
492  const ordinal_type row_size = fem_graph[iRowFEM].size();
493  for (ordinal_type iRowEntryFEM=0; iRowEntryFEM<row_size;
494  ++iRowEntryFEM, ++iEntryFEM) {
495  const ordinal_type iColFEM = fem_graph[iRowFEM][iRowEntryFEM];
496 
497  for (ordinal_type k=0; k<stoch_length; ++k) {
498  haM(iEntryFEM,k) =
499  generate_matrix_coefficient<scalar_type>(
500  fem_length, stoch_length, iRowFEM, iColFEM, k);
501  }
502  }
503  }
504 
505  Kokkos::deep_copy( matrix.values, hM );
506 
507  //------------------------------
508  // multiply
509 
510  multiply_op( matrix, x, y );
511 
512  //------------------------------
513  // generate correct answer
514 
515  typedef typename block_vector_type::array_type array_type;
516 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
517  array_type ay_expected =
518  array_type("ay_expected", fem_length, stoch_length);
519 #else
520  array_type ay_expected =
522 #endif
523  typename array_type::HostMirror hay_expected =
524  Kokkos::create_mirror_view(ay_expected);
525  for (ordinal_type iRowFEM=0, iEntryFEM=0; iRowFEM<fem_length; ++iRowFEM) {
526  const ordinal_type row_size = fem_graph[iRowFEM].size();
527  for (ordinal_type iRowEntryFEM=0; iRowEntryFEM<row_size;
528  ++iRowEntryFEM, ++iEntryFEM) {
529  const ordinal_type iColFEM = fem_graph[iRowFEM][iRowEntryFEM];
530  for (ordinal_type k=0; k<stoch_length; ++k) {
531  hay_expected(iRowFEM, k) +=
532  generate_matrix_coefficient<scalar_type>(
533  fem_length, stoch_length, iRowFEM, iColFEM, k) *
534  generate_vector_coefficient<scalar_type>(
535  fem_length, stoch_length, iColFEM, k );
536  }
537  }
538  }
539  Kokkos::deep_copy( ay_expected, hay_expected );
540 
541  //------------------------------
542  // check
543 
544  typename block_vector_type::array_type ay = y;
545  scalar_type rel_tol = ScalarTol<scalar_type>::tol();
546  scalar_type abs_tol = ScalarTol<scalar_type>::tol();
547  bool success = compare_rank_2_views(ay, ay_expected, rel_tol, abs_tol, out);
548 
549  return success;
550 }
551 
553  template <typename Matrix, typename InputVector, typename OutputVector>
554  void operator() (const Matrix& A,
555  const InputVector& x,
556  OutputVector& y) const {
557  KokkosSparse::spmv("N", typename Matrix::value_type(1.0) , A, x, typename Matrix::value_type(0.0), y);
558  }
559 };
560 
561 template <typename Tag>
563  Tag tag;
564  Stokhos_MV_Multiply_Op(const Tag& tg = Tag()) : tag(tg) {}
565 
566  template <typename Matrix, typename InputVector, typename OutputVector>
567  void operator() (const Matrix& A,
568  const InputVector& x,
569  OutputVector& y) const {
570  Stokhos::multiply(A, x, y, tag);
571  }
572 };
573 
576 
577 #define CRSMATRIX_MP_VECTOR_TESTS_MATRIXSCALAR( SCALAR ) \
578  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \
579  Kokkos_CrsMatrix_MP, ReplaceValues, SCALAR ) \
580  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \
581  Kokkos_CrsMatrix_MP, SumIntoValues, SCALAR ) \
582  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \
583  Kokkos_CrsMatrix_MP, SumIntoValuesAtomic, SCALAR )
584 
585 #define CRSMATRIX_MP_VECTOR_TESTS_STORAGE( STORAGE ) \
586  typedef Sacado::MP::Vector<STORAGE> MP_Vector_ ## STORAGE; \
587  CRSMATRIX_MP_VECTOR_TESTS_MATRIXSCALAR( MP_Vector_ ## STORAGE )
588 
589 #define CRSMATRIX_MP_VECTOR_TESTS_ORDINAL_SCALAR_DEVICE( ORDINAL, SCALAR, DEVICE ) \
590  typedef Stokhos::StaticFixedStorage<ORDINAL,SCALAR,VectorSize,DEVICE> SFS; \
591  typedef Stokhos::DynamicStorage<ORDINAL,SCALAR,DEVICE> DS; \
592  CRSMATRIX_MP_VECTOR_TESTS_STORAGE( SFS ) \
593  CRSMATRIX_MP_VECTOR_TESTS_STORAGE( DS )
594 
595 #define CRSMATRIX_MP_VECTOR_TESTS_DEVICE( DEVICE ) \
596  CRSMATRIX_MP_VECTOR_TESTS_ORDINAL_SCALAR_DEVICE( int, double, DEVICE )
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
Stokhos::StandardStorage< int, double > storage_type
bool compareVecs(const VectorType1 &a1, const std::string &a1_name, const VectorType2 &a2, const std::string &a2_name, const ValueType &rel_tol, const ValueType &abs_tol, Teuchos::FancyOStream &out)
ordinal generate_fem_graph(ordinal N, std::vector< std::vector< ordinal > > &graph)
Definition: TestEpetra.cpp:45
static bool check(const MatrixType matrix, Teuchos::FancyOStream &out)
Stokhos_MV_Multiply_Op< Stokhos::DefaultMultiply > DefaultMultiply
Kokkos::DefaultExecutionSpace execution_space
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
MatrixType buildDiagonalMatrix(typename MatrixType::ordinal_type nrow, typename MatrixType::ordinal_type mp_vector_size)
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)
IntType map_fem_graph_coord(const IntType &N, const IntType &i, const IntType &j, const IntType &k)
Definition: TestEpetra.cpp:35
void multiply(const CrsMatrix< MatrixValue, Device, Layout > &A, const InputMultiVectorType &x, OutputMultiVectorType &y, const std::vector< OrdinalType > &col_indices, SingleColumnMultivectorMultiply)
static bool check(const MatrixType matrix, Teuchos::FancyOStream &out)
Kokkos_MV_Multiply_Op KokkosMultiply
void operator()(const Matrix &A, const InputVector &x, OutputVector &y) const
static void apply(const MatrixType matrix)
static bool check(const MatrixType matrix, Teuchos::FancyOStream &out)
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
KOKKOS_INLINE_FUNCTION PCE< Storage > abs(const PCE< Storage > &a)
static ViewType create_view(const std::string &name, const OrdinalType &fem_length, const OrdinalType &stoch_length)
static ViewType create_view(const std::string &name, const OrdinalType &fem_length, const OrdinalType &stoch_length)
static ViewType create_view(const std::string &name, const OrdinalType &fem_length, const OrdinalType &stoch_length)
scalar generate_matrix_coefficient(const ordinal nFEM, const ordinal nStoch, const ordinal iRowFEM, const ordinal iColFEM, const ordinal iStoch)
expr val()
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(Kokkos_CrsMatrix_MP, ReplaceValues, MatrixScalar)
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< InputType, InputP... > >::value &&Kokkos::is_view_uq_pce< Kokkos::View< OutputType, OutputP... > >::value >::type spmv(KokkosKernels::Experimental::Controls, const char mode[], const AlphaType &a, const MatrixType &A, const Kokkos::View< InputType, InputP... > &x, const BetaType &b, const Kokkos::View< OutputType, OutputP... > &y, const RANK_ONE)
void operator()(const Matrix &A, const InputVector &x, OutputVector &y) const
bool compare_rank_2_views(const array_type &y, const array_type &y_exp, const scalar_type rel_tol, const scalar_type abs_tol, Teuchos::FancyOStream &out)
static void apply(const MatrixType matrix)
bool test_embedded_vector(const typename VectorType::ordinal_type nGrid, const typename VectorType::ordinal_type stoch_length, KokkosSparse::DeviceConfig dev_config, Multiply multiply_op, Teuchos::FancyOStream &out)
Stokhos::CrsMatrix< ValueType, Device, Layout >::HostMirror create_mirror_view(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)