42 #ifndef TPETRA_MULTIVECTOR_DECL_HPP 43 #define TPETRA_MULTIVECTOR_DECL_HPP 54 #include "Tpetra_DistObject.hpp" 56 #include "Kokkos_DualView.hpp" 57 #include "Teuchos_BLAS_types.hpp" 58 #include "Teuchos_DataAccess.hpp" 59 #include "Teuchos_Range1D.hpp" 60 #include "Kokkos_ArithTraits.hpp" 61 #include "Kokkos_InnerProductSpaceTraits.hpp" 62 #include "Tpetra_KokkosRefactor_Details_MultiVectorLocalDeepCopy.hpp" 63 #include <type_traits> 67 #ifndef DOXYGEN_SHOULD_SKIP_THIS 69 template<
class LO,
class GO,
class N>
class Map;
72 template<
class S,
class LO,
class GO,
class N, const
bool classic>
class Vector;
75 template<
class S,
class LO,
class GO,
class N, const
bool classic>
class MultiVector;
76 #endif // DOXYGEN_SHOULD_SKIP_THIS 104 template<
class DstMultiVectorType,
class SrcMultiVectorType>
106 typedef DstMultiVectorType dst_mv_type;
107 typedef SrcMultiVectorType src_mv_type;
109 static Teuchos::RCP<dst_mv_type>
110 clone (
const src_mv_type& X,
111 const Teuchos::RCP<typename dst_mv_type::node_type>& node2);
136 template <
class DS,
class DL,
class DG,
class DN,
const bool dstClassic,
137 class SS,
class SL,
class SG,
class SN,
const bool srcClassic>
149 template <
class ST,
class LO,
class GO,
class NT, const
bool classic = NT::
classic>
162 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node, const
bool classic = Node::
classic>
163 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
165 const size_t numVectors);
388 class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
390 const bool classic = Node::classic>
392 public DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>
394 static_assert (! classic,
"The 'classic' version of Tpetra was deprecated long ago, and has been removed.");
439 typedef typename Kokkos::Details::InnerProductSpaceTraits<impl_scalar_type>::dot_type
dot_type;
447 typedef typename Kokkos::Details::ArithTraits<impl_scalar_type>::mag_type
mag_type;
479 typedef Kokkos::DualView<impl_scalar_type**, Kokkos::LayoutLeft,
498 MultiVector (
const Teuchos::RCP<const map_type>& map,
499 const size_t numVecs,
500 const bool zeroOut =
true);
514 const Teuchos::DataAccess copyOrView);
531 MultiVector (
const Teuchos::RCP<const map_type>& map,
532 const Teuchos::ArrayView<const Scalar>& A,
534 const size_t NumVectors);
549 MultiVector (
const Teuchos::RCP<const map_type>& map,
550 const Teuchos::ArrayView<
const Teuchos::ArrayView<const Scalar> >&ArrayOfPtrs,
551 const size_t NumVectors);
565 MultiVector (
const Teuchos::RCP<const map_type>& map,
566 const dual_view_type& view);
606 MultiVector (
const Teuchos::RCP<const map_type>& map,
607 const typename dual_view_type::t_dev& d_view);
631 MultiVector (
const Teuchos::RCP<const map_type>& map,
632 const dual_view_type& view,
633 const dual_view_type& origView);
652 MultiVector (
const Teuchos::RCP<const map_type>& map,
653 const dual_view_type& view,
654 const Teuchos::ArrayView<const size_t>& whichVectors);
683 MultiVector (
const Teuchos::RCP<const map_type>& map,
684 const dual_view_type& view,
685 const dual_view_type& origView,
686 const Teuchos::ArrayView<const size_t>& whichVectors);
747 const map_type& subMap,
748 const size_t offset = 0);
758 template <
class Node2>
759 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >
760 clone (
const Teuchos::RCP<Node2>& node2)
const;
774 static const bool useAtomicUpdatesByDefault =
775 #ifdef KOKKOS_HAVE_SERIAL 776 ! std::is_same<execution_space, Kokkos::Serial>::value;
779 #endif // KOKKOS_HAVE_SERIAL 811 replaceGlobalValue (
const GlobalOrdinal gblRow,
813 const impl_scalar_type& value)
const;
848 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
851 const T& value)
const 853 replaceGlobalValue (globalRow, col, static_cast<impl_scalar_type> (value));
880 sumIntoGlobalValue (
const GlobalOrdinal gblRow,
882 const impl_scalar_type& value,
883 const bool atomic = useAtomicUpdatesByDefault)
const;
913 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
917 const bool atomic = useAtomicUpdatesByDefault)
const 919 sumIntoGlobalValue (gblRow, col, static_cast<impl_scalar_type> (val), atomic);
951 replaceLocalValue (
const LocalOrdinal lclRow,
953 const impl_scalar_type& value)
const;
988 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
993 replaceLocalValue (lclRow, col, static_cast<impl_scalar_type> (val));
1020 sumIntoLocalValue (
const LocalOrdinal lclRow,
1022 const impl_scalar_type& val,
1023 const bool atomic = useAtomicUpdatesByDefault)
const;
1050 template<
typename T>
1051 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1055 const bool atomic = useAtomicUpdatesByDefault)
const 1057 sumIntoLocalValue (lclRow, col, static_cast<impl_scalar_type> (val), atomic);
1061 void putScalar (
const Scalar& value);
1071 template<
typename T>
1072 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1075 putScalar (static_cast<impl_scalar_type> (value));
1105 void randomize (
const Scalar& minVal,
const Scalar& maxVal);
1172 void replaceMap (
const Teuchos::RCP<const map_type>& map);
1216 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1217 subCopy (
const Teuchos::Range1D& colRng)
const;
1220 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1221 subCopy (
const Teuchos::ArrayView<const size_t>& cols)
const;
1224 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1225 subView (
const Teuchos::Range1D& colRng)
const;
1228 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1229 subView (
const Teuchos::ArrayView<const size_t>& cols)
const;
1232 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1233 subViewNonConst (
const Teuchos::Range1D& colRng);
1236 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1237 subViewNonConst (
const Teuchos::ArrayView<const size_t>& cols);
1301 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1302 offsetView (
const Teuchos::RCP<const map_type>& subMap,
1303 const size_t offset)
const;
1322 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1323 offsetViewNonConst (
const Teuchos::RCP<const map_type>& subMap,
1324 const size_t offset);
1327 Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1328 getVector (
const size_t j)
const;
1331 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1332 getVectorNonConst (
const size_t j);
1335 Teuchos::ArrayRCP<const Scalar> getData (
size_t j)
const;
1338 Teuchos::ArrayRCP<Scalar> getDataNonConst (
size_t j);
1348 get1dCopy (
const Teuchos::ArrayView<Scalar>& A,
1349 const size_t LDA)
const;
1358 get2dCopy (
const Teuchos::ArrayView<
const Teuchos::ArrayView<Scalar> >& ArrayOfPtrs)
const;
1365 Teuchos::ArrayRCP<const Scalar> get1dView ()
const;
1368 Teuchos::ArrayRCP<Teuchos::ArrayRCP<const Scalar> > get2dView ()
const;
1375 Teuchos::ArrayRCP<Scalar> get1dViewNonConst ();
1378 Teuchos::ArrayRCP<Teuchos::ArrayRCP<Scalar> > get2dViewNonConst ();
1394 dual_view_type getDualView ()
const;
1414 template<
class TargetDeviceType>
1416 getDualView ().template sync<TargetDeviceType> ();
1420 template<
class TargetDeviceType>
1422 return getDualView ().template need_sync<TargetDeviceType> ();
1430 template<
class TargetDeviceType>
1432 getDualView ().template modify<TargetDeviceType> ();
1466 template<
class TargetDeviceType>
1467 typename Kokkos::Impl::if_c<
1469 typename device_type::memory_space,
1470 typename TargetDeviceType::memory_space>::value,
1471 typename dual_view_type::t_dev,
1472 typename dual_view_type::t_host>::type
1474 return getDualView ().template view<TargetDeviceType> ();
1496 const Teuchos::ArrayView<dot_type>& dots)
const;
1509 template <
typename T>
1510 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1512 const Teuchos::ArrayView<T> &dots)
const 1514 const size_t sz =
static_cast<size_t> (dots.size ());
1515 Teuchos::Array<dot_type> dts (sz);
1517 for (
size_t i = 0; i < sz; ++i) {
1524 template <
typename T>
1525 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1527 std::vector<T>& dots)
const 1529 const size_t sz = dots.size ();
1530 Teuchos::Array<dot_type> dts (sz);
1532 for (
size_t i = 0; i < sz; ++i) {
1557 const Kokkos::View<dot_type*, device_type>& dots)
const;
1571 template <
typename T>
1572 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1574 const Kokkos::View<T*, device_type>& dots)
const 1576 const size_t numDots = dots.dimension_0 ();
1577 Kokkos::View<dot_type*, device_type> dts (
"MV::dot tmp", numDots);
1602 void scale (
const Scalar& alpha);
1612 void scale (
const Teuchos::ArrayView<const Scalar>& alpha);
1622 void scale (
const Kokkos::View<const impl_scalar_type*, device_type>& alpha);
1633 scale (
const Scalar& alpha,
1643 update (
const Scalar& alpha,
1645 const Scalar& beta);
1654 update (
const Scalar& alpha,
1658 const Scalar& gamma);
1677 void norm1 (
const Kokkos::View<mag_type*, device_type>& norms)
const;
1694 template <
typename T>
1695 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1696 norm1 (
const Kokkos::View<T*, device_type>& norms)
const 1698 const size_t numNorms = norms.dimension_0 ();
1699 Kokkos::View<mag_type*, device_type> tmpNorms (
"MV::norm1 tmp", numNorms);
1701 this->norm1 (tmpNorms);
1713 void norm1 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1729 template <
typename T>
1730 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1731 norm1 (
const Teuchos::ArrayView<T>& norms)
const 1733 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1734 const size_type sz = norms.size ();
1735 Teuchos::Array<mag_type> theNorms (sz);
1736 this->norm1 (theNorms);
1737 for (size_type i = 0; i < sz; ++i) {
1739 norms[i] = theNorms[i];
1761 void norm2 (
const Kokkos::View<mag_type*, device_type>& norms)
const;
1776 template<
typename T>
1777 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1778 norm2 (
const Kokkos::View<T*, device_type>& norms)
const 1780 const size_t numNorms = norms.dimension_0 ();
1781 Kokkos::View<mag_type*, device_type> theNorms (
"MV::norm2 tmp", numNorms);
1783 this->norm2 (theNorms);
1795 void norm2 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1811 template <
typename T>
1812 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1813 norm2 (
const Teuchos::ArrayView<T>& norms)
const 1815 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1816 const size_type sz = norms.size ();
1817 Teuchos::Array<mag_type> theNorms (sz);
1818 this->norm2 (theNorms);
1819 for (size_type i = 0; i < sz; ++i) {
1821 norms[i] = theNorms[i];
1837 void normInf (
const Kokkos::View<mag_type*, device_type>& norms)
const;
1852 template<
typename T>
1853 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1854 normInf (
const Kokkos::View<T*, device_type>& norms)
const 1856 const size_t numNorms = norms.dimension_0 ();
1857 Kokkos::View<mag_type*, device_type> theNorms (
"MV::normInf tmp", numNorms);
1859 this->normInf (theNorms);
1872 void normInf (
const Teuchos::ArrayView<mag_type>& norms)
const;
1889 template <
typename T>
1890 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1891 normInf (
const Teuchos::ArrayView<T>& norms)
const 1893 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1894 const size_type sz = norms.size ();
1895 Teuchos::Array<mag_type> theNorms (sz);
1896 this->norm2 (theNorms);
1897 for (size_type i = 0; i < sz; ++i) {
1899 norms[i] = theNorms[i];
1909 void TPETRA_DEPRECATED
1911 const Teuchos::ArrayView<mag_type>& norms)
const;
1929 template <
typename T>
1930 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1933 const Teuchos::ArrayView<T>& norms)
const 1935 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1936 const size_type sz = norms.size ();
1937 Teuchos::Array<mag_type> theNorms (sz);
1938 this->normWeighted (weights, theNorms);
1939 for (size_type i = 0; i < sz; ++i) {
1941 norms[i] = theNorms[i];
1949 void meanValue (
const Teuchos::ArrayView<impl_scalar_type>& means)
const;
1951 template <
typename T>
1952 typename std::enable_if<! std::is_same<impl_scalar_type, T>::value,
void>::type
1953 meanValue (
const Teuchos::ArrayView<T>& means)
const 1955 typedef typename Teuchos::Array<T>::size_type size_type;
1956 const size_type numMeans = means.size ();
1958 Teuchos::Array<impl_scalar_type> theMeans (numMeans);
1959 this->meanValue (theMeans ());
1960 for (size_type k = 0; k < numMeans; ++k) {
1961 means[k] =
static_cast<T
> (theMeans[k]);
1971 multiply (Teuchos::ETransp transA,
1972 Teuchos::ETransp transB,
1973 const Scalar& alpha,
1976 const Scalar& beta);
1999 elementWiseMultiply (Scalar scalarAB,
2008 size_t getNumVectors()
const;
2011 size_t getLocalLength()
const;
2021 size_t getStride()
const;
2026 bool isConstantStride()
const;
2034 virtual std::string description()
const;
2065 describe (Teuchos::FancyOStream& out,
2066 const Teuchos::EVerbosityLevel verbLevel =
2067 Teuchos::Describable::verbLevel_default)
const;
2097 TEUCHOS_TEST_FOR_EXCEPTION(
2098 copyOrView == Teuchos::Copy, std::invalid_argument,
2099 "Tpetra::MultiVector::setCopyOrView: The Kokkos refactor version of " 2100 "MultiVector _only_ implements view semantics. You may not call this " 2101 "method with copyOrView = Teuchos::Copy. The only valid argument is " 2116 return Teuchos::View;
2137 template <
class DS,
class DL,
class DG,
class DN,
const bool dstClassic,
2138 class SS,
class SL,
class SG,
class SN,
const bool srcClassic>
2214 normImpl (
const Kokkos::View<mag_type*, device_type>& norms,
2228 descriptionImpl (
const std::string& className)
const;
2237 localDescribeToString (
const Teuchos::EVerbosityLevel vl)
const;
2253 describeImpl (Teuchos::FancyOStream& out,
2254 const std::string& className,
2255 const Teuchos::EVerbosityLevel verbLevel =
2256 Teuchos::Describable::verbLevel_default)
const;
2259 bool vectorIndexOutOfRange (
const size_t VectorIndex)
const;
2266 Teuchos::ArrayRCP<T>
2267 getSubArrayRCP (Teuchos::ArrayRCP<T> arr,
size_t j)
const;
2270 size_t getOrigNumLocalRows ()
const;
2273 size_t getOrigNumLocalCols ()
const;
2287 virtual size_t constantNumberOfPackets ()
const;
2294 const size_t numSameIDs,
2295 const Kokkos::DualView<const local_ordinal_type*, device_type>& permuteToLIDs,
2296 const Kokkos::DualView<const local_ordinal_type*, device_type>& permuteFromLIDs);
2300 const Kokkos::DualView<const local_ordinal_type*, device_type>& exportLIDs,
2301 Kokkos::DualView<impl_scalar_type*, device_type>& exports,
2302 const Kokkos::DualView<size_t*, device_type>& ,
2303 size_t& constantNumPackets,
2307 unpackAndCombineNew (
const Kokkos::DualView<const LocalOrdinal*, device_type>& importLIDs,
2308 const Kokkos::DualView<const impl_scalar_type*, device_type>& imports,
2309 const Kokkos::DualView<const size_t*, device_type>& ,
2310 const size_t constantNumPackets,
2318 template<
class DstMultiVectorType,
2319 class SrcMultiVectorType>
2320 Teuchos::RCP<typename MultiVectorCloner<DstMultiVectorType, SrcMultiVectorType>::dst_mv_type>
2321 MultiVectorCloner<DstMultiVectorType, SrcMultiVectorType>::
2322 clone (
const src_mv_type& X,
2323 const Teuchos::RCP<typename dst_mv_type::node_type>& node2)
2326 typedef typename src_mv_type::map_type src_map_type;
2327 typedef typename dst_mv_type::map_type dst_map_type;
2328 typedef typename dst_mv_type::node_type dst_node_type;
2329 typedef typename dst_mv_type::dual_view_type dst_dual_view_type;
2332 RCP<const src_map_type> map1 = X.getMap ();
2333 RCP<const dst_map_type> map2 = map1.is_null () ?
2334 Teuchos::null : map1->template clone<dst_node_type> (node2);
2336 const size_t lclNumRows = X.getLocalLength ();
2337 const size_t numCols = X.getNumVectors ();
2338 dst_dual_view_type Y_view (
"MV::dual_view", lclNumRows, numCols);
2340 RCP<dst_mv_type> Y (
new dst_mv_type (map2, Y_view));
2350 template <
class ST,
class LO,
class GO,
class NT, const
bool classic>
2362 template <
class DS,
class DL,
class DG,
class DN,
const bool dstClassic,
2363 class SS,
class SL,
class SG,
class SN,
const bool srcClassic>
2368 typedef typename DN::device_type DD;
2371 TEUCHOS_TEST_FOR_EXCEPTION(
2374 "Tpetra::deep_copy: Global dimensions of the two Tpetra::MultiVector " 2375 "objects do not match. src has dimensions [" << src.
getGlobalLength ()
2376 <<
"," << src.
getNumVectors () <<
"], and dst has dimensions [" 2380 TEUCHOS_TEST_FOR_EXCEPTION(
2382 "Tpetra::deep_copy: The local row counts of the two Tpetra::MultiVector " 2383 "objects do not match. src has " << src.
getLocalLength () <<
" row(s) " 2391 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2393 if (! useHostVersion) {
2395 dst.template modify<DES> ();
2397 Details::localDeepCopyConstStride (dst.template getLocalView<DES> (),
2398 src.template getLocalView<typename SN::device_type> ());
2399 dst.template sync<HES> ();
2402 dst.template modify<HES> ();
2404 Details::localDeepCopyConstStride (dst.template getLocalView<Kokkos::HostSpace> (),
2405 src.template getLocalView<Kokkos::HostSpace> ());
2406 dst.template sync<DES> ();
2410 typedef Kokkos::DualView<SL*, DD> whichvecs_type;
2411 typedef typename whichvecs_type::t_dev::execution_space DES;
2412 typedef typename whichvecs_type::t_host::execution_space HES;
2415 const SL numWhichVecs =
static_cast<SL
> (src.
whichVectors_.size ());
2416 const std::string whichVecsLabel (
"MV::deep_copy::whichVecs");
2423 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2425 if (! useHostVersion) {
2428 whichvecs_type whichVecs (whichVecsLabel, numWhichVecs);
2429 whichVecs.template modify<HES> ();
2430 for (SL i = 0; i < numWhichVecs; ++i) {
2431 whichVecs.h_view(i) =
static_cast<SL
> (src.
whichVectors_[i]);
2434 whichVecs.template sync<DES> ();
2437 dst.template modify<DES> ();
2439 Details::localDeepCopy (dst.template getLocalView<typename DN::device_type> (),
2440 src.template getLocalView<typename SN::device_type> (),
2447 dst.template sync<HES> ();
2454 typedef Kokkos::View<SL*, HES> the_whichvecs_type;
2455 the_whichvecs_type whichVecs (whichVecsLabel, numWhichVecs);
2456 for (SL i = 0; i < numWhichVecs; ++i) {
2462 Details::localDeepCopy (dst.template getLocalView<Kokkos::HostSpace> (),
2463 src.template getLocalView<Kokkos::HostSpace> (),
2466 whichVecs, whichVecs);
2468 dst.template sync<DES> ();
2475 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2477 if (! useHostVersion) {
2480 typedef Kokkos::DualView<DL*, DES> the_whichvecs_type;
2481 const std::string whichVecsLabel (
"MV::deep_copy::whichVecs");
2482 const DL numWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2483 the_whichvecs_type whichVecs (whichVecsLabel, numWhichVecs);
2484 whichVecs.template modify<HES> ();
2485 for (DL i = 0; i < numWhichVecs; ++i) {
2489 whichVecs.template sync<DES> ();
2492 Details::localDeepCopy (dst.template getLocalView<typename DN::device_type> (),
2493 src.template getLocalView<typename SN::device_type> (),
2503 dst.template sync<HES> ();
2510 typedef Kokkos::View<DL*, HES> the_whichvecs_type;
2511 const DL numWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2512 the_whichvecs_type whichVecs (
"MV::deep_copy::whichVecs", numWhichVecs);
2513 for (DL i = 0; i < numWhichVecs; ++i) {
2517 Details::localDeepCopy (dst.template getLocalView<Kokkos::HostSpace> (),
2518 src.template getLocalView<Kokkos::HostSpace> (),
2521 whichVecs, whichVecs);
2526 dst.template sync<DES> ();
2532 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2534 if (! useHostVersion) {
2537 const DL dstNumWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2538 Kokkos::DualView<DL*, DES> whichVecsDst (
"MV::deep_copy::whichVecsDst",
2540 whichVecsDst.template modify<HES> ();
2541 for (DL i = 0; i < dstNumWhichVecs; ++i) {
2542 whichVecsDst.h_view(i) =
static_cast<DL
> (dst.
whichVectors_[i]);
2545 whichVecsDst.template sync<DES> ();
2551 const DL srcNumWhichVecs =
static_cast<DL
> (src.
whichVectors_.size ());
2552 Kokkos::DualView<DL*, DES> whichVecsSrc (
"MV::deep_copy::whichVecsSrc",
2554 whichVecsSrc.template modify<HES> ();
2555 for (DL i = 0; i < srcNumWhichVecs; ++i) {
2556 whichVecsSrc.h_view(i) =
static_cast<DL
> (src.
whichVectors_[i]);
2559 whichVecsSrc.template sync<DES> ();
2563 Details::localDeepCopy (dst.template getLocalView<typename DN::device_type> (),
2564 src.template getLocalView<typename SN::device_type> (),
2567 whichVecsDst.d_view,
2568 whichVecsSrc.d_view);
2571 const DL dstNumWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2572 Kokkos::View<DL*, HES> whichVectorsDst (
"dstWhichVecs", dstNumWhichVecs);
2573 for (DL i = 0; i < dstNumWhichVecs; ++i) {
2578 const DL srcNumWhichVecs =
static_cast<DL
> (src.
whichVectors_.size ());
2579 Kokkos::View<DL*, HES> whichVectorsSrc (
"srcWhichVecs", srcNumWhichVecs);
2580 for (DL i = 0; i < srcNumWhichVecs; ++i) {
2586 Details::localDeepCopy (dst.template getLocalView<Kokkos::HostSpace> (),
2587 src.template getLocalView<Kokkos::HostSpace> (),
2590 whichVectorsDst, whichVectorsSrc);
2596 dst.template sync<HES> ();
2609 template<
class SC,
class LO,
class GO,
class NT, const
bool classic>
2610 class TypeNameTraits<Tpetra::
MultiVector<SC, LO, GO, NT, classic> > {
2612 static std::string name () {
2613 return std::string (
"Tpetra::MultiVector<") +
2614 TypeNameTraits<SC>::name () +
"," +
2615 TypeNameTraits<LO>::name () +
"," +
2616 TypeNameTraits<GO>::name () +
"," +
2617 TypeNameTraits<NT>::name () +
">";
2627 #endif // TPETRA_MULTIVECTOR_DECL_HPP Node node_type
This class' fourth template parameter; the Kokkos Node type.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
void sync()
Update data on device or host only if data in the other space has been marked as modified.
MultiVector< ST, LO, GO, NT, classic > createCopy(const MultiVector< ST, LO, GO, NT, classic > &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.
KokkosClassic::DefaultNode::DefaultNodeType node_type
Default value of Node template parameter.
void setCopyOrView(const Teuchos::DataAccess copyOrView)
Set whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
Teuchos::Array< size_t > whichVectors_
Indices of columns this multivector is viewing.
One or more distributed dense vectors.
void deep_copy(MultiVector< ST, LO, GO, NT, classic > &dst, const MultiVector< ST, LO, GO, NT, classic > &src)
Specialization of deep_copy for MultiVector objects with the same template parameters.
void deep_copy(MultiVector< DS, DL, DG, DN, dstClassic > &dst, const MultiVector< SS, SL, SG, SN, srcClassic > &src)
Copy the contents of the MultiVector src into dst.
Node::device_type device_type
The Kokkos device type.
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 removeEmptyProcessesInPlace(Teuchos::RCP< DistObjectType > &input, const Teuchos::RCP< const Map< typename DistObjectType::local_ordinal_type, typename DistObjectType::global_ordinal_type, typename DistObjectType::node_type > > &newMap)
Remove processes which contain no elements in this object's Map.
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The type of the Map specialization used by this class.
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.
dual_view_type view_
The Kokkos::DualView containing the MultiVector's data.
Kokkos::Details::InnerProductSpaceTraits< impl_scalar_type >::dot_type dot_type
Type of an inner ("dot") product result.
int local_ordinal_type
Default value of LocalOrdinal template parameter.
virtual bool useNewInterface()
Whether this class implements the old or new interface of DistObject.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > > 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 modify()
Mark data as modified on the given device TargetDeviceType.
Implementation details of Tpetra.
size_t global_size_t
Global size_t object.
Declaration of the Tpetra::Map class and related nonmember constructors.
Scalar scalar_type
This class' first template parameter; the type of each entry in the MultiVector.
bool isConstantStride() const
Whether this multivector has constant stride between columns.
size_t getLocalLength() const
Local number of rows on the calling process.
Node::execution_space execution_space
Type of the (new) Kokkos execution space.
Sets up and executes a communication plan for a Tpetra DistObject.
CombineMode
Rule for combining data in an Import or Export.
global_size_t getGlobalLength() const
Global number of rows in the multivector.
Abstract base class for objects that can be the source of an Import or Export operation.
double scalar_type
Default value of Scalar template parameter.
Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
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.
Implementation of Tpetra::MultiVector::clone().
Kokkos::Details::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutLeft, typename execution_space::execution_space > dual_view_type
Kokkos::DualView specialization used by this class.
A parallel distribution of indices over processes.
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.
size_t getNumVectors() const
Number of columns in the multivector.
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.
A distributed dense vector.
void assign(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &src)
Copy the contents of src into *this (deep copy).
LocalOrdinal local_ordinal_type
This class' second template parameter; the type of local indices.
bool need_sync() const
Whether this MultiVector needs synchronization to the given space.
EWhichNorm
Input argument for normImpl() (which see).
Teuchos::DataAccess getCopyOrView() const
Get whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
Base class for distributed Tpetra objects that support data redistribution.
GlobalOrdinal global_ordinal_type
This class' third template parameter; the type of global indices.
dual_view_type origView_
The "original view" of the MultiVector's data.