10 #ifndef TPETRA_MULTIVECTOR_DECL_HPP
11 #define TPETRA_MULTIVECTOR_DECL_HPP
19 #include "Tpetra_DistObject.hpp"
22 #include "Kokkos_DualView.hpp"
23 #include "Teuchos_BLAS_types.hpp"
24 #include "Teuchos_DataAccess.hpp"
25 #include "Teuchos_Range1D.hpp"
26 #if KOKKOS_VERSION >= 40799
27 #include "KokkosKernels_ArithTraits.hpp"
29 #include "Kokkos_ArithTraits.hpp"
31 #include "Kokkos_InnerProductSpaceTraits.hpp"
32 #include "Tpetra_KokkosRefactor_Details_MultiVectorLocalDeepCopy.hpp"
33 #include "Tpetra_Access.hpp"
34 #include "Tpetra_Details_WrappedDualView.hpp"
35 #include <type_traits>
37 #ifdef HAVE_TPETRACORE_TEUCHOSNUMERICS
38 #ifndef DOXYGEN_SHOULD_SKIP_THIS
40 template <
class OrdinalType,
class ScalarType>
41 class SerialDenseMatrix;
43 #endif // DOXYGEN_SHOULD_SKIP_THIS
44 #endif // HAVE_TPETRACORE_TEUCHOSNUMERICS
68 template <
class DS,
class DL,
class DG,
class DN,
69 class SS,
class SL,
class SG,
class SN>
70 void deep_copy(MultiVector<DS, DL, DG, DN>& dst,
71 const MultiVector<SS, SL, SG, SN>& src);
73 #ifdef HAVE_TPETRACORE_TEUCHOSNUMERICS
74 template <
class ST,
class LO,
class GO,
class NT>
81 void deep_copy(MultiVector<ST, LO, GO, NT>& dst,
82 const Teuchos::SerialDenseMatrix<int, ST>& src);
90 template <
class ST,
class LO,
class GO,
class NT>
91 void deep_copy(Teuchos::SerialDenseMatrix<int, ST>& dst,
92 const MultiVector<ST, LO, GO, NT>& src);
93 #endif // HAVE_TPETRACORE_TEUCHOSNUMERICS
102 template <
class ST,
class LO,
class GO,
class NT>
103 MultiVector<ST, LO, GO, NT>
104 createCopy(
const MultiVector<ST, LO, GO, NT>& src);
115 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
116 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
117 createMultiVector(
const Teuchos::RCP<
const Map<LocalOrdinal, GlobalOrdinal, Node>>& map,
118 const size_t numVectors);
123 template <
class SC,
class LO,
class GO,
class NT>
124 Teuchos::ArrayView<const size_t>
125 getMultiVectorWhichVectors(
const MultiVector<SC, LO, GO, NT>& X);
346 template <
class Scalar,
350 class MultiVector :
public DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
373 #if KOKKOS_VERSION >= 40799
374 typename KokkosKernels::ArithTraits<Scalar>::val_type;
376 typename Kokkos::ArithTraits<Scalar>::val_type;
396 typename Kokkos::Details::InnerProductSpaceTraits<impl_scalar_type>::dot_type;
404 #if KOKKOS_VERSION >= 40799
405 using mag_type =
typename KokkosKernels::ArithTraits<impl_scalar_type>::mag_type;
407 using mag_type =
typename Kokkos::ArithTraits<impl_scalar_type>::mag_type;
443 using host_view_type =
typename dual_view_type::t_host;
444 using device_view_type =
typename dual_view_type::t_dev;
459 MultiVector(
const Teuchos::RCP<const map_type>& map,
460 const size_t numVecs,
461 const bool zeroOut =
true);
474 const Teuchos::DataAccess copyOrView);
491 MultiVector(
const Teuchos::RCP<const map_type>& map,
492 const Teuchos::ArrayView<const Scalar>& A,
494 const size_t NumVectors);
509 MultiVector(
const Teuchos::RCP<const map_type>& map,
510 const Teuchos::ArrayView<
const Teuchos::ArrayView<const Scalar>>& ArrayOfPtrs,
511 const size_t NumVectors);
525 MultiVector(
const Teuchos::RCP<const map_type>& map,
566 MultiVector(
const Teuchos::RCP<const map_type>& map,
567 const typename dual_view_type::t_dev& d_view);
591 MultiVector(
const Teuchos::RCP<const map_type>& map,
603 MultiVector(
const Teuchos::RCP<const map_type>& map,
632 MultiVector(
const Teuchos::RCP<const map_type>& map,
634 const Teuchos::ArrayView<const size_t>& whichVectors);
653 MultiVector(
const Teuchos::RCP<const map_type>& map,
655 const Teuchos::ArrayView<const size_t>& whichVectors);
684 MultiVector(
const Teuchos::RCP<const map_type>& map,
687 const Teuchos::ArrayView<const size_t>& whichVectors);
750 const Teuchos::RCP<const map_type>& subMap,
761 const size_t offset = 0);
812 #ifdef KOKKOS_ENABLE_SERIAL
813 !std::is_same<execution_space, Kokkos::Serial>::value;
816 #endif // KOKKOS_ENABLE_SERIAL
885 template <
typename T>
886 typename std::enable_if<!std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
951 template <
typename T>
952 typename std::enable_if<!std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1027 template <
typename T>
1028 typename std::enable_if<!std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1091 template <
typename T>
1092 typename std::enable_if<!std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1111 template <
typename T>
1112 typename std::enable_if<!std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1114 putScalar(static_cast<impl_scalar_type>(value));
1144 void randomize(
const Scalar& minVal,
const Scalar& maxVal);
1211 void replaceMap(
const Teuchos::RCP<const map_type>& map);
1251 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1252 subCopy(
const Teuchos::Range1D& colRng)
const;
1255 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1256 subCopy(
const Teuchos::ArrayView<const size_t>& cols)
const;
1259 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1260 subView(
const Teuchos::Range1D& colRng)
const;
1263 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1264 subView(
const Teuchos::ArrayView<const size_t>& cols)
const;
1267 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1271 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1336 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1337 offsetView(
const Teuchos::RCP<const map_type>& subMap,
1338 const size_t offset)
const;
1357 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1359 const size_t offset);
1362 Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1366 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1370 Teuchos::ArrayRCP<const Scalar>
getData(
size_t j)
const;
1383 get1dCopy(
const Teuchos::ArrayView<Scalar>& A,
1384 const size_t LDA)
const;
1393 get2dCopy(
const Teuchos::ArrayView<
const Teuchos::ArrayView<Scalar>>& ArrayOfPtrs)
const;
1400 Teuchos::ArrayRCP<const Scalar>
get1dView()
const;
1403 Teuchos::ArrayRCP<Teuchos::ArrayRCP<const Scalar>>
get2dView()
const;
1417 typename dual_view_type::t_host::const_type
getLocalViewHost(Access::ReadOnlyStruct)
const;
1425 typename dual_view_type::t_host
getLocalViewHost(Access::OverwriteAllStruct);
1429 typename dual_view_type::t_dev::const_type
getLocalViewDevice(Access::ReadOnlyStruct)
const;
1446 template <
class TargetDeviceType>
1448 return view_.getDualView().template need_sync<TargetDeviceType>();
1485 template <
class TargetDeviceType>
1486 typename std::remove_reference<decltype(std::declval<dual_view_type>().
template view<TargetDeviceType>())>::type::const_type
1488 return view_.template getView<TargetDeviceType>(s);
1491 template <
class TargetDeviceType>
1492 typename std::remove_reference<decltype(std::declval<dual_view_type>().
template view<TargetDeviceType>())>::type
1494 return view_.template getView<TargetDeviceType>(s);
1497 template <
class TargetDeviceType>
1498 typename std::remove_reference<decltype(std::declval<dual_view_type>().
template view<TargetDeviceType>())>::type
1500 return view_.template getView<TargetDeviceType>(s);
1521 dot(
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
1522 const Teuchos::ArrayView<dot_type>& dots)
const;
1535 template <
typename T>
1536 typename std::enable_if<!(std::is_same<dot_type, T>::value),
void>::type
1538 const Teuchos::ArrayView<T>& dots)
const {
1539 const size_t sz =
static_cast<size_t>(dots.size());
1540 Teuchos::Array<dot_type> dts(sz);
1542 for (
size_t i = 0; i < sz; ++i) {
1549 template <
typename T>
1550 typename std::enable_if<!(std::is_same<dot_type, T>::value),
void>::type
1552 std::vector<T>& dots)
const {
1553 const size_t sz = dots.size();
1554 Teuchos::Array<dot_type> dts(sz);
1556 for (
size_t i = 0; i < sz; ++i) {
1581 const Kokkos::View<dot_type*, Kokkos::HostSpace>& norms)
const;
1583 template <
class ViewType>
1585 dot(
typename std::enable_if<std::is_same<typename ViewType::value_type, dot_type>::value &&
1586 std::is_same<typename ViewType::memory_space, typename device_type::memory_space>::value,
1588 const ViewType& dots)
const {
1589 const Kokkos::View<dot_type*, Kokkos::HostSpace> h_dots(
"Tpetra::Dots", dots.extent(0));
1590 this->
dot(A, h_dots);
1607 template <
typename T>
1608 typename std::enable_if<!(std::is_same<dot_type, T>::value),
void>::type
1610 const Kokkos::View<T*, device_type>& dots)
const {
1611 const size_t numDots = dots.extent(0);
1612 Kokkos::View<dot_type*, device_type> dts(
"MV::dot tmp", numDots);
1639 void scale(
const Scalar& alpha);
1649 void scale(
const Teuchos::ArrayView<const Scalar>& alpha);
1659 void scale(
const Kokkos::View<const impl_scalar_type*, device_type>& alpha);
1670 scale(
const Scalar& alpha,
1680 update(
const Scalar& alpha,
1682 const Scalar& beta);
1691 update(
const Scalar& alpha,
1695 const Scalar& gamma);
1709 norm1(
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1711 template <
class ViewType>
1712 typename std::enable_if<std::is_same<typename ViewType::value_type, mag_type>::value &&
1713 std::is_same<typename ViewType::memory_space, typename device_type::memory_space>::value>::type
1714 norm1(
const ViewType& norms)
const {
1718 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1719 host_norms_view_type h_norms(
"Tpetra::MV::h_norms", norms.extent(0));
1720 this->
norm1(h_norms);
1740 template <
typename T>
1741 typename std::enable_if<!(std::is_same<mag_type, T>::value),
void>::type
1742 norm1(
const Kokkos::View<T*, device_type>& norms)
const {
1743 const size_t numNorms = norms.extent(0);
1744 Kokkos::View<mag_type*, device_type> tmpNorms(
"MV::norm1 tmp", numNorms);
1746 this->
norm1(tmpNorms);
1759 void norm1(
const Teuchos::ArrayView<mag_type>& norms)
const;
1775 template <
typename T>
1776 typename std::enable_if<!(std::is_same<mag_type, T>::value),
void>::type
1777 norm1(
const Teuchos::ArrayView<T>& norms)
const {
1778 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1779 const size_type sz = norms.size();
1780 Teuchos::Array<mag_type> theNorms(sz);
1781 this->
norm1(theNorms);
1782 for (size_type i = 0; i < sz; ++i) {
1784 norms[i] = theNorms[i];
1801 norm2(
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1803 template <
class ViewType>
1804 typename std::enable_if<std::is_same<typename ViewType::value_type, mag_type>::value &&
1805 std::is_same<typename ViewType::memory_space, typename device_type::memory_space>::value>::type
1806 norm2(
const ViewType& norms)
const {
1810 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1811 host_norms_view_type h_norms(
"Tpetra::MV::h_norms", norms.extent(0));
1812 this->
norm2(h_norms);
1830 template <
typename T>
1831 typename std::enable_if<!(std::is_same<mag_type, T>::value),
void>::type
1832 norm2(
const Kokkos::View<T*, device_type>& norms)
const {
1833 const size_t numNorms = norms.extent(0);
1834 Kokkos::View<mag_type*, device_type> theNorms(
"MV::norm2 tmp", numNorms);
1836 this->
norm2(theNorms);
1849 void norm2(
const Teuchos::ArrayView<mag_type>& norms)
const;
1865 template <
typename T>
1866 typename std::enable_if<!(std::is_same<mag_type, T>::value),
void>::type
1867 norm2(
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->
norm2(theNorms);
1872 for (size_type i = 0; i < sz; ++i) {
1874 norms[i] = theNorms[i];
1884 void normInf(
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1886 template <
class ViewType>
1887 typename std::enable_if<std::is_same<typename ViewType::value_type, mag_type>::value &&
1888 std::is_same<typename ViewType::memory_space, typename device_type::memory_space>::value>::type
1889 normInf(
const ViewType& norms)
const {
1893 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1894 host_norms_view_type h_norms(
"Tpetra::MV::h_norms", norms.extent(0));
1913 template <
typename T>
1914 typename std::enable_if<!(std::is_same<mag_type, T>::value),
void>::type
1915 normInf(
const Kokkos::View<T*, device_type>& norms)
const {
1916 const size_t numNorms = norms.extent(0);
1917 Kokkos::View<mag_type*, device_type> theNorms(
"MV::normInf tmp", numNorms);
1933 void normInf(
const Teuchos::ArrayView<mag_type>& norms)
const;
1950 template <
typename T>
1951 typename std::enable_if<!(std::is_same<mag_type, T>::value),
void>::type
1952 normInf(
const Teuchos::ArrayView<T>& norms)
const {
1953 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1954 const size_type sz = norms.size();
1955 Teuchos::Array<mag_type> theNorms(sz);
1956 this->
norm2(theNorms);
1957 for (size_type i = 0; i < sz; ++i) {
1959 norms[i] = theNorms[i];
1967 void meanValue(
const Teuchos::ArrayView<impl_scalar_type>& means)
const;
1969 template <
typename T>
1970 typename std::enable_if<!std::is_same<impl_scalar_type, T>::value,
void>::type
1971 meanValue(
const Teuchos::ArrayView<T>& means)
const {
1972 typedef typename Teuchos::Array<T>::size_type size_type;
1973 const size_type numMeans = means.size();
1975 Teuchos::Array<impl_scalar_type> theMeans(numMeans);
1977 for (size_type k = 0; k < numMeans; ++k) {
1978 means[k] =
static_cast<T
>(theMeans[k]);
1989 Teuchos::ETransp transB,
1990 const Scalar& alpha,
1991 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
1992 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
1993 const Scalar& beta);
2017 const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
2018 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
2048 bool aliases(
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& other)
const;
2087 describe(Teuchos::FancyOStream& out,
2088 const Teuchos::EVerbosityLevel verbLevel =
2089 Teuchos::Describable::verbLevel_default)
const override;
2119 TEUCHOS_TEST_FOR_EXCEPTION(
2120 copyOrView == Teuchos::Copy, std::invalid_argument,
2121 "Tpetra::MultiVector::setCopyOrView: The Kokkos refactor version of "
2122 "MultiVector _only_ implements view semantics. You may not call this "
2123 "method with copyOrView = Teuchos::Copy. The only valid argument is "
2136 return Teuchos::View;
2159 Teuchos::RCP<MultiVector<T, LocalOrdinal, GlobalOrdinal, Node>>
2178 template <
class DS,
class DL,
class DG,
class DN,
2179 class SS,
class SL,
class SG,
class SN>
2205 template <
class SC,
class LO,
class GO,
class NT>
2206 friend ::Teuchos::ArrayView<const size_t> getMultiVectorWhichVectors(const ::Tpetra::MultiVector<SC, LO, GO, NT>& X);
2245 const std::string& className,
2246 const Teuchos::EVerbosityLevel verbLevel =
2247 Teuchos::Describable::verbLevel_default)
const;
2250 bool vectorIndexOutOfRange(
const size_t VectorIndex)
const;
2257 Teuchos::ArrayRCP<T>
2290 virtual void copyAndPermute(
2292 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
2293 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs,
2296 virtual void copyAndPermute(
2298 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
2299 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs,
2304 const Kokkos::DualView<
2313 size_t& constantNumPackets,
2318 const Kokkos::DualView<
2327 size_t& constantNumPackets)
override;
2330 unpackAndCombine(
const Kokkos::DualView<
2340 const size_t constantNumPackets,
2345 unpackAndCombine(
const Kokkos::DualView<
2355 const size_t constantNumPackets,
2361 template <
class NO = Node>
2362 typename std::enable_if<std::is_same<typename Tpetra::Details::DefaultTypes::CommBufferMemorySpace<typename NO::execution_space>::type,
2363 typename NO::device_type::memory_space>::value,
2365 reallocImportsIfNeededImpl(
const size_t newSize,
2367 const std::string* prefix,
2368 const bool areRemoteLIDsContiguous,
2373 template <
class NO = Node>
2374 typename std::enable_if<!std::is_same<typename Tpetra::Details::DefaultTypes::CommBufferMemorySpace<typename NO::execution_space>::type,
2375 typename NO::device_type::memory_space>::value,
2377 reallocImportsIfNeededImpl(
const size_t newSize,
2379 const std::string* prefix,
2380 const bool areRemoteLIDsContiguous,
2387 const std::string* prefix,
2388 const bool areRemoteLIDsContiguous =
false,
2392 bool importsAreAliased();
2395 Kokkos::DualView<impl_scalar_type*, buffer_device_type> unaliased_imports_;
2400 template <
class SC,
class LO,
class GO,
class NT>
2401 Teuchos::ArrayView<const size_t>
2403 return X.whichVectors_();
2408 template <
class ST,
class LO,
class GO,
class NT>
2418 template <
class DS,
class DL,
class DG,
class DN,
2419 class SS,
class SL,
class SG,
class SN>
2422 using ::Tpetra::getMultiVectorWhichVectors;
2424 TEUCHOS_TEST_FOR_EXCEPTION(
2425 dst.getGlobalLength() != src.getGlobalLength() ||
2426 dst.getNumVectors() != src.getNumVectors(),
2427 std::invalid_argument,
2428 "Tpetra::deep_copy: Global dimensions of the two Tpetra::MultiVector "
2429 "objects do not match. src has dimensions ["
2430 << src.getGlobalLength()
2431 <<
"," << src.getNumVectors() <<
"], and dst has dimensions ["
2432 << dst.getGlobalLength() <<
"," << dst.getNumVectors() <<
"].");
2435 TEUCHOS_TEST_FOR_EXCEPTION(
2436 dst.getLocalLength() != src.getLocalLength(), std::invalid_argument,
2437 "Tpetra::deep_copy: The local row counts of the two Tpetra::MultiVector "
2438 "objects do not match. src has "
2439 << src.getLocalLength() <<
" row(s) "
2440 <<
" and dst has " << dst.getLocalLength() <<
" row(s).");
2442 const bool srcMostUpToDateOnDevice = !src.need_sync_device();
2444 if (src.isConstantStride() && dst.isConstantStride()) {
2445 if (srcMostUpToDateOnDevice) {
2447 dst.getLocalViewDevice(Access::OverwriteAll),
2448 src.getLocalViewDevice(Access::ReadOnly));
2451 dst.getLocalViewDevice(Access::OverwriteAll),
2452 src.getLocalViewHost(Access::ReadOnly));
2455 auto dstWhichVecs = getMultiVectorWhichVectors(dst);
2456 auto srcWhichVecs = getMultiVectorWhichVectors(src);
2458 if (srcMostUpToDateOnDevice) {
2460 src.getLocalViewDevice(Access::ReadOnly),
2461 dst.isConstantStride(),
2462 src.isConstantStride(),
2467 src.getLocalViewHost(Access::ReadOnly),
2468 dst.isConstantStride(),
2469 src.isConstantStride(),
2481 template <
class SC,
class LO,
class GO,
class NT>
2482 class TypeNameTraits<Tpetra::MultiVector<SC, LO, GO, NT>> {
2484 static std::string name() {
2485 return std::string(
"Tpetra::MultiVector<") +
2486 TypeNameTraits<SC>::name() +
"," +
2487 TypeNameTraits<LO>::name() +
"," +
2488 TypeNameTraits<GO>::name() +
"," +
2489 TypeNameTraits<NT>::name() +
">";
2499 #endif // TPETRA_MULTIVECTOR_DECL_HPP
typename map_type::global_ordinal_type global_ordinal_type
The type of global indices that this class uses.
Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subView(const Teuchos::Range1D &colRng) const
Return a const MultiVector with const views of selected columns.
typename map_type::local_ordinal_type local_ordinal_type
The type of local indices that this class uses.
LocalOrdinal local_ordinal_type
The type of local indices.
typename device_type::execution_space execution_space
Type of the (new) Kokkos execution space.
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.
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.
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.
void localDeepCopyConstStride(const DstViewType &dst, const SrcViewType &src)
Implementation of Tpetra::MultiVector deep copy of local data, for when both the source and destinati...
std::enable_if<!(std::is_same< mag_type, T >::value), void >::type normInf(const Teuchos::ArrayView< T > &norms) const
Compute the infinity-norm of each vector (column), storing the result in a Teuchos::ArrayView.
typename Kokkos::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
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.
virtual size_t constantNumberOfPackets() const override
Number of packets to send per LID.
Teuchos::ArrayRCP< Teuchos::ArrayRCP< Scalar > > get2dViewNonConst()
Return non-const persisting pointers to values.
bool isConstantStride() const
Whether this multivector has constant stride between columns.
typename map_type::device_type device_type
This class' preferred Kokkos device type.
std::string localDescribeToString(const Teuchos::EVerbosityLevel vl) const
Print the calling process' verbose describe() information to the returned string. ...
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subCopy(const Teuchos::Range1D &colRng) const
Return a MultiVector with copies of selected columns.
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.
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.
MultiVector< ST, LO, GO, NT > createCopy(const MultiVector< ST, LO, GO, NT > &src)
Return a deep copy of the given MultiVector.
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< mag_type, T >::value), void >::type norm2(const Kokkos::View< T *, device_type > &norms) const
Compute the two-norm of each vector (column), storing the result in a device view.
static const bool useAtomicUpdatesByDefault
Whether sumIntoLocalValue and sumIntoGlobalValue should use atomic updates by default.
std::enable_if<!(std::is_same< mag_type, T >::value), void >::type normInf(const Kokkos::View< T *, device_type > &norms) const
Compute the infinity-norm of each vector (column), storing the result in a device view...
Teuchos::Array< size_t > whichVectors_
Indices of columns this multivector is viewing.
std::remove_reference< decltype(std::declval< dual_view_type >).template view< TargetDeviceType >))>::type::const_type getLocalView(Access::ReadOnlyStruct s) const
Return a view of the local data on a specific device, with the given access mode. The return type is ...
bool need_sync_device() const
Whether this MultiVector needs synchronization to the device.
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & operator=(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy assigment (shallow copy).
bool isSameSize(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &vec) const
size_t getOrigNumLocalCols() const
"Original" number of columns in the (local) data.
typename Kokkos::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
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.
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...
Insert new values that don't currently exist.
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 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.
wrapped_dual_view_type view_
The Kokkos::DualView containing the MultiVector's data.
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).
std::string descriptionImpl(const std::string &className) const
Implementation of description() for this class, and its subclass Vector.
virtual bool reallocImportsIfNeeded(const size_t newSize, const bool verbose, const std::string *prefix, const bool areRemoteLIDsContiguous=false, const CombineMode CM=INSERT) override
Reallocate imports_ if needed.
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 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.
CombineMode
Rule for combining data in an Import or Export.
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.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const override
Print the object with the given verbosity level to a FancyOStream.
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.
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.
std::enable_if<!(std::is_same< dot_type, T >::value), void >::type dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Kokkos::View< T *, device_type > &dots) const
Compute the dot product of each corresponding pair of vectors (columns) in A and B, storing the result in a device view.
Scalar scalar_type
The type of each entry in the MultiVector.
Teuchos::RCP< MultiVector< T, LocalOrdinal, GlobalOrdinal, Node > > convert() const
Return another MultiVector with the same entries, but converted to a different Scalar type T...
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.
bool need_sync_host() const
Whether this MultiVector needs synchronization to the host.
Abstract base class for objects that can be the source of an Import or Export operation.
std::enable_if<!(std::is_same< mag_type, T >::value), void >::type norm1(const Kokkos::View< T *, device_type > &norms) const
Compute the one-norm of each vector (column), storing the result in a device view.
Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
bool need_sync() const
Whether this MultiVector needs synchronization to the given space.
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutLeft, device_type > dual_view_type
Kokkos::DualView specialization used by this class.
virtual bool checkSizes(const SrcDistObject &sourceObj) override
Whether data redistribution between sourceObj and this object is legal.
void swap(MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &mv)
Swap contents of mv with contents of *this.
void replaceGlobalValue(const GlobalOrdinal gblRow, const size_t col, const impl_scalar_type &value)
Replace value in host memory, using global row index.
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.
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...
virtual std::string description() const override
A simple one-line description of this object.
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.
typename map_type::node_type node_type
Legacy thing that you should not use any more.
MultiVector()
Default constructor: makes a MultiVector with no rows or columns.
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...
Forward declaration of Tpetra::FEMultiVector.
Teuchos::DataAccess getCopyOrView() const
Get whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
std::enable_if<!(std::is_same< mag_type, T >::value), void >::type norm2(const Teuchos::ArrayView< T > &norms) const
Compute the two-norm of each vector (column).
void setCopyOrView(const Teuchos::DataAccess copyOrView)
Set whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
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.
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap) override
Remove processes owning zero rows from the Map and their communicator.
virtual ~MultiVector()=default
Destructor (virtual for memory safety of derived classes).
size_t getStride() const
Stride between columns in the multivector.
std::enable_if<!(std::is_same< dot_type, T >::value), void >::type dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< T > &dots) const
Compute the dot product of each corresponding pair of vectors (columns) in A and B.
typename Kokkos::Details::InnerProductSpaceTraits< impl_scalar_type >::dot_type dot_type
Type of an inner ("dot") product result.
void reduce()
Sum values of a locally replicated multivector across all processes.
std::enable_if<!(std::is_same< dot_type, T >::value), void >::type dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, std::vector< T > &dots) const
Like the above dot() overload, but for std::vector output.
wrapped_dual_view_type getWrappedDualView() const
Return the wrapped dual view holding this MultiVector's local data.
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 DistObject< scalar_type, local_ordinal_type, global_ordinal_type, node_type >::buffer_device_type buffer_device_type
typename Node::device_type device_type
This class' Kokkos::Device specialization.
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.
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)
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.
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.
std::enable_if<!(std::is_same< mag_type, T >::value), void >::type norm1(const Teuchos::ArrayView< T > &norms) const
Compute the one-norm of each vector (column).
Forward declaration of Tpetra::Map.
size_t getOrigNumLocalRows() const
"Original" number of rows in the (local) data.
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.