Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
Stokhos_KokkosCrsMatrixMPVectorUnitTest.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Stokhos Package
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #include "Teuchos_UnitTestHelpers.hpp"
44 
48 
49 // For computing DeviceConfig
50 #include "Kokkos_Core.hpp"
51 
52 // Helper functions
53 template< typename IntType >
54 inline
55 IntType map_fem_graph_coord( const IntType& N,
56  const IntType& i,
57  const IntType& j,
58  const IntType& k )
59 {
60  return k + N * ( j + N * i );
61 }
62 
63 template < typename ordinal >
64 inline
65 ordinal generate_fem_graph( ordinal N,
66  std::vector< std::vector<ordinal> >& graph )
67 {
68  graph.resize( N * N * N, std::vector<ordinal>() );
69 
70  ordinal total = 0;
71 
72  for ( int i = 0; i < (int) N; ++i ) {
73  for ( int j = 0; j < (int) N; ++j ) {
74  for ( int k = 0; k < (int) N; ++k ) {
75 
76  const ordinal row = map_fem_graph_coord((int)N,i,j,k);
77 
78  graph[row].reserve(27);
79 
80  for ( int ii = -1; ii < 2; ++ii ) {
81  for ( int jj = -1; jj < 2; ++jj ) {
82  for ( int kk = -1; kk < 2; ++kk ) {
83  if ( 0 <= i + ii && i + ii < (int) N &&
84  0 <= j + jj && j + jj < (int) N &&
85  0 <= k + kk && k + kk < (int) N ) {
86  ordinal col = map_fem_graph_coord((int)N,i+ii,j+jj,k+kk);
87 
88  graph[row].push_back(col);
89  }
90  }}}
91  total += graph[row].size();
92  }}}
93 
94  return total;
95 }
96 
97 template <typename scalar, typename ordinal>
98 inline
99 scalar generate_matrix_coefficient( const ordinal nFEM,
100  const ordinal nStoch,
101  const ordinal iRowFEM,
102  const ordinal iColFEM,
103  const ordinal iStoch )
104 {
105  const scalar A_fem = ( 10.0 + scalar(iRowFEM) / scalar(nFEM) ) +
106  ( 5.0 + scalar(iColFEM) / scalar(nFEM) );
107 
108  const scalar A_stoch = ( 1.0 + scalar(iStoch) / scalar(nStoch) );
109 
110  return A_fem + A_stoch;
111  //return 1.0;
112 }
113 
114 template <typename scalar, typename ordinal>
115 inline
116 scalar generate_vector_coefficient( const ordinal nFEM,
117  const ordinal nStoch,
118  const ordinal iColFEM,
119  const ordinal iStoch )
120 {
121  const scalar X_fem = 100.0 + scalar(iColFEM) / scalar(nFEM);
122  const scalar X_stoch = 1.0 + scalar(iStoch) / scalar(nStoch);
123  return X_fem + X_stoch;
124  //return 1.0;
125 }
126 
127 // Reasonable tolerances for common precisions
128 template <typename Scalar> struct ScalarTol {};
129 template <> struct ScalarTol<float> { static float tol() { return 1e-4; } };
130 template <> struct ScalarTol<double> { static double tol() { return 1e-10; } };
131 
132 // Compare two rank-2 views for equality, to given precision
133 template <typename array_type, typename scalar_type>
134 bool compare_rank_2_views(const array_type& y,
135  const array_type& y_exp,
136  const scalar_type rel_tol,
137  const scalar_type abs_tol,
138  Teuchos::FancyOStream& out)
139 {
140  typedef typename array_type::size_type size_type;
141  typename array_type::HostMirror hy = Kokkos::create_mirror_view(y);
142  typename array_type::HostMirror hy_exp = Kokkos::create_mirror_view(y_exp);
143  Kokkos::deep_copy(hy, y);
144  Kokkos::deep_copy(hy_exp, y_exp);
145 
146  size_type num_rows = y.extent(0);
147  size_type num_cols = y.extent(1);
148  bool success = true;
149  for (size_type i=0; i<num_rows; ++i) {
150  for (size_type j=0; j<num_cols; ++j) {
151  scalar_type diff = std::abs( hy(i,j) - hy_exp(i,j) );
152  scalar_type tol = rel_tol*std::abs(hy_exp(i,j)) + abs_tol;
153  bool s = diff < tol;
154  out << "y_expected(" << i << "," << j << ") - "
155  << "y(" << i << "," << j << ") = " << hy_exp(i,j)
156  << " - " << hy(i,j) << " == "
157  << diff << " < " << tol << " : ";
158  if (s)
159  out << "passed";
160  else
161  out << "failed";
162  out << std::endl;
163  success = success && s;
164  }
165  }
166 
167  return success;
168 }
169 
170 // Helper function to build a diagonal matrix
171 template <typename MatrixType>
172 MatrixType
174  typename MatrixType::ordinal_type mp_vector_size) {
175  typedef typename MatrixType::ordinal_type ordinal_type;
176  typedef typename MatrixType::StaticCrsGraphType matrix_graph_type;
177  typedef typename MatrixType::values_type matrix_values_type;
178 
179  std::vector< std::vector<ordinal_type> > graph(nrow);
180  for (ordinal_type i=0; i<nrow; ++i)
181  graph[i] = std::vector<ordinal_type>(1, i);
182  ordinal_type graph_length = nrow;
183 
184  matrix_graph_type matrix_graph =
185  Kokkos::create_staticcrsgraph<matrix_graph_type>("graph", graph);
186  matrix_values_type matrix_values =
187  matrix_values_type("values", graph_length, mp_vector_size);
188 
189  MatrixType matrix("matrix", nrow, matrix_values, matrix_graph);
190  return matrix;
191 }
192 
193 //
194 // Tests
195 //
196 
197 // Kernel to set diagonal of a matrix to prescribed values
198 template <typename MatrixType>
201  typedef typename MatrixType::size_type size_type;
204 
205  const MatrixType m_matrix;
206  ReplaceDiagonalValuesKernel(const MatrixType matrix) : m_matrix(matrix) {};
207 
208  // Replace diagonal entry for row 'i' with a value
209  KOKKOS_INLINE_FUNCTION
210  void operator() (const size_type i) const {
211  const ordinal_type row = i;
212  const ordinal_type col = i;
213  value_type val = value_type(row);
214  m_matrix.replaceValues(row, &col, 1, &val, false, true);
215  }
216 
217  // Kernel launch
218  static void apply(const MatrixType matrix) {
219  const size_type nrow = matrix.numRows();
220  Kokkos::parallel_for( nrow, ReplaceDiagonalValuesKernel(matrix) );
221  }
222 
223  // Check the result is as expected
224  static bool check(const MatrixType matrix,
225  Teuchos::FancyOStream& out) {
226  typedef typename MatrixType::values_type matrix_values_type;
227  typename matrix_values_type::HostMirror host_matrix_values =
228  Kokkos::create_mirror_view(matrix.values);
229  Kokkos::deep_copy(host_matrix_values, matrix.values);
230  const ordinal_type nrow = matrix.numRows();
231  const ordinal_type vec_size = Kokkos::dimension_scalar(host_matrix_values);
232  bool success = true;
233  for (ordinal_type row=0; row<nrow; ++row) {
234  bool s = compareVecs(host_matrix_values(row),
235  "matrix_values(row)",
236  value_type(vec_size, row),
237  "value_type(row)",
238  0.0, 0.0, out);
239  success = success && s;
240  }
241  return success;
242  }
243 };
244 
245 // Kernel to add values to the diagonal of a matrix
246 template <typename MatrixType>
249  typedef typename MatrixType::size_type size_type;
252 
253  const MatrixType m_matrix;
254  AddDiagonalValuesKernel(const MatrixType matrix) : m_matrix(matrix) {};
255 
256  // Replace diagonal entry for row 'i' with a value
257  KOKKOS_INLINE_FUNCTION
258  void operator() (const size_type i) const {
259  const ordinal_type row = i;
260  const ordinal_type col = i;
261  value_type val = value_type(row);
262  m_matrix.sumIntoValues(row, &col, 1, &val, false, true);
263  }
264 
265  // Kernel launch
266  static void apply(const MatrixType matrix) {
267  const size_type nrow = matrix.numRows();
268  Kokkos::parallel_for( nrow, AddDiagonalValuesKernel(matrix) );
269  }
270 
271  // Check the result is as expected
272  static bool check(const MatrixType matrix,
273  Teuchos::FancyOStream& out) {
274  typedef typename MatrixType::values_type matrix_values_type;
275  typename matrix_values_type::HostMirror host_matrix_values =
276  Kokkos::create_mirror_view(matrix.values);
277  Kokkos::deep_copy(host_matrix_values, matrix.values);
278  const ordinal_type nrow = matrix.numRows();
279  const ordinal_type vec_size = Kokkos::dimension_scalar(host_matrix_values);
280  bool success = true;
281  for (ordinal_type row=0; row<nrow; ++row) {
282  bool s = compareVecs(host_matrix_values(row),
283  "matrix_values(row)",
284  value_type(vec_size, row),
285  "value_type(row)",
286  0.0, 0.0, out);
287  success = success && s;
288  }
289  return success;
290  }
291 };
292 
293 // Kernel to add values to the diagonal of a matrix where each thread
294 // adds to the same row (checks atomic really works)
295 template <typename MatrixType>
298  typedef typename MatrixType::size_type size_type;
301 
302  const MatrixType m_matrix;
303  AddDiagonalValuesAtomicKernel(const MatrixType matrix) : m_matrix(matrix) {};
304 
305  // Replace diagonal entry for row 'i' with a value
306  KOKKOS_INLINE_FUNCTION
307  void operator() (const size_type i) const {
308  const ordinal_type row = 0;
309  const ordinal_type col = 0;
311  m_matrix.sumIntoValues(row, &col, 1, &val, false, true);
312  }
313 
314  // Kernel launch
315  static void apply(const MatrixType matrix) {
316  const size_type nrow = matrix.numRows();
317  Kokkos::parallel_for( nrow, AddDiagonalValuesAtomicKernel(matrix) );
318  }
319 
320  // Check the result is as expected
321  static bool check(const MatrixType matrix,
322  Teuchos::FancyOStream& out) {
323  typedef typename MatrixType::values_type matrix_values_type;
324  typename matrix_values_type::HostMirror host_matrix_values =
325  Kokkos::create_mirror_view(matrix.values);
326  Kokkos::deep_copy(host_matrix_values, matrix.values);
327  const ordinal_type nrow = matrix.numRows();
328  const ordinal_type vec_size = Kokkos::dimension_scalar(host_matrix_values);
329  bool success = true;
330  for (ordinal_type row=0; row<nrow; ++row) {
331  value_type val;
332  if (row == 0)
333  val = value_type( vec_size, nrow*(nrow-1)/2 );
334  else
335  val = value_type( vec_size, 0.0 );
336  bool s = compareVecs(host_matrix_values(row),
337  "matrix_values(row)",
338  val,
339  "val",
340  0.0, 0.0, out);
341  success = success && s;
342  }
343  return success;
344  }
345 };
346 
347 const unsigned VectorSize = 16; // Currently must be a multiple of 8 based on
348  // alignment assumptions for SFS
349 
351  Kokkos_CrsMatrix_MP, ReplaceValues, MatrixScalar )
352 {
353  typedef typename MatrixScalar::ordinal_type Ordinal;
354  typedef typename MatrixScalar::execution_space Device;
355  typedef KokkosSparse::CrsMatrix<MatrixScalar,Ordinal,Device> Matrix;
356 
357  // Build diagonal matrix
358  Ordinal nrow = 10;
359  Matrix matrix = buildDiagonalMatrix<Matrix>(nrow, VectorSize);
360 
361  // Launch our kernel
363  kernel::apply(matrix);
364 
365  // Check the result
366  success = kernel::check(matrix, out);
367 }
368 
370  Kokkos_CrsMatrix_MP, SumIntoValues, MatrixScalar )
371 {
372  typedef typename MatrixScalar::ordinal_type Ordinal;
373  typedef typename MatrixScalar::execution_space Device;
374  typedef KokkosSparse::CrsMatrix<MatrixScalar,Ordinal,Device> Matrix;
375 
376  // Build diagonal matrix
377  Ordinal nrow = 10;
378  Matrix matrix = buildDiagonalMatrix<Matrix>(nrow, VectorSize);
379 
380  // Launch our kernel
381  typedef AddDiagonalValuesKernel<Matrix> kernel;
382  kernel::apply(matrix);
383 
384  // Check the result
385  success = kernel::check(matrix, out);
386 }
387 
389  Kokkos_CrsMatrix_MP, SumIntoValuesAtomic, MatrixScalar )
390 {
391  typedef typename MatrixScalar::ordinal_type Ordinal;
392  typedef typename MatrixScalar::execution_space Device;
393  typedef KokkosSparse::CrsMatrix<MatrixScalar,Ordinal,Device> Matrix;
394 
395  // Build diagonal matrix
396  Ordinal nrow = 10;
397  Matrix matrix = buildDiagonalMatrix<Matrix>(nrow, VectorSize);
398 
399  // Launch our kernel
401  kernel::apply(matrix);
402 
403  // Check the result
404  success = kernel::check(matrix, out);
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,
412  Teuchos::FancyOStream& out)
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::LayoutRight Layout;
419  typedef Kokkos::View< VectorType*, Layout, execution_space > block_vector_type;
420  typedef KokkosSparse::CrsMatrix< VectorType, ordinal_type, execution_space > block_matrix_type;
421  typedef typename block_matrix_type::StaticCrsGraphType matrix_graph_type;
422  typedef typename block_matrix_type::values_type matrix_values_type;
423 
424  // Check ensemble_length == storage_type::static_size for static storage
425  TEUCHOS_TEST_FOR_EXCEPTION(
426  storage_type::is_static && storage_type::static_size != stoch_length,
427  std::logic_error,
428  "Static storage size must equal ensemble size");
429 
430  // Generate FEM graph:
431  ordinal_type fem_length = nGrid * nGrid * nGrid;
432  std::vector< std::vector<ordinal_type> > fem_graph;
433  ordinal_type fem_graph_length = generate_fem_graph( nGrid, fem_graph );
434 
435  //------------------------------
436  // Generate input multivector:
437 
438  // FIXME: Experimental view needs to be fixed so that construct is called
439  // when not initializing
440  // block_vector_type x =
441  // block_vector_type(Kokkos::ViewAllocateWithoutInitializing("x"), fem_length, stoch_length);
442  // block_vector_type y =
443  // block_vector_type(Kokkos::ViewAllocateWithoutInitializing("y"), fem_length, stoch_length);
444 
445  block_vector_type x =
446  block_vector_type("x", fem_length, stoch_length);
447  block_vector_type y =
448  block_vector_type("y", fem_length, stoch_length);
449 
450  typename block_vector_type::HostMirror hx = Kokkos::create_mirror_view( x );
451  typename block_vector_type::HostMirror hy = Kokkos::create_mirror_view( y );
452 
453  // View the block vector as an array of the embedded intrinsic type.
454  typename block_vector_type::HostMirror::array_type hax = hx ;
455  typename block_vector_type::HostMirror::array_type hay = hy ;
456 
457  for (ordinal_type iRowFEM=0; iRowFEM<fem_length; ++iRowFEM) {
458  for (ordinal_type iRowStoch=0; iRowStoch<stoch_length; ++iRowStoch) {
459  hax(iRowFEM,iRowStoch) =
460  generate_vector_coefficient<scalar_type>(
461  fem_length, stoch_length, iRowFEM, iRowStoch );
462  hay(iRowFEM,iRowStoch) = 0.0;
463  }
464  }
465 
466  Kokkos::deep_copy( x, hx );
467  Kokkos::deep_copy( y, hy );
468 
469  //------------------------------
470  // Generate block matrix
471 
472  matrix_graph_type matrix_graph =
473  Kokkos::create_staticcrsgraph<matrix_graph_type>(
474  std::string("test crs graph"), fem_graph);
475  // FIXME:
476  // matrix_values_type matrix_values =
477  // matrix_values_type(
478  // Kokkos::ViewAllocateWithoutInitializing("matrix"), fem_graph_length, stoch_length);
479  matrix_values_type matrix_values =
480  matrix_values_type("matrix", fem_graph_length, stoch_length);
481  block_matrix_type matrix(
482  "block_matrix", fem_length, matrix_values, matrix_graph);
483  matrix.dev_config = dev_config;
484 
485  typename matrix_values_type::HostMirror hM =
486  Kokkos::create_mirror_view( matrix.values );
487 
488  typename matrix_values_type::HostMirror::array_type haM = hM ;
489 
490  for (ordinal_type iRowFEM=0, iEntryFEM=0; iRowFEM<fem_length; ++iRowFEM) {
491  const ordinal_type row_size = fem_graph[iRowFEM].size();
492  for (ordinal_type iRowEntryFEM=0; iRowEntryFEM<row_size;
493  ++iRowEntryFEM, ++iEntryFEM) {
494  const ordinal_type iColFEM = fem_graph[iRowFEM][iRowEntryFEM];
495 
496  for (ordinal_type k=0; k<stoch_length; ++k) {
497  haM(iEntryFEM,k) =
498  generate_matrix_coefficient<scalar_type>(
499  fem_length, stoch_length, iRowFEM, iColFEM, k);
500  }
501  }
502  }
503 
504  Kokkos::deep_copy( matrix.values, hM );
505 
506  //------------------------------
507  // multiply
508 
509  multiply_op( matrix, x, y );
510 
511  //------------------------------
512  // generate correct answer
513 
514  typedef typename block_vector_type::array_type array_type;
515  array_type ay_expected =
516  array_type("ay_expected", fem_length, stoch_length);
517  typename array_type::HostMirror hay_expected =
518  Kokkos::create_mirror_view(ay_expected);
519  for (ordinal_type iRowFEM=0, iEntryFEM=0; iRowFEM<fem_length; ++iRowFEM) {
520  const ordinal_type row_size = fem_graph[iRowFEM].size();
521  for (ordinal_type iRowEntryFEM=0; iRowEntryFEM<row_size;
522  ++iRowEntryFEM, ++iEntryFEM) {
523  const ordinal_type iColFEM = fem_graph[iRowFEM][iRowEntryFEM];
524  for (ordinal_type k=0; k<stoch_length; ++k) {
525  hay_expected(iRowFEM, k) +=
526  generate_matrix_coefficient<scalar_type>(
527  fem_length, stoch_length, iRowFEM, iColFEM, k) *
528  generate_vector_coefficient<scalar_type>(
529  fem_length, stoch_length, iColFEM, k );
530  }
531  }
532  }
533  Kokkos::deep_copy( ay_expected, hay_expected );
534 
535  //------------------------------
536  // check
537 
538  typename block_vector_type::array_type ay = y;
541  bool success = compare_rank_2_views(ay, ay_expected, rel_tol, abs_tol, out);
542 
543  return success;
544 }
545 
547  template <typename Matrix, typename InputVector, typename OutputVector>
548  void operator() (const Matrix& A,
549  const InputVector& x,
550  OutputVector& y) const {
551  KokkosSparse::spmv("N", typename Matrix::value_type(1.0) , A, x, typename Matrix::value_type(0.0), y);
552  }
553 };
554 
555 template <typename Tag>
557  Tag tag;
558  Stokhos_MV_Multiply_Op(const Tag& tg = Tag()) : tag(tg) {}
559 
560  template <typename Matrix, typename InputVector, typename OutputVector>
561  void operator() (const Matrix& A,
562  const InputVector& x,
563  OutputVector& y) const {
564  Stokhos::multiply(A, x, y, tag);
565  }
566 };
567 
570 
571 #define CRSMATRIX_MP_VECTOR_TESTS_MATRIXSCALAR( SCALAR ) \
572  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \
573  Kokkos_CrsMatrix_MP, ReplaceValues, SCALAR ) \
574  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \
575  Kokkos_CrsMatrix_MP, SumIntoValues, SCALAR ) \
576  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \
577  Kokkos_CrsMatrix_MP, SumIntoValuesAtomic, SCALAR )
578 
579 #define CRSMATRIX_MP_VECTOR_TESTS_STORAGE( STORAGE ) \
580  typedef Sacado::MP::Vector<STORAGE> MP_Vector_ ## STORAGE; \
581  CRSMATRIX_MP_VECTOR_TESTS_MATRIXSCALAR( MP_Vector_ ## STORAGE )
582 
583 #define CRSMATRIX_MP_VECTOR_TESTS_ORDINAL_SCALAR_DEVICE( ORDINAL, SCALAR, DEVICE ) \
584  typedef Stokhos::StaticFixedStorage<ORDINAL,SCALAR,VectorSize,DEVICE> SFS; \
585  typedef Stokhos::DynamicStorage<ORDINAL,SCALAR,DEVICE> DS; \
586  CRSMATRIX_MP_VECTOR_TESTS_STORAGE( SFS ) \
587  CRSMATRIX_MP_VECTOR_TESTS_STORAGE( DS )
588 
589 #define CRSMATRIX_MP_VECTOR_TESTS_DEVICE( DEVICE ) \
590  CRSMATRIX_MP_VECTOR_TESTS_ORDINAL_SCALAR_DEVICE( int, double, DEVICE )
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)
void operator()(const Matrix &A, const InputVector &x, OutputVector &y) const
static bool check(const MatrixType matrix, Teuchos::FancyOStream &out)
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
Stokhos_MV_Multiply_Op< Stokhos::DefaultMultiply > DefaultMultiply
Kokkos::DefaultExecutionSpace execution_space
MatrixType buildDiagonalMatrix(typename MatrixType::ordinal_type nrow, typename MatrixType::ordinal_type mp_vector_size)
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
void multiply(const CrsMatrix< MatrixValue, Device, Layout > &A, const InputMultiVectorType &x, OutputMultiVectorType &y, const std::vector< OrdinalType > &col_indices, SingleColumnMultivectorMultiply)
scalar generate_vector_coefficient(const ordinal nFEM, const ordinal nStoch, const ordinal iColFEM, const ordinal iStoch)
static bool check(const MatrixType matrix, Teuchos::FancyOStream &out)
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
Definition: csr_vector.h:260
Kokkos_MV_Multiply_Op KokkosMultiply
static void apply(const MatrixType matrix)
static bool check(const MatrixType matrix, Teuchos::FancyOStream &out)
IntType map_fem_graph_coord(const IntType &N, const IntType &i, const IntType &j, const IntType &k)
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< View< T, P... > >::value, unsigned >::type dimension_scalar(const View< T, P... > &view)
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)
ordinal generate_fem_graph(ordinal N, std::vector< std::vector< ordinal > > &graph)
expr val()
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(Kokkos_CrsMatrix_MP, ReplaceValues, MatrixScalar)
scalar generate_matrix_coefficient(const ordinal nFEM, const ordinal nStoch, const ordinal iRowFEM, const ordinal iColFEM, const ordinal iStoch)
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)
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType ValueType * y
Definition: csr_vector.h:267
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(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)
Stokhos::CrsMatrix< ValueType, Device, Layout >::HostMirror create_mirror_view(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)
void operator()(const Matrix &A, const InputVector &x, OutputVector &y) const