42 #ifndef TPETRA_MULTIVECTOR_DECL_HPP
43 #define TPETRA_MULTIVECTOR_DECL_HPP
57 #include "Tpetra_DistObject.hpp"
59 #include "Kokkos_DualView.hpp"
60 #include "Teuchos_BLAS_types.hpp"
61 #include "Teuchos_DataAccess.hpp"
62 #include "Teuchos_Range1D.hpp"
63 #include "Kokkos_ArithTraits.hpp"
64 #include "Kokkos_InnerProductSpaceTraits.hpp"
65 #include "Tpetra_KokkosRefactor_Details_MultiVectorLocalDeepCopy.hpp"
66 #include <type_traits>
68 #ifdef HAVE_TPETRACORE_TEUCHOSNUMERICS
69 #ifndef DOXYGEN_SHOULD_SKIP_THIS
71 template<
class OrdinalType,
class ScalarType>
72 class SerialDenseMatrix;
79 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
106 template<
class DstMultiVectorType,
class SrcMultiVectorType>
107 struct MultiVectorCloner {
108 typedef DstMultiVectorType dst_mv_type;
109 typedef SrcMultiVectorType src_mv_type;
111 static Teuchos::RCP<dst_mv_type>
112 clone (
const src_mv_type& X,
113 const Teuchos::RCP<typename dst_mv_type::node_type>& node2);
138 template <
class DS,
class DL,
class DG,
class DN,
139 class SS,
class SL,
class SG,
class SN>
144 #ifdef HAVE_TPETRACORE_TEUCHOSNUMERICS
151 template <
class ST,
class LO,
class GO,
class NT>
154 const Teuchos::SerialDenseMatrix<int, ST>& src);
162 template <
class ST,
class LO,
class GO,
class NT>
164 deep_copy (Teuchos::SerialDenseMatrix<int, ST>& dst,
175 template <
class ST,
class LO,
class GO,
class NT>
188 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
189 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
191 const size_t numVectors);
196 template<
class SC,
class LO,
class GO,
class NT>
197 Teuchos::ArrayView<const size_t>
419 template <
class Scalar,
424 public DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>
448 typename Kokkos::Details::ArithTraits<Scalar>::val_type;
467 typename Kokkos::Details::InnerProductSpaceTraits<impl_scalar_type>::dot_type;
475 using mag_type =
typename Kokkos::ArithTraits<impl_scalar_type>::mag_type;
522 MultiVector (
const Teuchos::RCP<const map_type>& map,
523 const size_t numVecs,
524 const bool zeroOut =
true);
537 const Teuchos::DataAccess copyOrView);
554 MultiVector (
const Teuchos::RCP<const map_type>& map,
555 const Teuchos::ArrayView<const Scalar>& A,
557 const size_t NumVectors);
572 MultiVector (
const Teuchos::RCP<const map_type>& map,
573 const Teuchos::ArrayView<
const Teuchos::ArrayView<const Scalar> >&ArrayOfPtrs,
574 const size_t NumVectors);
588 MultiVector (
const Teuchos::RCP<const map_type>& map,
629 MultiVector (
const Teuchos::RCP<const map_type>& map,
630 const typename dual_view_type::t_dev& d_view);
654 MultiVector (
const Teuchos::RCP<const map_type>& map,
686 MultiVector (
const Teuchos::RCP<const map_type>& map,
688 const Teuchos::ArrayView<const size_t>& whichVectors);
717 MultiVector (
const Teuchos::RCP<const map_type>& map,
720 const Teuchos::ArrayView<const size_t>& whichVectors);
783 const Teuchos::RCP<const map_type>& subMap,
794 const size_t offset = 0);
840 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
841 template <
class Node2>
842 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node2> > TPETRA_DEPRECATED
843 clone (
const Teuchos::RCP<Node2>& node2)
const;
859 #ifdef KOKKOS_ENABLE_SERIAL
860 ! std::is_same<execution_space, Kokkos::Serial>::value;
932 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
935 const T& value)
const
997 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1071 template<
typename T>
1072 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1134 template<
typename T>
1135 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1155 template<
typename T>
1156 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1189 void randomize (
const Scalar& minVal,
const Scalar& maxVal);
1256 void replaceMap (
const Teuchos::RCP<const map_type>& map);
1296 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1297 subCopy (
const Teuchos::Range1D& colRng)
const;
1300 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1301 subCopy (
const Teuchos::ArrayView<const size_t>& cols)
const;
1304 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1305 subView (
const Teuchos::Range1D& colRng)
const;
1308 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1309 subView (
const Teuchos::ArrayView<const size_t>& cols)
const;
1312 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1316 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1381 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1382 offsetView (
const Teuchos::RCP<const map_type>& subMap,
1383 const size_t offset)
const;
1402 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1404 const size_t offset);
1407 Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1411 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1415 Teuchos::ArrayRCP<const Scalar>
getData (
size_t j)
const;
1428 get1dCopy (
const Teuchos::ArrayView<Scalar>& A,
1429 const size_t LDA)
const;
1438 get2dCopy (
const Teuchos::ArrayView<
const Teuchos::ArrayView<Scalar> >& ArrayOfPtrs)
const;
1445 Teuchos::ArrayRCP<const Scalar>
get1dView ()
const;
1448 Teuchos::ArrayRCP<Teuchos::ArrayRCP<const Scalar> >
get2dView ()
const;
1460 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1505 template<
class TargetDeviceType>
1507 view_.template sync<TargetDeviceType> ();
1517 template<
class TargetDeviceType>
1519 return view_.template need_sync<TargetDeviceType> ();
1533 template<
class TargetDeviceType>
1535 view_.template modify<TargetDeviceType> ();
1575 template<
class TargetDeviceType>
1576 typename Kokkos::Impl::if_c<
1578 typename device_type::memory_space,
1579 typename TargetDeviceType::memory_space>::value,
1580 typename dual_view_type::t_dev,
1581 typename dual_view_type::t_host>::type
1583 return view_.template view<TargetDeviceType> ();
1611 const Teuchos::ArrayView<dot_type>& dots)
const;
1624 template <
typename T>
1625 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1627 const Teuchos::ArrayView<T> &dots)
const
1629 const size_t sz =
static_cast<size_t> (dots.size ());
1630 Teuchos::Array<dot_type> dts (sz);
1632 for (
size_t i = 0; i < sz; ++i) {
1639 template <
typename T>
1640 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1642 std::vector<T>& dots)
const
1644 const size_t sz = dots.size ();
1645 Teuchos::Array<dot_type> dts (sz);
1647 for (
size_t i = 0; i < sz; ++i) {
1672 const Kokkos::View<dot_type*, Kokkos::HostSpace>& norms)
const;
1674 template<
class ViewType>
1676 dot (
typename std::enable_if<std::is_same<typename ViewType::value_type,dot_type>::value &&
1677 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value,
1679 const ViewType& dots)
const {
1680 const Kokkos::View<dot_type*, Kokkos::HostSpace> h_dots(
"Tpetra::Dots",dots.extent(0));
1681 this->
dot (A, h_dots);
1697 template <
typename T>
1698 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1700 const Kokkos::View<T*, device_type>& dots)
const
1702 const size_t numDots = dots.extent (0);
1703 Kokkos::View<dot_type*, device_type> dts (
"MV::dot tmp", numDots);
1729 void scale (
const Scalar& alpha);
1739 void scale (
const Teuchos::ArrayView<const Scalar>& alpha);
1749 void scale (
const Kokkos::View<const impl_scalar_type*, device_type>& alpha);
1760 scale (
const Scalar& alpha,
1770 update (
const Scalar& alpha,
1772 const Scalar& beta);
1781 update (
const Scalar& alpha,
1785 const Scalar& gamma);
1799 norm1 (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1801 template<
class ViewType>
1802 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1803 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1804 norm1 (
const ViewType& norms)
const {
1808 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1809 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
1810 this->
norm1 (h_norms);
1829 template <
typename T>
1830 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1831 norm1 (
const Kokkos::View<T*, device_type>& norms)
const
1833 const size_t numNorms = norms.extent (0);
1834 Kokkos::View<mag_type*, device_type> tmpNorms (
"MV::norm1 tmp", numNorms);
1836 this->
norm1 (tmpNorms);
1848 void norm1 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1864 template <
typename T>
1865 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1866 norm1 (
const Teuchos::ArrayView<T>& norms)
const
1868 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1869 const size_type sz = norms.size ();
1870 Teuchos::Array<mag_type> theNorms (sz);
1871 this->
norm1 (theNorms);
1872 for (size_type i = 0; i < sz; ++i) {
1874 norms[i] = theNorms[i];
1891 norm2 (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1893 template<
class ViewType>
1894 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1895 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1896 norm2 (
const ViewType& norms)
const {
1900 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1901 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
1902 this->
norm2 (h_norms);
1919 template<
typename T>
1920 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1921 norm2 (
const Kokkos::View<T*, device_type>& norms)
const
1923 const size_t numNorms = norms.extent (0);
1924 Kokkos::View<mag_type*, device_type> theNorms (
"MV::norm2 tmp", numNorms);
1926 this->
norm2 (theNorms);
1938 void norm2 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1954 template <
typename T>
1955 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1956 norm2 (
const Teuchos::ArrayView<T>& norms)
const
1958 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1959 const size_type sz = norms.size ();
1960 Teuchos::Array<mag_type> theNorms (sz);
1961 this->
norm2 (theNorms);
1962 for (size_type i = 0; i < sz; ++i) {
1964 norms[i] = theNorms[i];
1974 void normInf (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1976 template<
class ViewType>
1977 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1978 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1979 normInf (
const ViewType& norms)
const {
1983 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1984 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
2002 template<
typename T>
2003 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
2004 normInf (
const Kokkos::View<T*, device_type>& norms)
const
2006 const size_t numNorms = norms.extent (0);
2007 Kokkos::View<mag_type*, device_type> theNorms (
"MV::normInf tmp", numNorms);
2022 void normInf (
const Teuchos::ArrayView<mag_type>& norms)
const;
2039 template <
typename T>
2040 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
2041 normInf (
const Teuchos::ArrayView<T>& norms)
const
2043 typedef typename Teuchos::ArrayView<T>::size_type size_type;
2044 const size_type sz = norms.size ();
2045 Teuchos::Array<mag_type> theNorms (sz);
2046 this->
norm2 (theNorms);
2047 for (size_type i = 0; i < sz; ++i) {
2049 norms[i] = theNorms[i];
2053 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2060 void TPETRA_DEPRECATED
2062 const Teuchos::ArrayView<mag_type>& norms)
const;
2080 template <
typename T>
2081 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
2084 const Teuchos::ArrayView<T>& norms)
const
2086 typedef typename Teuchos::ArrayView<T>::size_type size_type;
2087 const size_type sz = norms.size ();
2088 Teuchos::Array<mag_type> theNorms (sz);
2089 this->normWeighted (weights, theNorms);
2090 for (size_type i = 0; i < sz; ++i) {
2092 norms[i] = theNorms[i];
2101 void meanValue (
const Teuchos::ArrayView<impl_scalar_type>& means)
const;
2103 template <
typename T>
2104 typename std::enable_if<! std::is_same<impl_scalar_type, T>::value,
void>::type
2105 meanValue (
const Teuchos::ArrayView<T>& means)
const
2107 typedef typename Teuchos::Array<T>::size_type size_type;
2108 const size_type numMeans = means.size ();
2110 Teuchos::Array<impl_scalar_type> theMeans (numMeans);
2112 for (size_type k = 0; k < numMeans; ++k) {
2113 means[k] =
static_cast<T
> (theMeans[k]);
2124 Teuchos::ETransp transB,
2125 const Scalar& alpha,
2126 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
2127 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
2128 const Scalar& beta);
2152 const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
2153 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
2217 describe (Teuchos::FancyOStream& out,
2218 const Teuchos::EVerbosityLevel verbLevel =
2219 Teuchos::Describable::verbLevel_default)
const;
2249 TEUCHOS_TEST_FOR_EXCEPTION(
2250 copyOrView == Teuchos::Copy, std::invalid_argument,
2251 "Tpetra::MultiVector::setCopyOrView: The Kokkos refactor version of "
2252 "MultiVector _only_ implements view semantics. You may not call this "
2253 "method with copyOrView = Teuchos::Copy. The only valid argument is "
2266 return Teuchos::View;
2303 template <
class DS,
class DL,
class DG,
class DN,
2304 class SS,
class SL,
class SG,
class SN>
2362 template<
class SC,
class LO,
class GO,
class NT>
2363 friend ::Teuchos::ArrayView<const size_t> getMultiVectorWhichVectors (const ::Tpetra::MultiVector<SC, LO, GO, NT>& X);
2402 const std::string& className,
2403 const Teuchos::EVerbosityLevel verbLevel =
2404 Teuchos::Describable::verbLevel_default)
const;
2407 bool vectorIndexOutOfRange (
const size_t VectorIndex)
const;
2414 Teuchos::ArrayRCP<T>
2448 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2454 const size_t numSameIDs,
2455 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
2456 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs);
2459 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2465 const Kokkos::DualView<
2474 size_t& constantNumPackets,
2478 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2483 (
const Kokkos::DualView<
2492 const size_t constantNumPackets,
2498 template<
class SC,
class LO,
class GO,
class NT>
2499 Teuchos::ArrayView<const size_t>
2505 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2507 template<
class DstMultiVectorType,
2508 class SrcMultiVectorType>
2510 typename MultiVectorCloner<
2512 SrcMultiVectorType>::dst_mv_type>
2513 MultiVectorCloner<DstMultiVectorType, SrcMultiVectorType>::
2514 clone (
const src_mv_type& X,
2515 const Teuchos::RCP<typename dst_mv_type::node_type>& node2)
2518 typedef typename src_mv_type::map_type src_map_type;
2519 typedef typename dst_mv_type::map_type dst_map_type;
2520 typedef typename dst_mv_type::node_type dst_node_type;
2521 typedef typename dst_mv_type::dual_view_type dst_dual_view_type;
2524 RCP<const src_map_type> map1 = X.getMap ();
2525 RCP<const dst_map_type> map2 = map1.is_null () ?
2526 Teuchos::null : map1->template clone<dst_node_type> (node2);
2528 const size_t lclNumRows = X.getLocalLength ();
2529 const size_t numCols = X.getNumVectors ();
2530 dst_dual_view_type Y_view (
"MV::dual_view", lclNumRows, numCols);
2532 RCP<dst_mv_type> Y (
new dst_mv_type (map2, Y_view));
2542 template <
class ST,
class LO,
class GO,
class NT>
2554 template <
class DS,
class DL,
class DG,
class DN,
2555 class SS,
class SL,
class SG,
class SN>
2560 using ::Tpetra::getMultiVectorWhichVectors;
2562 TEUCHOS_TEST_FOR_EXCEPTION(
2565 "Tpetra::deep_copy: Global dimensions of the two Tpetra::MultiVector "
2566 "objects do not match. src has dimensions [" << src.
getGlobalLength ()
2567 <<
"," << src.
getNumVectors () <<
"], and dst has dimensions ["
2571 TEUCHOS_TEST_FOR_EXCEPTION(
2573 "Tpetra::deep_copy: The local row counts of the two Tpetra::MultiVector "
2574 "objects do not match. src has " << src.
getLocalLength () <<
" row(s) "
2582 if (srcMostUpToDateOnDevice) {
2592 auto dstWhichVecs = getMultiVectorWhichVectors (dst);
2593 auto srcWhichVecs = getMultiVectorWhichVectors (src);
2595 if (srcMostUpToDateOnDevice) {
2620 template<
class SC,
class LO,
class GO,
class NT>
2621 class TypeNameTraits<
Tpetra::MultiVector<SC, LO, GO, NT> > {
2623 static std::string name () {
2624 return std::string (
"Tpetra::MultiVector<") +
2625 TypeNameTraits<SC>::name () +
"," +
2626 TypeNameTraits<LO>::name () +
"," +
2627 TypeNameTraits<GO>::name () +
"," +
2628 TypeNameTraits<NT>::name () +
">";
Forward declaration of Tpetra::FEMultiVector.
Forward declaration of Tpetra::Map.
Forward declaration of Tpetra::MultiVector.
Forward declaration of Tpetra::Vector.
Base class for distributed Tpetra objects that support data redistribution.
Sets up and executes a communication plan for a Tpetra DistObject.
A parallel distribution of indices over processes.
Node node_type
Legacy typedef that will go away at some point.
GlobalOrdinal global_ordinal_type
The type of global indices.
LocalOrdinal local_ordinal_type
The type of local indices.
typename Node::device_type device_type
This class' Kokkos::Device specialization.
One or more distributed dense vectors.
virtual void copyAndPermute(const SrcDistObject &sourceObj, const size_t numSameIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteToLIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteFromLIDs)
Perform copies and permutations that are local to the calling (MPI) process.
typename map_type::global_ordinal_type global_ordinal_type
The type of global indices that this class uses.
void reciprocal(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,...
dual_view_type origView_
The "original view" of the MultiVector's data.
void normInf(const Kokkos::View< mag_type *, Kokkos::HostSpace > &norms) const
Compute the infinity-norm of each vector (column), storing the result in a host View.
std::enable_if<! std::is_same< T, impl_scalar_type >::value &&std::is_convertible< T, impl_scalar_type >::value, void >::type sumIntoLocalValue(const LocalOrdinal lclRow, const size_t col, const T &val, const bool atomic=useAtomicUpdatesByDefault) const
Like the above sumIntoLocalValue, but only enabled if T differs from impl_scalar_type.
void get1dCopy(const Teuchos::ArrayView< Scalar > &A, const size_t LDA) const
Fill the given array with a copy of this multivector's local values.
size_t getStride() const
Stride between columns in the multivector.
virtual size_t constantNumberOfPackets() const
Number of packets to send per LID.
typename map_type::node_type node_type
Legacy thing that you should not use any more.
virtual std::string description() const
A simple one-line description of this object.
void reduce()
Sum values of a locally replicated multivector across all processes.
dual_view_type::t_host getLocalViewHost() const
A local Kokkos::View of host memory.
void randomize()
Set all values in the multivector to pseudorandom numbers.
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap)
Remove processes owning zero rows from the Map and their communicator.
typename map_type::local_ordinal_type local_ordinal_type
The type of local indices that this class uses.
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.
void scale(const Scalar &alpha)
Scale in place: this = alpha*this.
Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subView(const Teuchos::Range1D &colRng) const
Return a const MultiVector with const views of selected columns.
void dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< dot_type > &dots) const
Compute the dot product of each corresponding pair of vectors (columns) in A and B.
void describeImpl(Teuchos::FancyOStream &out, const std::string &className, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Implementation of describe() for this class, and its subclass Vector.
void replaceLocalValue(const LocalOrdinal lclRow, const size_t col, const impl_scalar_type &value) const
Replace value in host memory, using local (row) index.
Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > offsetView(const Teuchos::RCP< const map_type > &subMap, const size_t offset) const
Return a const view of a subset of rows.
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & operator=(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy assigment (shallow copy).
Teuchos::ArrayRCP< Scalar > get1dViewNonConst()
Nonconst persisting (1-D) view of this multivector's local values.
void assign(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &src)
Copy the contents of src into *this (deep copy).
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(const size_t j)
Return a Vector which is a nonconst view of column j.
void meanValue(const Teuchos::ArrayView< impl_scalar_type > &means) const
Compute mean (average) value of each column.
std::string descriptionImpl(const std::string &className) const
Implementation of description() for this class, and its subclass Vector.
void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Scalar &beta)
Matrix-matrix multiplication: this = beta*this + alpha*op(A)*op(B).
Kokkos::Impl::if_c< std::is_same< typename device_type::memory_space, typename TargetDeviceType::memory_space >::value, typename dual_view_type::t_dev, typename dual_view_type::t_host >::type getLocalView() const
Return a view of the local data on a specific device.
bool need_sync_device() const
Whether this MultiVector needs synchronization to the device.
MultiVector(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const map_type &subMap, const size_t offset=0)
"Offset view" constructor, that takes the new Map as a const Map& rather than by RCP.
void clear_sync_state()
Clear "modified" flags on both host and device sides.
std::enable_if<! std::is_same< T, impl_scalar_type >::value &&std::is_convertible< T, impl_scalar_type >::value, void >::type sumIntoGlobalValue(const GlobalOrdinal gblRow, const size_t col, const T &val, const bool atomic=useAtomicUpdatesByDefault) const
Like the above sumIntoGlobalValue, but only enabled if T differs from impl_scalar_type.
void swap(MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &mv)
Return a deep copy of this MultiVector, with a different Node type.
size_t getLocalLength() const
Local number of rows on the calling process.
typename DistObject< scalar_type, local_ordinal_type, global_ordinal_type, node_type >::buffer_device_type buffer_device_type
Kokkos::Device specialization for communication buffers.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subCopy(const Teuchos::Range1D &colRng) const
Return a MultiVector with copies of selected columns.
typename Kokkos::Details::InnerProductSpaceTraits< impl_scalar_type >::dot_type dot_type
Type of an inner ("dot") product result.
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this multivector.
bool need_sync_host() const
Whether this MultiVector needs synchronization to the host.
Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(const size_t j) const
Return a Vector which is a const view of column j.
void modify_device()
Mark data as modified on the device side.
std::enable_if<! std::is_same< T, impl_scalar_type >::value &&std::is_convertible< T, impl_scalar_type >::value, void >::type replaceLocalValue(const LocalOrdinal lclRow, const size_t col, const T &val) const
Like the above replaceLocalValue, but only enabled if T differs from impl_scalar_type.
void sumIntoGlobalValue(const GlobalOrdinal gblRow, const size_t col, const impl_scalar_type &value, const bool atomic=useAtomicUpdatesByDefault) const
Update (+=) a value in host memory, using global row index.
Scalar scalar_type
The type of each entry in the MultiVector.
bool need_sync() const
Whether this MultiVector needs synchronization to the given space.
void norm2(const Kokkos::View< mag_type *, Kokkos::HostSpace > &norms) const
Compute the two-norm of each vector (column), storing the result in a host View.
typename Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
global_size_t getGlobalLength() const
Global number of rows in the multivector.
Teuchos::ArrayRCP< const Scalar > get1dView() const
Const persisting (1-D) view of this multivector's local values.
Teuchos::ArrayRCP< T > getSubArrayRCP(Teuchos::ArrayRCP< T > arr, size_t j) const
Persisting view of j-th column in the given ArrayRCP.
void modify()
Mark data as modified on the given device TargetDeviceType.
typename map_type::device_type device_type
This class' preferred Kokkos device type.
void sumIntoLocalValue(const LocalOrdinal lclRow, const size_t col, const impl_scalar_type &val, const bool atomic=useAtomicUpdatesByDefault) const
Update (+=) a value in host memory, using local row index.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with the given verbosity level to a FancyOStream.
void elementWiseMultiply(Scalar scalarAB, const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, Scalar scalarThis)
Multiply a Vector A elementwise by a MultiVector B.
void replaceGlobalValue(const GlobalOrdinal gblRow, const size_t col, const impl_scalar_type &value) const
Replace value in host memory, using global row index.
void setCopyOrView(const Teuchos::DataAccess copyOrView)
Set whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
size_t getNumVectors() const
Number of columns in the multivector.
void sync_host()
Synchronize to Host.
void replaceMap(const Teuchos::RCP< const map_type > &map)
Replace the underlying Map in place.
Teuchos::DataAccess getCopyOrView() const
Get whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
virtual bool checkSizes(const SrcDistObject &sourceObj)
Whether data redistribution between sourceObj and this object is legal.
MultiVector()
Default constructor: makes a MultiVector with no rows or columns.
typename device_type::execution_space execution_space
Type of the (new) Kokkos execution space.
void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise absolute values of input Multi-vector in target: A = abs(this)
void norm1(const Kokkos::View< mag_type *, Kokkos::HostSpace > &norms) const
Compute the one-norm of each vector (column), storing the result in a host view.
void sync_device()
Synchronize to Device.
void get2dCopy(const Teuchos::ArrayView< const Teuchos::ArrayView< Scalar > > &ArrayOfPtrs) const
Fill the given array with a copy of this multivector's local values.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subViewNonConst(const Teuchos::Range1D &colRng)
Return a MultiVector with views of selected columns.
MultiVector(MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &&)=default
Move constructor (shallow move).
Teuchos::Array< size_t > whichVectors_
Indices of columns this multivector is viewing.
Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
bool isConstantStride() const
Whether this multivector has constant stride between columns.
void sync()
Update data on device or host only if data in the other space has been marked as modified.
typename Kokkos::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
std::enable_if<! std::is_same< T, impl_scalar_type >::value &&std::is_convertible< T, impl_scalar_type >::value, void >::type putScalar(const T &value)
Set all values in the multivector with the given value.
size_t getOrigNumLocalCols() const
"Original" number of columns in the (local) data.
MultiVector(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const Teuchos::RCP< const map_type > &subMap, const local_ordinal_type rowOffset=0)
"Offset view" constructor; make a view of a contiguous subset of rows on each process.
Teuchos::ArrayRCP< Teuchos::ArrayRCP< Scalar > > get2dViewNonConst()
Return non-const persisting pointers to values.
std::enable_if<! std::is_same< T, impl_scalar_type >::value &&std::is_convertible< T, impl_scalar_type >::value, void >::type replaceGlobalValue(GlobalOrdinal globalRow, size_t col, const T &value) const
Like the above replaceGlobalValue, but only enabled if T differs from impl_scalar_type.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > offsetViewNonConst(const Teuchos::RCP< const map_type > &subMap, const size_t offset)
Return a nonconst view of a subset of rows.
std::string localDescribeToString(const Teuchos::EVerbosityLevel vl) const
Print the calling process' verbose describe() information to the returned string.
bool isSameSize(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &vec) const
size_t getOrigNumLocalRows() const
"Original" number of rows in the (local) data.
MultiVector(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy constructor (shallow copy).
Teuchos::ArrayRCP< Teuchos::ArrayRCP< const Scalar > > get2dView() const
Return const persisting pointers to values.
virtual ~MultiVector()=default
Destructor (virtual for memory safety of derived classes).
void modify_host()
Mark data as modified on the host side.
dual_view_type view_
The Kokkos::DualView containing the MultiVector's data.
static const bool useAtomicUpdatesByDefault
Whether sumIntoLocalValue and sumIntoGlobalValue should use atomic updates by default.
void putScalar(const Scalar &value)
Set all values in the multivector with the given value.
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutLeft, execution_space > dual_view_type
Kokkos::DualView specialization used by this class.
void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)
Update: this = beta*this + alpha*A.
dual_view_type::t_dev getLocalViewDevice() const
A local Kokkos::View of device memory.
Abstract base class for objects that can be the source of an Import or Export operation.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > createMultiVector(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const size_t numVectors)
Nonmember MultiVector "constructor": Create a MultiVector from a given Map.
Implementation details of Tpetra.
void localDeepCopyConstStride(const DstViewType &dst, const SrcViewType &src)
Implementation of Tpetra::MultiVector deep copy of local data, for when both the source and destinati...
void localDeepCopy(const DstViewType &dst, const SrcViewType &src, const bool dstConstStride, const bool srcConstStride, const DstWhichVecsType &dstWhichVecs, const SrcWhichVecsType &srcWhichVecs)
Implementation of Tpetra::MultiVector deep copy of local data.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
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.
void deep_copy(MultiVector< ST, LO, GO, NT > &dst, const MultiVector< ST, LO, GO, NT > &src)
Specialization of deep_copy for MultiVector objects with the same template parameters.
size_t global_size_t
Global size_t object.
MultiVector< ST, LO, GO, NT > createCopy(const MultiVector< ST, LO, GO, NT > &src)
Return a deep copy of the given MultiVector.
CombineMode
Rule for combining data in an Import or Export.