Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tpetra_Details_fill.hpp
Go to the documentation of this file.
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_DETAILS_FILL_HPP
11 #define TPETRA_DETAILS_FILL_HPP
12 
21 
22 #include "Tpetra_Details_Blas.hpp"
23 #include <type_traits>
24 
25 namespace Tpetra {
26 namespace Details {
27 namespace Blas {
28 
36 template<class ViewType,
37  class ValueType,
38  class IndexType,
39  class ExecutionSpace>
40 void
41 fill (const ExecutionSpace& execSpace,
42  const ViewType& X,
43  const ValueType& alpha,
44  const IndexType numRows,
45  const IndexType numCols)
46 {
47  static_assert (std::is_integral<IndexType>::value,
48  "IndexType must be a built-in integer type.");
49  auto X_j = Kokkos::subview (X, Kokkos::make_pair(IndexType(0), numRows), Kokkos::make_pair(IndexType(0), numCols));
50  Kokkos::deep_copy(execSpace, X_j, alpha);
51 }
52 
53 template<class ViewType,
54  class ValueType,
55  class IndexType,
56  class ExecutionSpace>
57 void
58 fill (const ExecutionSpace& execSpace,
59  const ViewType& X,
60  const ValueType& alpha,
61  const IndexType numRows,
62  const IndexType numCols,
63  const size_t whichVectors[])
64 {
65  static_assert (ViewType::rank == 2, "ViewType must be a rank-2 "
66  "Kokkos::View in order to call the \"whichVectors\" "
67  "specialization of fill.");
68  static_assert (std::is_integral<IndexType>::value,
69  "IndexType must be a built-in integer type.");
70  for (IndexType k = 0; k < numCols; ++k) {
71  const IndexType j = whichVectors[k];
72  auto X_j = Kokkos::subview (X, Kokkos::make_pair(IndexType(0), numRows), j);
73  Kokkos::deep_copy(execSpace, X_j, alpha);
74  }
75 }
76 
77 } // namespace Blas
78 } // namespace Details
79 } // namespace Tpetra
80 
81 #endif // TPETRA_DETAILS_FILL_HPP
Type traits for Tpetra&#39;s BLAS wrappers; an implementation detail of Tpetra::MultiVector.
void deep_copy(MultiVector< DS, DL, DG, DN > &dst, const MultiVector< SS, SL, SG, SN > &src)
Copy the contents of the MultiVector src into dst.