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;
74 #endif // DOXYGEN_SHOULD_SKIP_THIS
75 #endif // HAVE_TPETRACORE_TEUCHOSNUMERICS
100 template <
class DS,
class DL,
class DG,
class DN,
101 class SS,
class SL,
class SG,
class SN>
103 deep_copy (MultiVector<DS, DL, DG, DN>& dst,
104 const MultiVector<SS, SL, SG, SN>& src);
106 #ifdef HAVE_TPETRACORE_TEUCHOSNUMERICS
107 template <
class ST,
class LO,
class GO,
class NT>
115 deep_copy (MultiVector<ST, LO, GO, NT>& dst,
116 const Teuchos::SerialDenseMatrix<int, ST>& src);
124 template <
class ST,
class LO,
class GO,
class NT>
126 deep_copy (Teuchos::SerialDenseMatrix<int, ST>& dst,
127 const MultiVector<ST, LO, GO, NT>& src);
128 #endif // HAVE_TPETRACORE_TEUCHOSNUMERICS
137 template <
class ST,
class LO,
class GO,
class NT>
138 MultiVector<ST, LO, GO, NT>
139 createCopy (
const MultiVector<ST, LO, GO, NT>& src);
150 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
151 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
152 createMultiVector (
const Teuchos::RCP<
const Map<LocalOrdinal, GlobalOrdinal, Node> >& map,
153 const size_t numVectors);
158 template<
class SC,
class LO,
class GO,
class NT>
159 Teuchos::ArrayView<const size_t>
160 getMultiVectorWhichVectors (
const MultiVector<SC, LO, GO, NT>& X);
381 template <
class Scalar,
386 public DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>
410 typename Kokkos::Details::ArithTraits<Scalar>::val_type;
429 typename Kokkos::Details::InnerProductSpaceTraits<impl_scalar_type>::dot_type;
437 using mag_type =
typename Kokkos::ArithTraits<impl_scalar_type>::mag_type;
484 MultiVector (
const Teuchos::RCP<const map_type>& map,
485 const size_t numVecs,
486 const bool zeroOut =
true);
499 const Teuchos::DataAccess copyOrView);
516 MultiVector (
const Teuchos::RCP<const map_type>& map,
517 const Teuchos::ArrayView<const Scalar>& A,
519 const size_t NumVectors);
534 MultiVector (
const Teuchos::RCP<const map_type>& map,
535 const Teuchos::ArrayView<
const Teuchos::ArrayView<const Scalar> >&ArrayOfPtrs,
536 const size_t NumVectors);
550 MultiVector (
const Teuchos::RCP<const map_type>& map,
591 MultiVector (
const Teuchos::RCP<const map_type>& map,
592 const typename dual_view_type::t_dev& d_view);
616 MultiVector (
const Teuchos::RCP<const map_type>& map,
648 MultiVector (
const Teuchos::RCP<const map_type>& map,
650 const Teuchos::ArrayView<const size_t>& whichVectors);
679 MultiVector (
const Teuchos::RCP<const map_type>& map,
682 const Teuchos::ArrayView<const size_t>& whichVectors);
745 const Teuchos::RCP<const map_type>& subMap,
756 const size_t offset = 0);
807 #ifdef KOKKOS_ENABLE_SERIAL
808 ! std::is_same<execution_space, Kokkos::Serial>::value;
811 #endif // KOKKOS_ENABLE_SERIAL
880 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
883 const T& value)
const
945 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1019 template<
typename T>
1020 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1082 template<
typename T>
1083 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1103 template<
typename T>
1104 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1107 putScalar (static_cast<impl_scalar_type> (value));
1137 void randomize (
const Scalar& minVal,
const Scalar& maxVal);
1204 void replaceMap (
const Teuchos::RCP<const map_type>& map);
1244 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1245 subCopy (
const Teuchos::Range1D& colRng)
const;
1248 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1249 subCopy (
const Teuchos::ArrayView<const size_t>& cols)
const;
1252 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1253 subView (
const Teuchos::Range1D& colRng)
const;
1256 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1257 subView (
const Teuchos::ArrayView<const size_t>& cols)
const;
1260 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1264 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1329 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1330 offsetView (
const Teuchos::RCP<const map_type>& subMap,
1331 const size_t offset)
const;
1350 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1352 const size_t offset);
1355 Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1359 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1363 Teuchos::ArrayRCP<const Scalar>
getData (
size_t j)
const;
1376 get1dCopy (
const Teuchos::ArrayView<Scalar>& A,
1377 const size_t LDA)
const;
1386 get2dCopy (
const Teuchos::ArrayView<
const Teuchos::ArrayView<Scalar> >& ArrayOfPtrs)
const;
1393 Teuchos::ArrayRCP<const Scalar>
get1dView ()
const;
1396 Teuchos::ArrayRCP<Teuchos::ArrayRCP<const Scalar> >
get2dView ()
const;
1430 template<
class TargetDeviceType>
1432 view_.template sync<TargetDeviceType> ();
1442 template<
class TargetDeviceType>
1444 return view_.template need_sync<TargetDeviceType> ();
1458 template<
class TargetDeviceType>
1460 view_.template modify<TargetDeviceType> ();
1500 template<
class TargetDeviceType>
1501 typename Kokkos::Impl::if_c<
1503 typename device_type::memory_space,
1504 typename TargetDeviceType::memory_space>::value,
1505 typename dual_view_type::t_dev,
1506 typename dual_view_type::t_host>::type
1508 return view_.template view<TargetDeviceType> ();
1536 const Teuchos::ArrayView<dot_type>& dots)
const;
1549 template <
typename T>
1550 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1552 const Teuchos::ArrayView<T> &dots)
const
1554 const size_t sz =
static_cast<size_t> (dots.size ());
1555 Teuchos::Array<dot_type> dts (sz);
1557 for (
size_t i = 0; i < sz; ++i) {
1564 template <
typename T>
1565 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1567 std::vector<T>& dots)
const
1569 const size_t sz = dots.size ();
1570 Teuchos::Array<dot_type> dts (sz);
1572 for (
size_t i = 0; i < sz; ++i) {
1597 const Kokkos::View<dot_type*, Kokkos::HostSpace>& norms)
const;
1599 template<
class ViewType>
1601 dot (
typename std::enable_if<std::is_same<typename ViewType::value_type,dot_type>::value &&
1602 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value,
1604 const ViewType& dots)
const {
1605 const Kokkos::View<dot_type*, Kokkos::HostSpace> h_dots(
"Tpetra::Dots",dots.extent(0));
1606 this->
dot (A, h_dots);
1622 template <
typename T>
1623 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1625 const Kokkos::View<T*, device_type>& dots)
const
1627 const size_t numDots = dots.extent (0);
1628 Kokkos::View<dot_type*, device_type> dts (
"MV::dot tmp", numDots);
1654 void scale (
const Scalar& alpha);
1664 void scale (
const Teuchos::ArrayView<const Scalar>& alpha);
1674 void scale (
const Kokkos::View<const impl_scalar_type*, device_type>& alpha);
1685 scale (
const Scalar& alpha,
1695 update (
const Scalar& alpha,
1697 const Scalar& beta);
1706 update (
const Scalar& alpha,
1710 const Scalar& gamma);
1724 norm1 (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1726 template<
class ViewType>
1727 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1728 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1729 norm1 (
const ViewType& norms)
const {
1733 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1734 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
1735 this->
norm1 (h_norms);
1754 template <
typename T>
1755 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1756 norm1 (
const Kokkos::View<T*, device_type>& norms)
const
1758 const size_t numNorms = norms.extent (0);
1759 Kokkos::View<mag_type*, device_type> tmpNorms (
"MV::norm1 tmp", numNorms);
1761 this->
norm1 (tmpNorms);
1773 void norm1 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1789 template <
typename T>
1790 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1791 norm1 (
const Teuchos::ArrayView<T>& norms)
const
1793 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1794 const size_type sz = norms.size ();
1795 Teuchos::Array<mag_type> theNorms (sz);
1796 this->
norm1 (theNorms);
1797 for (size_type i = 0; i < sz; ++i) {
1799 norms[i] = theNorms[i];
1816 norm2 (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1818 template<
class ViewType>
1819 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1820 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1821 norm2 (
const ViewType& norms)
const {
1825 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1826 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
1827 this->
norm2 (h_norms);
1844 template<
typename T>
1845 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1846 norm2 (
const Kokkos::View<T*, device_type>& norms)
const
1848 const size_t numNorms = norms.extent (0);
1849 Kokkos::View<mag_type*, device_type> theNorms (
"MV::norm2 tmp", numNorms);
1851 this->
norm2 (theNorms);
1863 void norm2 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1879 template <
typename T>
1880 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1881 norm2 (
const Teuchos::ArrayView<T>& norms)
const
1883 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1884 const size_type sz = norms.size ();
1885 Teuchos::Array<mag_type> theNorms (sz);
1886 this->
norm2 (theNorms);
1887 for (size_type i = 0; i < sz; ++i) {
1889 norms[i] = theNorms[i];
1899 void normInf (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1901 template<
class ViewType>
1902 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1903 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1904 normInf (
const ViewType& norms)
const {
1908 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1909 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
1927 template<
typename T>
1928 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1929 normInf (
const Kokkos::View<T*, device_type>& norms)
const
1931 const size_t numNorms = norms.extent (0);
1932 Kokkos::View<mag_type*, device_type> theNorms (
"MV::normInf tmp", numNorms);
1947 void normInf (
const Teuchos::ArrayView<mag_type>& norms)
const;
1964 template <
typename T>
1965 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1966 normInf (
const Teuchos::ArrayView<T>& norms)
const
1968 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1969 const size_type sz = norms.size ();
1970 Teuchos::Array<mag_type> theNorms (sz);
1971 this->
norm2 (theNorms);
1972 for (size_type i = 0; i < sz; ++i) {
1974 norms[i] = theNorms[i];
1983 void meanValue (
const Teuchos::ArrayView<impl_scalar_type>& means)
const;
1985 template <
typename T>
1986 typename std::enable_if<! std::is_same<impl_scalar_type, T>::value,
void>::type
1987 meanValue (
const Teuchos::ArrayView<T>& means)
const
1989 typedef typename Teuchos::Array<T>::size_type size_type;
1990 const size_type numMeans = means.size ();
1992 Teuchos::Array<impl_scalar_type> theMeans (numMeans);
1994 for (size_type k = 0; k < numMeans; ++k) {
1995 means[k] =
static_cast<T
> (theMeans[k]);
2006 Teuchos::ETransp transB,
2007 const Scalar& alpha,
2008 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
2009 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
2010 const Scalar& beta);
2034 const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
2035 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
2099 describe (Teuchos::FancyOStream& out,
2100 const Teuchos::EVerbosityLevel verbLevel =
2101 Teuchos::Describable::verbLevel_default)
const;
2131 TEUCHOS_TEST_FOR_EXCEPTION(
2132 copyOrView == Teuchos::Copy, std::invalid_argument,
2133 "Tpetra::MultiVector::setCopyOrView: The Kokkos refactor version of "
2134 "MultiVector _only_ implements view semantics. You may not call this "
2135 "method with copyOrView = Teuchos::Copy. The only valid argument is "
2148 return Teuchos::View;
2185 template <
class DS,
class DL,
class DG,
class DN,
2186 class SS,
class SL,
class SG,
class SN>
2244 template<
class SC,
class LO,
class GO,
class NT>
2245 friend ::Teuchos::ArrayView<const size_t> getMultiVectorWhichVectors (const ::Tpetra::MultiVector<SC, LO, GO, NT>& X);
2284 const std::string& className,
2285 const Teuchos::EVerbosityLevel verbLevel =
2286 Teuchos::Describable::verbLevel_default)
const;
2289 bool vectorIndexOutOfRange (
const size_t VectorIndex)
const;
2296 Teuchos::ArrayRCP<T>
2332 const size_t numSameIDs,
2333 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
2334 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs);
2339 const Kokkos::DualView<
2348 size_t& constantNumPackets,
2353 (
const Kokkos::DualView<
2362 const size_t constantNumPackets,
2368 template<
class SC,
class LO,
class GO,
class NT>
2369 Teuchos::ArrayView<const size_t>
2378 template <
class ST,
class LO,
class GO,
class NT>
2390 template <
class DS,
class DL,
class DG,
class DN,
2391 class SS,
class SL,
class SG,
class SN>
2396 using ::Tpetra::getMultiVectorWhichVectors;
2398 TEUCHOS_TEST_FOR_EXCEPTION(
2401 "Tpetra::deep_copy: Global dimensions of the two Tpetra::MultiVector "
2402 "objects do not match. src has dimensions [" << src.
getGlobalLength ()
2403 <<
"," << src.
getNumVectors () <<
"], and dst has dimensions ["
2407 TEUCHOS_TEST_FOR_EXCEPTION(
2409 "Tpetra::deep_copy: The local row counts of the two Tpetra::MultiVector "
2410 "objects do not match. src has " << src.
getLocalLength () <<
" row(s) "
2418 if (srcMostUpToDateOnDevice) {
2428 auto dstWhichVecs = getMultiVectorWhichVectors (dst);
2429 auto srcWhichVecs = getMultiVectorWhichVectors (src);
2431 if (srcMostUpToDateOnDevice) {
2456 template<
class SC,
class LO,
class GO,
class NT>
2457 class TypeNameTraits<Tpetra::MultiVector<SC, LO, GO, NT> > {
2459 static std::string name () {
2460 return std::string (
"Tpetra::MultiVector<") +
2461 TypeNameTraits<SC>::name () +
"," +
2462 TypeNameTraits<LO>::name () +
"," +
2463 TypeNameTraits<GO>::name () +
"," +
2464 TypeNameTraits<NT>::name () +
">";
2474 #endif // TPETRA_MULTIVECTOR_DECL_HPP
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.
Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subView(const Teuchos::Range1D &colRng) const
Return a const MultiVector with const views of selected columns.
dual_view_type::t_host getLocalViewHost() const
A local Kokkos::View of host memory.
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.
LocalOrdinal local_ordinal_type
The type of local indices.
dual_view_type view_
The Kokkos::DualView containing the MultiVector's data.
Node node_type
The Node type. If you don't know what this is, don't use it.
GlobalOrdinal global_ordinal_type
The type of global indices.
Teuchos::ArrayRCP< Scalar > get1dViewNonConst()
Nonconst persisting (1-D) view of this multivector's local values.
void meanValue(const Teuchos::ArrayView< impl_scalar_type > &means) const
Compute mean (average) value of each column.
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.
void get2dCopy(const Teuchos::ArrayView< const Teuchos::ArrayView< Scalar > > &ArrayOfPtrs) const
Fill the given array with a copy of this multivector's local values.
typename map_type::node_type node_type
Legacy thing that you should not use any more.
void clear_sync_state()
Clear "modified" flags on both host and device sides.
void localDeepCopyConstStride(const DstViewType &dst, const SrcViewType &src)
Implementation of Tpetra::MultiVector deep copy of local data, for when both the source and destinati...
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutLeft, execution_space > dual_view_type
Kokkos::DualView specialization used by this class.
void putScalar(const Scalar &value)
Set all values in the multivector with the given value.
size_t getNumVectors() const
Number of columns in the multivector.
size_t getLocalLength() const
Local number of rows on the calling process.
void replaceMap(const Teuchos::RCP< const map_type > &map)
Replace the underlying Map in place.
Teuchos::ArrayRCP< Teuchos::ArrayRCP< Scalar > > get2dViewNonConst()
Return non-const persisting pointers to values.
bool isConstantStride() const
Whether this multivector has constant stride between columns.
std::string localDescribeToString(const Teuchos::EVerbosityLevel vl) const
Print the calling process' verbose describe() information to the returned string. ...
One or more distributed dense vectors.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subCopy(const Teuchos::Range1D &colRng) const
Return a MultiVector with copies of selected columns.
void modify()
Mark data as modified on the given device TargetDeviceType.
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.
bool need_sync() const
Whether this MultiVector needs synchronization to the given space.
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.
static const bool useAtomicUpdatesByDefault
Whether sumIntoLocalValue and sumIntoGlobalValue should use atomic updates by default.
MultiVector< ST, LO, GO, NT > createCopy(const MultiVector< ST, LO, GO, NT > &src)
Return a deep copy of the given MultiVector.
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.
void setCopyOrView(const Teuchos::DataAccess copyOrView)
Set whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & operator=(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy assigment (shallow copy).
void sync()
Update data on device or host only if data in the other space has been marked as modified.
typename Node::device_type device_type
The Kokkos Device type.
bool need_sync_device() const
Whether this MultiVector needs synchronization to the device.
GO global_ordinal_type
The type of global indices.
bool isSameSize(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &vec) const
size_t getOrigNumLocalCols() const
"Original" number of columns in the (local) data.
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this multivector.
size_t global_size_t
Global size_t object.
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.
typename device_type::execution_space execution_space
The Kokkos execution space.
void sync_host()
Synchronize to Host.
void scale(const Scalar &alpha)
Scale in place: this = alpha*this.
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).
void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)
Update: this = beta*this + alpha*A.
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.
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(const size_t j)
Return a Vector which is a nonconst view of column j.
void assign(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &src)
Copy the contents of src into *this (deep copy).
dual_view_type origView_
The "original view" of the MultiVector's data.
std::string descriptionImpl(const std::string &className) const
Implementation of description() for this class, and its subclass Vector.
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.
void replaceGlobalValue(const GlobalOrdinal gblRow, const size_t col, const impl_scalar_type &value) const
Replace value in host memory, using global row index.
typename Kokkos::Details::InnerProductSpaceTraits< impl_scalar_type >::dot_type dot_type
Type of an inner ("dot") product 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.
Sets up and executes a communication plan for a Tpetra DistObject.
CombineMode
Rule for combining data in an Import or Export.
typename DistObject< scalar_type, local_ordinal_type, global_ordinal_type, node_type >::buffer_device_type buffer_device_type
Kokkos::Device specialization for communication buffers.
Forward declaration of Tpetra::MultiVector.
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.
virtual ~MultiVector()=default
Destructor (virtual for memory safety of derived classes).
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.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subViewNonConst(const Teuchos::Range1D &colRng)
Return a MultiVector with views of selected columns.
virtual size_t constantNumberOfPackets() const
Number of packets to send per LID.
bool need_sync_host() const
Whether this MultiVector needs synchronization to the host.
void modify_device()
Mark data as modified on the device side.
typename map_type::global_ordinal_type global_ordinal_type
The type of global indices that this class uses.
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.
typename Kokkos::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
Abstract base class for objects that can be the source of an Import or Export operation.
Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
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)
Swap contents of mv with contents of *this.
LO local_ordinal_type
The type of local indices.
void randomize()
Set all values in the multivector to pseudorandom numbers.
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.
Teuchos::ArrayRCP< T > getSubArrayRCP(Teuchos::ArrayRCP< T > arr, size_t j) const
Persisting view of j-th column in the given ArrayRCP.
Forward declaration of Tpetra::Vector.
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_host()
Mark data as modified on the host side.
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.
MultiVector()
Default constructor: makes a MultiVector with no rows or columns.
Forward declaration of Tpetra::FEMultiVector.
Scalar scalar_type
The type of each entry in the MultiVector.
void replaceLocalValue(const LocalOrdinal lclRow, const size_t col, const impl_scalar_type &value) const
Replace value in host memory, using local (row) index.
typename Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
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.
A parallel distribution of indices over processes.
size_t getStride() const
Stride between columns in the multivector.
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.
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.
typename map_type::local_ordinal_type local_ordinal_type
The type of local indices that this class uses.
virtual bool checkSizes(const SrcDistObject &sourceObj)
Whether data redistribution between sourceObj and this object is legal.
typename Node::device_type device_type
This class' Kokkos::Device specialization.
dual_view_type::t_dev getLocalViewDevice() const
A local Kokkos::View of device memory.
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.
Kokkos::Device< typename device_type::execution_space, buffer_memory_space > buffer_device_type
Teuchos::DataAccess getCopyOrView() const
Get whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
Teuchos::ArrayRCP< Teuchos::ArrayRCP< const Scalar > > get2dView() const
Return const persisting pointers to values.
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,j).
Base class for distributed Tpetra objects that support data redistribution.
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.
global_size_t getGlobalLength() const
Global number of rows in the multivector.
void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise absolute values of input Multi-vector in target: A = abs(this)
Node node_type
Legacy typedef that will go away at some point.
Teuchos::ArrayRCP< const Scalar > get1dView() const
Const persisting (1-D) view of this multivector's local values.
Forward declaration of Tpetra::Map.
size_t getOrigNumLocalRows() const
"Original" number of rows in the (local) data.
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap)
Remove processes owning zero rows from the Map and their communicator.
void sync_device()
Synchronize to Device.
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.
Teuchos::Array< size_t > whichVectors_
Indices of columns this multivector is viewing.