Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_KokkosMultiVecAdapter_def.hpp
Go to the documentation of this file.
1// @HEADER
2//
3// ***********************************************************************
4//
5// Amesos2: Templated Direct Sparse Solver Package
6// Copyright 2011 Sandia Corporation
7//
8// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9// the U.S. Government retains certain rights in this software.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39//
40// ***********************************************************************
41//
42// @HEADER
43
53#ifndef AMESOS2_KOKKOS_MULTIVEC_ADAPTER_DEF_HPP
54#define AMESOS2_KOKKOS_MULTIVEC_ADAPTER_DEF_HPP
55
56#include <type_traits>
59
60
61namespace Amesos2 {
62
63 template <typename Scalar, typename ExecutionSpace >
64 MultiVecAdapter<
65 Kokkos::View<Scalar**, Kokkos::LayoutLeft, ExecutionSpace> >::MultiVecAdapter( const Teuchos::RCP<multivec_t>& m )
66 : mv_(m)
67 {}
68
69 template <typename Scalar, typename ExecutionSpace >
70 Teuchos::RCP< Kokkos::View<Scalar**, Kokkos::LayoutLeft, ExecutionSpace> >
72 Kokkos::View<Scalar**, Kokkos::LayoutLeft, ExecutionSpace> >::clone() const
73 {
74 using MV = Kokkos::View<Scalar**, Kokkos::LayoutLeft, ExecutionSpace>;
75 MV Y("clonedY", mv_->extent(0), mv_->extent(1));
76 return Teuchos::rcp( &Y );
77 }
78
79 template <typename Scalar, typename ExecutionSpace >
80 Scalar *
81 MultiVecAdapter<
82 Kokkos::View<Scalar**, Kokkos::LayoutLeft, ExecutionSpace> >::getMVPointer_impl() const
83 {
84 TEUCHOS_TEST_FOR_EXCEPTION( true, std::runtime_error, "getMVPointer_impl not implemented.");
85 }
86
87 template <typename Scalar, typename ExecutionSpace >
88 void
90 Kokkos::View<Scalar**, Kokkos::LayoutLeft, ExecutionSpace> >::get1dCopy(const Teuchos::ArrayView<scalar_t>& av,
91 size_t lda,
92 Teuchos::Ptr<
93 const Tpetra::Map<local_ordinal_t, global_ordinal_t,
94 MultiVecAdapter<Kokkos::View<Scalar**, Kokkos::LayoutLeft, ExecutionSpace>>::node_t>> distribution_map,
95 EDistribution distribution) const
96 {
97 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "get1dCopy for kokkos not implemented.");
98 }
99
100 template <typename Scalar, typename ExecutionSpace >
101 Teuchos::ArrayRCP<Scalar>
103 Kokkos::View<Scalar**, Kokkos::LayoutLeft, ExecutionSpace> >::get1dViewNonConst (bool local)
104 {
105 TEUCHOS_TEST_FOR_EXCEPTION(
106 true, std::logic_error, "Amesos2::MultiVecAdapter::get1dViewNonConst: "
107 "Not implemented.");
108 }
109
110 template <typename Scalar, typename ExecutionSpace>
111 void
113 Kokkos::View<Scalar**, Kokkos::LayoutLeft, ExecutionSpace> >::put1dData(
114 const Teuchos::ArrayView<const scalar_t>& new_data,
115 size_t lda,
116 Teuchos::Ptr<
117 const Tpetra::Map<local_ordinal_t, global_ordinal_t,
118 MultiVecAdapter<Kokkos::View<Scalar**, Kokkos::LayoutLeft, ExecutionSpace>>::node_t> > source_map,
119 EDistribution /* distribution */) const
120 {
121 TEUCHOS_TEST_FOR_EXCEPTION(
122 true, std::logic_error, "Amesos2::MultiVecAdapter::put1dData: "
123 "Not implemented.");
124 }
125
126 template <typename Scalar, typename ExecutionSpace >
127 std::string
129 Kokkos::View<Scalar**, Kokkos::LayoutLeft, ExecutionSpace> >::description() const
130 {
131 std::ostringstream oss;
132 oss << "Amesos2 adapter wrapping: ";
133 oss << mv_->description();
134 return oss.str();
135 }
136
137
138 template <typename Scalar, typename ExecutionSpace >
139 void
141 Kokkos::View<Scalar**, Kokkos::LayoutLeft, ExecutionSpace> >::describe (Teuchos::FancyOStream& os,
142 const Teuchos::EVerbosityLevel verbLevel) const
143 {
144 mv_->describe (os, verbLevel);
145 }
146
147} // end namespace Amesos2
148
149#endif // AMESOS2_KOKKOS_MULTIVEC_ADAPTER_DEF_HPP
Amesos2::MultiVecAdapter specialization for the Kokkos::View class.
Copy or assign views based on memory spaces.
EDistribution
Definition Amesos2_TypeDecl.hpp:123
A templated MultiVector class adapter for Amesos2.
Definition Amesos2_MultiVecAdapter_decl.hpp:176