42#ifndef TPETRA_MULTIVECTOR_DECL_HPP
43#define TPETRA_MULTIVECTOR_DECL_HPP
51#include "Tpetra_DistObject.hpp"
54#include "Kokkos_DualView.hpp"
55#include "Teuchos_BLAS_types.hpp"
56#include "Teuchos_DataAccess.hpp"
57#include "Teuchos_Range1D.hpp"
58#include "Kokkos_ArithTraits.hpp"
59#include "Kokkos_InnerProductSpaceTraits.hpp"
60#include "Tpetra_KokkosRefactor_Details_MultiVectorLocalDeepCopy.hpp"
61#include "Tpetra_Access.hpp"
64#ifdef HAVE_TPETRACORE_TEUCHOSNUMERICS
65#ifndef DOXYGEN_SHOULD_SKIP_THIS
67 template<
class OrdinalType,
class ScalarType>
68 class SerialDenseMatrix;
97 template <
class DS,
class DL,
class DG,
class DN,
98 class SS,
class SL,
class SG,
class SN>
103#ifdef HAVE_TPETRACORE_TEUCHOSNUMERICS
110 template <
class ST,
class LO,
class GO,
class NT>
113 const Teuchos::SerialDenseMatrix<int, ST>& src);
121 template <
class ST,
class LO,
class GO,
class NT>
123 deep_copy (Teuchos::SerialDenseMatrix<int, ST>& dst,
134 template <
class ST,
class LO,
class GO,
class NT>
147 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
148 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
150 const size_t numVectors);
155 template<
class SC,
class LO,
class GO,
class NT>
156 Teuchos::ArrayView<const size_t>
378 template <
class Scalar,
383 public DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>
407 typename Kokkos::Details::ArithTraits<Scalar>::val_type;
426 typename Kokkos::Details::InnerProductSpaceTraits<impl_scalar_type>::dot_type;
434 using mag_type =
typename Kokkos::ArithTraits<impl_scalar_type>::mag_type;
481 MultiVector (
const Teuchos::RCP<const map_type>& map,
482 const size_t numVecs,
483 const bool zeroOut =
true);
496 const Teuchos::DataAccess copyOrView);
513 MultiVector (
const Teuchos::RCP<const map_type>& map,
514 const Teuchos::ArrayView<const Scalar>& A,
516 const size_t NumVectors);
531 MultiVector (
const Teuchos::RCP<const map_type>& map,
532 const Teuchos::ArrayView<
const Teuchos::ArrayView<const Scalar> >&ArrayOfPtrs,
533 const size_t NumVectors);
547 MultiVector (
const Teuchos::RCP<const map_type>& map,
588 MultiVector (
const Teuchos::RCP<const map_type>& map,
589 const typename dual_view_type::t_dev& d_view);
613 MultiVector (
const Teuchos::RCP<const map_type>& map,
645 MultiVector (
const Teuchos::RCP<const map_type>& map,
647 const Teuchos::ArrayView<const size_t>& whichVectors);
676 MultiVector (
const Teuchos::RCP<const map_type>& map,
679 const Teuchos::ArrayView<const size_t>& whichVectors);
742 const Teuchos::RCP<const map_type>& subMap,
753 const size_t offset = 0);
804#ifdef KOKKOS_ENABLE_SERIAL
805 ! std::is_same<execution_space, Kokkos::Serial>::value;
878 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
945 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1021 template<
typename T>
1022 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1086 template<
typename T>
1087 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1107 template<
typename T>
1108 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1141 void randomize (
const Scalar& minVal,
const Scalar& maxVal);
1208 void replaceMap (
const Teuchos::RCP<const map_type>& map);
1248 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1249 subCopy (
const Teuchos::Range1D& colRng)
const;
1252 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1253 subCopy (
const Teuchos::ArrayView<const size_t>& cols)
const;
1256 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1257 subView (
const Teuchos::Range1D& colRng)
const;
1260 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1261 subView (
const Teuchos::ArrayView<const size_t>& cols)
const;
1264 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1268 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1333 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1334 offsetView (
const Teuchos::RCP<const map_type>& subMap,
1335 const size_t offset)
const;
1354 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1356 const size_t offset);
1359 Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1363 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1367 Teuchos::ArrayRCP<const Scalar>
getData (
size_t j)
const;
1380 get1dCopy (
const Teuchos::ArrayView<Scalar>& A,
1381 const size_t LDA)
const;
1390 get2dCopy (
const Teuchos::ArrayView<
const Teuchos::ArrayView<Scalar> >& ArrayOfPtrs)
const;
1397 Teuchos::ArrayRCP<const Scalar>
get1dView ()
const;
1400 Teuchos::ArrayRCP<Teuchos::ArrayRCP<const Scalar> >
get2dView ()
const;
1414 typename dual_view_type::t_host::const_type
getLocalViewHost(Access::ReadOnlyStruct)
const;
1422 typename dual_view_type::t_host
getLocalViewHost(Access::OverwriteAllStruct);
1426 typename dual_view_type::t_dev::const_type
getLocalViewDevice(Access::ReadOnlyStruct)
const;
1436#ifdef TPETRA_ENABLE_DEPRECATED_CODE
1439 void clear_sync_state ();
1459 template<
class TargetDeviceType>
1462 view_.template sync<TargetDeviceType> ();
1471 void sync_device ();
1475 template<
class TargetDeviceType>
1477 return view_.template need_sync<TargetDeviceType> ();
1486#ifdef TPETRA_ENABLE_DEPRECATED_CODE
1493 template<
class TargetDeviceType>
1496 view_.template modify<TargetDeviceType> ();
1501 void modify_device ();
1505 void modify_host ();
1536 template<
class TargetDeviceType>
1537 typename std::remove_reference<decltype(std::declval<dual_view_type>().template view<TargetDeviceType>())>::type::const_type
1540 bool returnDevice =
true;
1542 auto tmp =
view_.template view<TargetDeviceType>();
1543 if (tmp == this->
view_.view_host()) returnDevice =
false;
1550 const char msg[] =
"Tpetra::MultiVector: Cannot access data on "
1551 " device while a host view is alive";
1553 std::cout <<
"Rank " << this->
getMap()->getComm()->getRank()
1554 <<
": " << msg << std::endl;
1556 throw std::runtime_error(msg);
1565 const char msg[] =
"Tpetra::MultiVector: Cannot access data on "
1566 " host while a device view is alive";
1568 std::cout <<
"Rank " << this->
getMap()->getComm()->getRank()
1569 <<
": " << msg << std::endl;
1571 throw std::runtime_error(msg);
1575 return view_.template view<TargetDeviceType>();
1578 template<
class TargetDeviceType>
1579 typename std::remove_reference<decltype(std::declval<dual_view_type>().template view<TargetDeviceType>())>::type
1582 bool returnDevice =
true;
1584 auto tmp =
view_.template view<TargetDeviceType>();
1585 if (tmp == this->
view_.view_host()) returnDevice =
false;
1592 const char msg[] =
"Tpetra::MultiVector: Cannot access data on "
1593 " device while a host view is alive";
1595 std::cout <<
"Rank " << this->
getMap()->getComm()->getRank()
1596 <<
": " << msg << std::endl;
1598 throw std::runtime_error(msg);
1608 const char msg[] =
"Tpetra::MultiVector: Cannot access data on "
1609 " host while a device view is alive";
1611 std::cout <<
"Rank " << this->
getMap()->getComm()->getRank()
1612 <<
": " << msg << std::endl;
1614 throw std::runtime_error(msg);
1619 return view_.template view<TargetDeviceType>();
1622 template<
class TargetDeviceType>
1623 typename std::remove_reference<decltype(std::declval<dual_view_type>().template view<TargetDeviceType>())>::type
1628 return getLocalView<TargetDeviceType>(Access::ReadWrite);
1630 bool returnDevice =
true;
1632 auto tmp =
view_.template view<TargetDeviceType>();
1633 if (tmp == this->
view_.view_host()) returnDevice =
false;
1640 const char msg[] =
"Tpetra::MultiVector: Cannot access data on "
1641 " device while a host view is alive";
1643 std::cout <<
"Rank " << this->
getMap()->getComm()->getRank()
1644 <<
": " << msg << std::endl;
1646 throw std::runtime_error(msg);
1656 const char msg[] =
"Tpetra::MultiVector: Cannot access data on "
1657 " host while a device view is alive";
1659 std::cout <<
"Rank " << this->
getMap()->getComm()->getRank()
1660 <<
": " << msg << std::endl;
1662 throw std::runtime_error(msg);
1667 return view_.template view<TargetDeviceType>();
1671#ifdef TPETRA_ENABLE_DEPRECATED_CODE
1702 template<
class TargetDeviceType>
1704 typename std::remove_reference<decltype(std::declval<dual_view_type>().template view<TargetDeviceType>())>::type
1707 return view_.template view<TargetDeviceType>();
1737 dot (
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
1738 const Teuchos::ArrayView<dot_type>& dots)
const;
1751 template <
typename T>
1752 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1754 const Teuchos::ArrayView<T> &dots)
const
1756 const size_t sz =
static_cast<size_t> (dots.size ());
1757 Teuchos::Array<dot_type> dts (sz);
1759 for (
size_t i = 0; i < sz; ++i) {
1766 template <
typename T>
1767 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1769 std::vector<T>& dots)
const
1771 const size_t sz = dots.size ();
1772 Teuchos::Array<dot_type> dts (sz);
1774 for (
size_t i = 0; i < sz; ++i) {
1799 const Kokkos::View<dot_type*, Kokkos::HostSpace>& norms)
const;
1801 template<
class ViewType>
1803 dot (
typename std::enable_if<std::is_same<typename ViewType::value_type,dot_type>::value &&
1804 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value,
1806 const ViewType& dots)
const {
1807 const Kokkos::View<dot_type*, Kokkos::HostSpace> h_dots(
"Tpetra::Dots",dots.extent(0));
1808 this->
dot (A, h_dots);
1824 template <
typename T>
1825 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1827 const Kokkos::View<T*, device_type>& dots)
const
1829 const size_t numDots = dots.extent (0);
1830 Kokkos::View<dot_type*, device_type> dts (
"MV::dot tmp", numDots);
1856 void scale (
const Scalar& alpha);
1866 void scale (
const Teuchos::ArrayView<const Scalar>& alpha);
1876 void scale (
const Kokkos::View<const impl_scalar_type*, device_type>& alpha);
1887 scale (
const Scalar& alpha,
1897 update (
const Scalar& alpha,
1899 const Scalar& beta);
1908 update (
const Scalar& alpha,
1912 const Scalar& gamma);
1926 norm1 (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1928 template<
class ViewType>
1929 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1930 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1931 norm1 (
const ViewType& norms)
const {
1935 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1936 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
1937 this->
norm1 (h_norms);
1956 template <
typename T>
1957 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1958 norm1 (
const Kokkos::View<T*, device_type>& norms)
const
1960 const size_t numNorms = norms.extent (0);
1961 Kokkos::View<mag_type*, device_type> tmpNorms (
"MV::norm1 tmp", numNorms);
1963 this->
norm1 (tmpNorms);
1975 void norm1 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1991 template <
typename T>
1992 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1993 norm1 (
const Teuchos::ArrayView<T>& norms)
const
1995 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1996 const size_type sz = norms.size ();
1997 Teuchos::Array<mag_type> theNorms (sz);
1998 this->
norm1 (theNorms);
1999 for (size_type i = 0; i < sz; ++i) {
2001 norms[i] = theNorms[i];
2018 norm2 (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
2020 template<
class ViewType>
2021 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
2022 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
2023 norm2 (
const ViewType& norms)
const {
2027 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
2028 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
2029 this->
norm2 (h_norms);
2046 template<
typename T>
2047 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
2048 norm2 (
const Kokkos::View<T*, device_type>& norms)
const
2050 const size_t numNorms = norms.extent (0);
2051 Kokkos::View<mag_type*, device_type> theNorms (
"MV::norm2 tmp", numNorms);
2053 this->
norm2 (theNorms);
2065 void norm2 (
const Teuchos::ArrayView<mag_type>& norms)
const;
2081 template <
typename T>
2082 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
2083 norm2 (
const Teuchos::ArrayView<T>& norms)
const
2085 typedef typename Teuchos::ArrayView<T>::size_type size_type;
2086 const size_type sz = norms.size ();
2087 Teuchos::Array<mag_type> theNorms (sz);
2088 this->
norm2 (theNorms);
2089 for (size_type i = 0; i < sz; ++i) {
2091 norms[i] = theNorms[i];
2101 void normInf (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
2103 template<
class ViewType>
2104 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
2105 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
2106 normInf (
const ViewType& norms)
const {
2110 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
2111 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
2129 template<
typename T>
2130 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
2131 normInf (
const Kokkos::View<T*, device_type>& norms)
const
2133 const size_t numNorms = norms.extent (0);
2134 Kokkos::View<mag_type*, device_type> theNorms (
"MV::normInf tmp", numNorms);
2149 void normInf (
const Teuchos::ArrayView<mag_type>& norms)
const;
2166 template <
typename T>
2167 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
2168 normInf (
const Teuchos::ArrayView<T>& norms)
const
2170 typedef typename Teuchos::ArrayView<T>::size_type size_type;
2171 const size_type sz = norms.size ();
2172 Teuchos::Array<mag_type> theNorms (sz);
2173 this->
norm2 (theNorms);
2174 for (size_type i = 0; i < sz; ++i) {
2176 norms[i] = theNorms[i];
2185 void meanValue (
const Teuchos::ArrayView<impl_scalar_type>& means)
const;
2187 template <
typename T>
2188 typename std::enable_if<! std::is_same<impl_scalar_type, T>::value,
void>::type
2189 meanValue (
const Teuchos::ArrayView<T>& means)
const
2191 typedef typename Teuchos::Array<T>::size_type size_type;
2192 const size_type numMeans = means.size ();
2194 Teuchos::Array<impl_scalar_type> theMeans (numMeans);
2196 for (size_type k = 0; k < numMeans; ++k) {
2197 means[k] =
static_cast<T
> (theMeans[k]);
2208 Teuchos::ETransp transB,
2209 const Scalar& alpha,
2210 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
2211 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
2212 const Scalar& beta);
2236 const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
2237 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
2267 bool aliases(
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& other)
const;
2306 describe (Teuchos::FancyOStream& out,
2307 const Teuchos::EVerbosityLevel verbLevel =
2308 Teuchos::Describable::verbLevel_default)
const;
2338 TEUCHOS_TEST_FOR_EXCEPTION(
2339 copyOrView == Teuchos::Copy, std::invalid_argument,
2340 "Tpetra::MultiVector::setCopyOrView: The Kokkos refactor version of "
2341 "MultiVector _only_ implements view semantics. You may not call this "
2342 "method with copyOrView = Teuchos::Copy. The only valid argument is "
2355 return Teuchos::View;
2378 Teuchos::RCP<MultiVector<T, LocalOrdinal, GlobalOrdinal, Node> >
2398 template <
class DS,
class DL,
class DG,
class DN,
2399 class SS,
class SL,
class SG,
class SN>
2461 template<
class SC,
class LO,
class GO,
class NT>
2462 friend ::Teuchos::ArrayView<const size_t> getMultiVectorWhichVectors (const ::Tpetra::MultiVector<SC, LO, GO, NT>& X);
2501 const std::string& className,
2502 const Teuchos::EVerbosityLevel verbLevel =
2503 Teuchos::Describable::verbLevel_default)
const;
2506 bool vectorIndexOutOfRange (
const size_t VectorIndex)
const;
2513 Teuchos::ArrayRCP<T>
2549 const size_t numSameIDs,
2550 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
2551 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs,
2557 const Kokkos::DualView<
2566 size_t& constantNumPackets);
2570 (
const Kokkos::DualView<
2579 const size_t constantNumPackets,
2586 template<
class NO=Node>
2587 typename std::enable_if<std::is_same<typename Tpetra::Details::DefaultTypes::CommBufferMemorySpace<typename NO::execution_space>::type,
2588 typename NO::device_type::memory_space>::value,
bool>::type
2589 reallocImportsIfNeededImpl (
const size_t newSize,
2591 const std::string* prefix,
2592 const bool areRemoteLIDsContiguous,
2597 template<
class NO=Node>
2598 typename std::enable_if<!std::is_same<typename Tpetra::Details::DefaultTypes::CommBufferMemorySpace<typename NO::execution_space>::type,
2599 typename NO::device_type::memory_space>::value,
bool>::type
2600 reallocImportsIfNeededImpl (
const size_t newSize,
2602 const std::string* prefix,
2603 const bool areRemoteLIDsContiguous,
2610 const std::string* prefix,
2611 const bool areRemoteLIDsContiguous=
false,
2616 bool importsAreAliased();
2619 Kokkos::DualView<impl_scalar_type*, buffer_device_type> unaliased_imports_;
2624 template<
class SC,
class LO,
class GO,
class NT>
2625 Teuchos::ArrayView<const size_t>
2634 template <
class ST,
class LO,
class GO,
class NT>
2646 template <
class DS,
class DL,
class DG,
class DN,
2647 class SS,
class SL,
class SG,
class SN>
2652 using ::Tpetra::getMultiVectorWhichVectors;
2654 TEUCHOS_TEST_FOR_EXCEPTION(
2657 "Tpetra::deep_copy: Global dimensions of the two Tpetra::MultiVector "
2658 "objects do not match. src has dimensions [" << src.
getGlobalLength ()
2659 <<
"," << src.
getNumVectors () <<
"], and dst has dimensions ["
2663 TEUCHOS_TEST_FOR_EXCEPTION(
2665 "Tpetra::deep_copy: The local row counts of the two Tpetra::MultiVector "
2666 "objects do not match. src has " << src.
getLocalLength () <<
" row(s) "
2672 if (srcMostUpToDateOnDevice) {
2684 auto dstWhichVecs = getMultiVectorWhichVectors (dst);
2685 auto srcWhichVecs = getMultiVectorWhichVectors (src);
2687 if (srcMostUpToDateOnDevice) {
2712 template<
class SC,
class LO,
class GO,
class NT>
2713 class TypeNameTraits<
Tpetra::MultiVector<SC, LO, GO, NT> > {
2715 static std::string name () {
2716 return std::string (
"Tpetra::MultiVector<") +
2717 TypeNameTraits<SC>::name () +
"," +
2718 TypeNameTraits<LO>::name () +
"," +
2719 TypeNameTraits<GO>::name () +
"," +
2720 TypeNameTraits<NT>::name () +
">";
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.
Forward declaration of Tpetra::FEMultiVector.
Forward declaration of Tpetra::Map.
Forward declaration of Tpetra::MultiVector.
Forward declaration of Tpetra::Vector.
static bool debug()
Whether Tpetra is in debug mode.
Base class for distributed Tpetra objects that support data redistribution.
virtual Teuchos::RCP< const map_type > getMap() const
The Map describing the parallel distribution of this object.
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.
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.
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.
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.
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)
Like the above replaceGlobalValue, but only enabled if T differs from impl_scalar_type.
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.
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.
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).
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & operator=(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy assigment (shallow 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).
bool need_sync_device() const
Whether this MultiVector needs synchronization to the device.
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, const CombineMode CM)
Perform copies and permutations that are local to the calling (MPI) process.
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 replaceLocalValue(const LocalOrdinal lclRow, const size_t col, const impl_scalar_type &value)
Replace value in host memory, using local (row) index.
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.
void swap(MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &mv)
Swap contents of mv with contents of *this.
size_t getLocalLength() const
Local number of rows on the calling process.
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)
Like the above sumIntoGlobalValue, but only enabled if T differs from impl_scalar_type.
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.
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 replaceGlobalValue(const GlobalOrdinal gblRow, const size_t col, const impl_scalar_type &value)
Replace value in host memory, using global row index.
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutLeft, device_type > dual_view_type
Kokkos::DualView specialization used by this class.
virtual bool reallocImportsIfNeeded(const size_t newSize, const bool verbose, const std::string *prefix, const bool areRemoteLIDsContiguous=false, const CombineMode CM=INSERT)
Reallocate imports_ if needed.
typename map_type::device_type device_type
This class' preferred Kokkos device type.
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 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.
dual_view_type owningView_
The true original DualView - it owns the memory of this MultiVector, and was not constructed as a sub...
void sumIntoLocalValue(const LocalOrdinal lclRow, const size_t col, const impl_scalar_type &val, const bool atomic=useAtomicUpdatesByDefault)
Update (+=) a value in host memory, using local row index.
std::remove_reference< decltype(std::declval< dual_view_type >().templateview< TargetDeviceType >())>::type::const_type getLocalView(Access::ReadOnlyStruct) const
Return a view of the local data on a specific device, with the given access mode. The return type is ...
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.
Teuchos::RCP< MultiVector< T, LocalOrdinal, GlobalOrdinal, Node > > convert() const
Return another MultiVector with the same entries, but converted to a different Scalar type T.
MultiVector()
Default constructor: makes a MultiVector with no rows or columns.
dual_view_type::t_dev::const_type getLocalViewDevice(Access::ReadOnlyStruct) const
Return a read-only, up-to-date view of this MultiVector's local data on device. This requires that th...
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 get2dCopy(const Teuchos::ArrayView< const Teuchos::ArrayView< Scalar > > &ArrayOfPtrs) const
Fill the given array with a copy of this multivector's local values.
void sumIntoGlobalValue(const GlobalOrdinal gblRow, const size_t col, const impl_scalar_type &value, const bool atomic=useAtomicUpdatesByDefault)
Update (+=) a value in host memory, using global row index.
bool aliases(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &other) const
Whether this multivector's memory might alias other. This is conservative: if either this or other is...
dual_view_type::t_host::const_type getLocalViewHost(Access::ReadOnlyStruct) const
Return a read-only, up-to-date view of this MultiVector's local data on host. This requires that ther...
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.
typename Kokkos::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
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 replaceLocalValue(const LocalOrdinal lclRow, const size_t col, const T &val)
Like the above replaceLocalValue, 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.
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)
Like the above sumIntoLocalValue, but only enabled if T differs from impl_scalar_type.
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).
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.
void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)
Update: this = beta*this + alpha*A.
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.
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.
@ INSERT
Insert new values that don't currently exist.