Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tpetra_Details_fill_MP_Vector.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_MP_VECTOR_HPP
11 #define TPETRA_DETAILS_FILL_MP_VECTOR_HPP
12 
13 #include "Tpetra_Details_fill.hpp"
15 
16 namespace Tpetra {
17 namespace Details {
18 namespace Blas {
19 
20 template<class DT, class ... DP,
21  class ValueType,
22  class IndexType,
23  class ExecutionSpace>
24 typename std::enable_if<
25  Kokkos::is_view_mp_vector< Kokkos::View<DT,DP...> >::value >::type
26 fill (const ExecutionSpace& execSpace,
27  const Kokkos::View<DT,DP...>& X,
28  const ValueType& alpha,
29  const IndexType numRows,
30  const IndexType numCols)
31 {
32  static_assert (std::is_integral<IndexType>::value,
33  "IndexType must be a built-in integer type.");
34  Kokkos::deep_copy(execSpace, X, alpha);
35 }
36 
37 template<class DT, class ... DP,
38  class ValueType,
39  class IndexType,
40  class ExecutionSpace>
41 typename std::enable_if<
42  Kokkos::is_view_mp_vector< Kokkos::View<DT,DP...> >::value >::type
43 fill (const ExecutionSpace& execSpace,
44  const Kokkos::View<DT,DP...>& X,
45  const ValueType& alpha,
46  const IndexType numRows,
47  const IndexType numCols,
48  const size_t whichVectors[])
49 {
50  typedef Kokkos::View<DT,DP...> ViewType;
51  static_assert (ViewType::rank == 2, "ViewType must be a rank-2 "
52  "Kokkos::View in order to call the \"whichVectors\" "
53  "specialization of fill.");
54  static_assert (std::is_integral<IndexType>::value,
55  "IndexType must be a built-in integer type.");
56  for (IndexType k = 0; k < numCols; ++k) {
57  const IndexType j = whichVectors[k];
58  auto X_j = Kokkos::subview (X, Kokkos::ALL (), j);
59  Kokkos::deep_copy(execSpace, X_j, alpha);
60  }
61 }
62 
63 } // namespace Blas
64 } // namespace Details
65 } // namespace Tpetra
66 
67 #endif // TPETRA_DETAILS_FILL_MP_VECTOR_HPP
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< DT, DP...> >::value >::type fill(const ExecutionSpace &execSpace, const Kokkos::View< DT, DP...> &X, const ValueType &alpha, const IndexType numRows, const IndexType numCols)