Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tpetra_Details_MatrixApplyHelper.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Tpetra: Templated Linear Algebra Services Package
4 //
5 // Copyright 2008 NTESS and the Tpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TPETRA_MATRIX_APPLY_HELPER_HPP
11 #define TPETRA_MATRIX_APPLY_HELPER_HPP
12 
13 #include "Kokkos_Core.hpp"
14 #include "KokkosSparse_spmv_handle.hpp"
15 #include "Tpetra_Details_IntRowPtrHelper.hpp"
16 
17 namespace Tpetra {
18 namespace Details {
19 
27 template<typename LocalMatrix, typename IntLocalMatrix, typename MultiVectorLocalView>
28 struct MatrixApplyHelper : public IntRowPtrHelper<LocalMatrix, IntLocalMatrix>
29 {
30  // using Rowptrs = typename LocalMatrix::row_map_type;
31  // using IntRowptrs = typename IntLocalMatrix::row_map_type;
32  using XVectorType = typename MultiVectorLocalView::const_type;
33  using YVectorType = MultiVectorLocalView;
34  using SPMVHandle = KokkosSparse::SPMVHandle<typename LocalMatrix::device_type, LocalMatrix, XVectorType, YVectorType>;
35  using SPMVHandleInt = KokkosSparse::SPMVHandle<typename LocalMatrix::device_type, IntLocalMatrix, XVectorType, YVectorType>;
36 
37  MatrixApplyHelper(size_t nnz, const typename LocalMatrix::row_map_type& rowptrs, KokkosSparse::SPMVAlgorithm algo = KokkosSparse::SPMV_DEFAULT)
38  : IntRowPtrHelper<LocalMatrix, IntLocalMatrix>(nnz, rowptrs), handle_int(algo) {}
39 
40 
41  // SPMVHandles are lazily initialized by actual spmv calls.
42  // We declare both here because we don't know until runtime (based on nnz) which should be used.
43  SPMVHandle handle;
44  SPMVHandleInt handle_int;
45 };
46 }
47 }
48 
49 #endif // TPETRA_MATRIX_APPLY_HELPER_HPP
50