42 #ifndef TPETRA_MULTIVECTOR_DECL_HPP 43 #define TPETRA_MULTIVECTOR_DECL_HPP 57 #include "Tpetra_DistObject.hpp" 59 #include "Kokkos_DualView.hpp" 60 #include "Teuchos_BLAS_types.hpp" 61 #include "Teuchos_DataAccess.hpp" 62 #include "Teuchos_Range1D.hpp" 63 #include "Kokkos_ArithTraits.hpp" 64 #include "Kokkos_InnerProductSpaceTraits.hpp" 65 #include "Tpetra_KokkosRefactor_Details_MultiVectorLocalDeepCopy.hpp" 66 #include <type_traits> 96 template<
class DstMultiVectorType,
class SrcMultiVectorType>
98 typedef DstMultiVectorType dst_mv_type;
99 typedef SrcMultiVectorType src_mv_type;
101 static Teuchos::RCP<dst_mv_type>
102 clone (
const src_mv_type& X,
103 const Teuchos::RCP<typename dst_mv_type::node_type>& node2);
127 template <
class DS,
class DL,
class DG,
class DN,
128 class SS,
class SL,
class SG,
class SN>
140 template <
class ST,
class LO,
class GO,
class NT>
153 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
154 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
156 const size_t numVectors);
162 template<
class SC,
class LO,
class GO,
class NT>
163 Teuchos::ArrayView<const size_t>
385 template <
class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
387 class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
390 public DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>
435 typedef typename Kokkos::Details::InnerProductSpaceTraits<impl_scalar_type>::dot_type
dot_type;
443 typedef typename Kokkos::Details::ArithTraits<impl_scalar_type>::mag_type
mag_type;
475 typedef Kokkos::DualView<impl_scalar_type**, Kokkos::LayoutLeft,
494 MultiVector (
const Teuchos::RCP<const map_type>& map,
495 const size_t numVecs,
496 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);
663 MultiVector (
const Teuchos::RCP<const map_type>& map,
664 const dual_view_type& view,
665 const Teuchos::ArrayView<const size_t>& whichVectors);
694 MultiVector (
const Teuchos::RCP<const map_type>& map,
695 const dual_view_type& view,
696 const dual_view_type& origView,
697 const Teuchos::ArrayView<const size_t>& whichVectors);
758 const map_type& subMap,
759 const size_t offset = 0);
769 template <
class Node2>
770 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >
771 clone (
const Teuchos::RCP<Node2>& node2)
const;
791 static const bool useAtomicUpdatesByDefault =
792 #ifdef KOKKOS_ENABLE_SERIAL 793 ! std::is_same<execution_space, Kokkos::Serial>::value;
796 #endif // KOKKOS_ENABLE_SERIAL 828 replaceGlobalValue (
const GlobalOrdinal gblRow,
830 const impl_scalar_type& value)
const;
865 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
868 const T& value)
const 870 replaceGlobalValue (globalRow, col, static_cast<impl_scalar_type> (value));
897 sumIntoGlobalValue (
const GlobalOrdinal gblRow,
899 const impl_scalar_type& value,
900 const bool atomic = useAtomicUpdatesByDefault)
const;
930 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
934 const bool atomic = useAtomicUpdatesByDefault)
const 936 sumIntoGlobalValue (gblRow, col, static_cast<impl_scalar_type> (val), atomic);
968 replaceLocalValue (
const LocalOrdinal lclRow,
970 const impl_scalar_type& value)
const;
1004 template<
typename T>
1005 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1010 replaceLocalValue (lclRow, col, static_cast<impl_scalar_type> (val));
1037 sumIntoLocalValue (
const LocalOrdinal lclRow,
1039 const impl_scalar_type& val,
1040 const bool atomic = useAtomicUpdatesByDefault)
const;
1067 template<
typename T>
1068 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1072 const bool atomic = useAtomicUpdatesByDefault)
const 1074 sumIntoLocalValue (lclRow, col, static_cast<impl_scalar_type> (val), atomic);
1078 void putScalar (
const Scalar& value);
1088 template<
typename T>
1089 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1092 putScalar (static_cast<impl_scalar_type> (value));
1122 void randomize (
const Scalar& minVal,
const Scalar& maxVal);
1189 void replaceMap (
const Teuchos::RCP<const map_type>& map);
1233 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1234 subCopy (
const Teuchos::Range1D& colRng)
const;
1237 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1238 subCopy (
const Teuchos::ArrayView<const size_t>& cols)
const;
1241 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1242 subView (
const Teuchos::Range1D& colRng)
const;
1245 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1246 subView (
const Teuchos::ArrayView<const size_t>& cols)
const;
1249 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1250 subViewNonConst (
const Teuchos::Range1D& colRng);
1253 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1254 subViewNonConst (
const Teuchos::ArrayView<const size_t>& cols);
1318 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1319 offsetView (
const Teuchos::RCP<const map_type>& subMap,
1320 const size_t offset)
const;
1339 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1340 offsetViewNonConst (
const Teuchos::RCP<const map_type>& subMap,
1341 const size_t offset);
1344 Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1345 getVector (
const size_t j)
const;
1348 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1349 getVectorNonConst (
const size_t j);
1352 Teuchos::ArrayRCP<const Scalar> getData (
size_t j)
const;
1355 Teuchos::ArrayRCP<Scalar> getDataNonConst (
size_t j);
1365 get1dCopy (
const Teuchos::ArrayView<Scalar>& A,
1366 const size_t LDA)
const;
1375 get2dCopy (
const Teuchos::ArrayView<
const Teuchos::ArrayView<Scalar> >& ArrayOfPtrs)
const;
1382 Teuchos::ArrayRCP<const Scalar> get1dView ()
const;
1385 Teuchos::ArrayRCP<Teuchos::ArrayRCP<const Scalar> > get2dView ()
const;
1392 Teuchos::ArrayRCP<Scalar> get1dViewNonConst ();
1395 Teuchos::ArrayRCP<Teuchos::ArrayRCP<Scalar> > get2dViewNonConst ();
1411 dual_view_type getDualView ()
const;
1431 template<
class TargetDeviceType>
1433 getDualView ().template sync<TargetDeviceType> ();
1437 template<
class TargetDeviceType>
1439 return getDualView ().template need_sync<TargetDeviceType> ();
1447 template<
class TargetDeviceType>
1449 getDualView ().template modify<TargetDeviceType> ();
1483 template<
class TargetDeviceType>
1484 typename Kokkos::Impl::if_c<
1486 typename device_type::memory_space,
1487 typename TargetDeviceType::memory_space>::value,
1488 typename dual_view_type::t_dev,
1489 typename dual_view_type::t_host>::type
1491 return getDualView ().template view<TargetDeviceType> ();
1513 const Teuchos::ArrayView<dot_type>& dots)
const;
1526 template <
typename T>
1527 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1529 const Teuchos::ArrayView<T> &dots)
const 1531 const size_t sz =
static_cast<size_t> (dots.size ());
1532 Teuchos::Array<dot_type> dts (sz);
1534 for (
size_t i = 0; i < sz; ++i) {
1541 template <
typename T>
1542 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1544 std::vector<T>& dots)
const 1546 const size_t sz = dots.size ();
1547 Teuchos::Array<dot_type> dts (sz);
1549 for (
size_t i = 0; i < sz; ++i) {
1574 const Kokkos::View<dot_type*, Kokkos::HostSpace>& norms)
const;
1576 template<
class ViewType>
1578 dot (
typename std::enable_if<std::is_same<typename ViewType::value_type,dot_type>::value &&
1579 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value,
1581 const ViewType& dots)
const {
1582 const Kokkos::View<dot_type*, Kokkos::HostSpace> h_dots(
"Tpetra::Dots",dots.extent(0));
1583 this->dot (A, h_dots);
1599 template <
typename T>
1600 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1602 const Kokkos::View<T*, device_type>& dots)
const 1604 const size_t numDots = dots.extent (0);
1605 Kokkos::View<dot_type*, device_type> dts (
"MV::dot tmp", numDots);
1631 void scale (
const Scalar& alpha);
1641 void scale (
const Teuchos::ArrayView<const Scalar>& alpha);
1651 void scale (
const Kokkos::View<const impl_scalar_type*, device_type>& alpha);
1662 scale (
const Scalar& alpha,
1672 update (
const Scalar& alpha,
1674 const Scalar& beta);
1683 update (
const Scalar& alpha,
1687 const Scalar& gamma);
1706 template<
class ViewType>
1707 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1708 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1710 typedef typename Kokkos::View<mag_type*, Kokkos::HostSpace> host_norms_view_type;
1711 host_norms_view_type h_norms(
"Tpetra::MV::h_norms",norms.extent(0));
1712 this->normImpl (h_norms, NORM_ONE);
1715 void norm1 (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1732 template <
typename T>
1733 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1734 norm1 (
const Kokkos::View<T*, device_type>& norms)
const 1736 const size_t numNorms = norms.extent (0);
1737 Kokkos::View<mag_type*, device_type> tmpNorms (
"MV::norm1 tmp", numNorms);
1739 this->norm1 (tmpNorms);
1751 void norm1 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1767 template <
typename T>
1768 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1769 norm1 (
const Teuchos::ArrayView<T>& norms)
const 1771 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1772 const size_type sz = norms.size ();
1773 Teuchos::Array<mag_type> theNorms (sz);
1774 this->norm1 (theNorms);
1775 for (size_type i = 0; i < sz; ++i) {
1777 norms[i] = theNorms[i];
1799 template<
class ViewType>
1800 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1801 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1803 typedef typename Kokkos::View<mag_type*, Kokkos::HostSpace> host_norms_view_type;
1804 host_norms_view_type h_norms(
"Tpetra::MV::h_norms",norms.extent(0));
1805 this->normImpl (h_norms, NORM_TWO);
1808 void norm2 (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1823 template<
typename T>
1824 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1825 norm2 (
const Kokkos::View<T*, device_type>& norms)
const 1827 const size_t numNorms = norms.extent (0);
1828 Kokkos::View<mag_type*, device_type> theNorms (
"MV::norm2 tmp", numNorms);
1830 this->norm2 (theNorms);
1842 void norm2 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1858 template <
typename T>
1859 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1860 norm2 (
const Teuchos::ArrayView<T>& norms)
const 1862 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1863 const size_type sz = norms.size ();
1864 Teuchos::Array<mag_type> theNorms (sz);
1865 this->norm2 (theNorms);
1866 for (size_type i = 0; i < sz; ++i) {
1868 norms[i] = theNorms[i];
1884 template<
class ViewType>
1885 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1886 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1888 typedef typename Kokkos::View<mag_type*, Kokkos::HostSpace> host_norms_view_type;
1889 host_norms_view_type h_norms(
"Tpetra::MV::h_norms",norms.extent(0));
1890 this->normImpl (h_norms, NORM_INF);
1893 void normInf (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1908 template<
typename T>
1909 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1910 normInf (
const Kokkos::View<T*, device_type>& norms)
const 1912 const size_t numNorms = norms.extent (0);
1913 Kokkos::View<mag_type*, device_type> theNorms (
"MV::normInf tmp", numNorms);
1915 this->normInf (theNorms);
1928 void normInf (
const Teuchos::ArrayView<mag_type>& norms)
const;
1945 template <
typename T>
1946 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1947 normInf (
const Teuchos::ArrayView<T>& norms)
const 1949 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1950 const size_type sz = norms.size ();
1951 Teuchos::Array<mag_type> theNorms (sz);
1952 this->norm2 (theNorms);
1953 for (size_type i = 0; i < sz; ++i) {
1955 norms[i] = theNorms[i];
1965 void TPETRA_DEPRECATED
1967 const Teuchos::ArrayView<mag_type>& norms)
const;
1985 template <
typename T>
1986 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1989 const Teuchos::ArrayView<T>& norms)
const 1991 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1992 const size_type sz = norms.size ();
1993 Teuchos::Array<mag_type> theNorms (sz);
1994 this->normWeighted (weights, theNorms);
1995 for (size_type i = 0; i < sz; ++i) {
1997 norms[i] = theNorms[i];
2005 void meanValue (
const Teuchos::ArrayView<impl_scalar_type>& means)
const;
2007 template <
typename T>
2008 typename std::enable_if<! std::is_same<impl_scalar_type, T>::value,
void>::type
2009 meanValue (
const Teuchos::ArrayView<T>& means)
const 2011 typedef typename Teuchos::Array<T>::size_type size_type;
2012 const size_type numMeans = means.size ();
2014 Teuchos::Array<impl_scalar_type> theMeans (numMeans);
2015 this->meanValue (theMeans ());
2016 for (size_type k = 0; k < numMeans; ++k) {
2017 means[k] =
static_cast<T
> (theMeans[k]);
2027 multiply (Teuchos::ETransp transA,
2028 Teuchos::ETransp transB,
2029 const Scalar& alpha,
2032 const Scalar& beta);
2055 elementWiseMultiply (Scalar scalarAB,
2064 size_t getNumVectors()
const;
2067 size_t getLocalLength()
const;
2077 size_t getStride()
const;
2082 bool isConstantStride()
const;
2090 virtual std::string description()
const;
2121 describe (Teuchos::FancyOStream& out,
2122 const Teuchos::EVerbosityLevel verbLevel =
2123 Teuchos::Describable::verbLevel_default)
const;
2153 TEUCHOS_TEST_FOR_EXCEPTION(
2154 copyOrView == Teuchos::Copy, std::invalid_argument,
2155 "Tpetra::MultiVector::setCopyOrView: The Kokkos refactor version of " 2156 "MultiVector _only_ implements view semantics. You may not call this " 2157 "method with copyOrView = Teuchos::Copy. The only valid argument is " 2170 return Teuchos::View;
2202 template <
class DS,
class DL,
class DG,
class DN,
2203 class SS,
class SL,
class SG,
class SN>
2261 template<
class SC,
class LO,
class GO,
class NT>
2262 friend ::Teuchos::ArrayView<const size_t> getMultiVectorWhichVectors (const ::Tpetra::MultiVector<SC, LO, GO, NT>& X);
2282 normImpl (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms,
2301 descriptionImpl (
const std::string& className)
const;
2310 localDescribeToString (
const Teuchos::EVerbosityLevel vl)
const;
2326 describeImpl (Teuchos::FancyOStream& out,
2327 const std::string& className,
2328 const Teuchos::EVerbosityLevel verbLevel =
2329 Teuchos::Describable::verbLevel_default)
const;
2332 bool vectorIndexOutOfRange (
const size_t VectorIndex)
const;
2339 Teuchos::ArrayRCP<T>
2340 getSubArrayRCP (Teuchos::ArrayRCP<T> arr,
size_t j)
const;
2343 size_t getOrigNumLocalRows ()
const;
2346 size_t getOrigNumLocalCols ()
const;
2360 virtual size_t constantNumberOfPackets ()
const;
2369 typedef typename DistObject<Scalar, LocalOrdinal, GlobalOrdinal,
2374 const size_t numSameIDs,
2375 const Kokkos::DualView<const local_ordinal_type*, device_type>& permuteToLIDs,
2376 const Kokkos::DualView<const local_ordinal_type*, device_type>& permuteFromLIDs);
2380 const Kokkos::DualView<const local_ordinal_type*, device_type>& exportLIDs,
2381 Kokkos::DualView<impl_scalar_type*, buffer_device_type>& exports,
2382 const Kokkos::DualView<size_t*, buffer_device_type>& ,
2383 size_t& constantNumPackets,
2387 unpackAndCombineNew (
const Kokkos::DualView<const LocalOrdinal*, device_type>& importLIDs,
2388 const Kokkos::DualView<const impl_scalar_type*, buffer_device_type>& imports,
2389 const Kokkos::DualView<const size_t*, buffer_device_type>& ,
2390 const size_t constantNumPackets,
2396 template<
class SC,
class LO,
class GO,
class NT>
2397 Teuchos::ArrayView<const size_t>
2406 template<
class DstMultiVectorType,
2407 class SrcMultiVectorType>
2408 Teuchos::RCP<typename MultiVectorCloner<DstMultiVectorType, SrcMultiVectorType>::dst_mv_type>
2409 MultiVectorCloner<DstMultiVectorType, SrcMultiVectorType>::
2410 clone (
const src_mv_type& X,
2411 const Teuchos::RCP<typename dst_mv_type::node_type>& node2)
2414 typedef typename src_mv_type::map_type src_map_type;
2415 typedef typename dst_mv_type::map_type dst_map_type;
2416 typedef typename dst_mv_type::node_type dst_node_type;
2417 typedef typename dst_mv_type::dual_view_type dst_dual_view_type;
2420 RCP<const src_map_type> map1 = X.getMap ();
2421 RCP<const dst_map_type> map2 = map1.is_null () ?
2422 Teuchos::null : map1->template clone<dst_node_type> (node2);
2424 const size_t lclNumRows = X.getLocalLength ();
2425 const size_t numCols = X.getNumVectors ();
2426 dst_dual_view_type Y_view (
"MV::dual_view", lclNumRows, numCols);
2428 RCP<dst_mv_type> Y (
new dst_mv_type (map2, Y_view));
2438 template <
class ST,
class LO,
class GO,
class NT>
2450 template <
class DS,
class DL,
class DG,
class DN,
2451 class SS,
class SL,
class SG,
class SN>
2456 typedef typename DN::device_type DD;
2458 using ::Tpetra::Classes::getMultiVectorWhichVectors;
2460 TEUCHOS_TEST_FOR_EXCEPTION(
2463 "Tpetra::deep_copy: Global dimensions of the two Tpetra::MultiVector " 2464 "objects do not match. src has dimensions [" << src.
getGlobalLength ()
2465 <<
"," << src.
getNumVectors () <<
"], and dst has dimensions [" 2469 TEUCHOS_TEST_FOR_EXCEPTION(
2471 "Tpetra::deep_copy: The local row counts of the two Tpetra::MultiVector " 2472 "objects do not match. src has " << src.
getLocalLength () <<
" row(s) " 2480 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2482 if (! useHostVersion) {
2484 dst.template modify<DES> ();
2486 Details::localDeepCopyConstStride (dst.template getLocalView<DES> (),
2487 src.template getLocalView<typename SN::device_type> ());
2488 dst.template sync<HES> ();
2491 dst.template modify<HES> ();
2493 Details::localDeepCopyConstStride (dst.template getLocalView<Kokkos::HostSpace> (),
2494 src.template getLocalView<Kokkos::HostSpace> ());
2495 dst.template sync<DES> ();
2499 typedef Kokkos::DualView<SL*, DD> whichvecs_type;
2500 typedef typename whichvecs_type::t_dev::execution_space DES;
2501 typedef typename whichvecs_type::t_host::execution_space HES;
2504 const SL numWhichVecs =
2505 static_cast<SL
> (getMultiVectorWhichVectors (src).size ());
2506 const std::string whichVecsLabel (
"MV::deep_copy::whichVecs");
2513 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2515 if (! useHostVersion) {
2518 whichvecs_type whichVecs (whichVecsLabel, numWhichVecs);
2519 whichVecs.template modify<HES> ();
2521 Teuchos::ArrayView<const size_t> src_whichVectors =
2522 getMultiVectorWhichVectors (src);
2523 for (SL i = 0; i < numWhichVecs; ++i) {
2524 whichVecs.h_view(i) =
static_cast<SL
> (src_whichVectors[i]);
2527 whichVecs.template sync<DES> ();
2530 dst.template modify<DES> ();
2532 Details::localDeepCopy (dst.template getLocalView<typename DN::device_type> (),
2533 src.template getLocalView<typename SN::device_type> (),
2540 dst.template sync<HES> ();
2547 typedef Kokkos::View<SL*, HES> the_whichvecs_type;
2548 the_whichvecs_type whichVecs (whichVecsLabel, numWhichVecs);
2549 Teuchos::ArrayView<const size_t> src_whichVectors =
2550 getMultiVectorWhichVectors (src);
2551 for (SL i = 0; i < numWhichVecs; ++i) {
2552 whichVecs(i) =
static_cast<SL
> (src_whichVectors[i]);
2557 Details::localDeepCopy (dst.template getLocalView<Kokkos::HostSpace> (),
2558 src.template getLocalView<Kokkos::HostSpace> (),
2561 whichVecs, whichVecs);
2563 dst.template sync<DES> ();
2570 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2572 if (! useHostVersion) {
2575 typedef Kokkos::DualView<DL*, DES> the_whichvecs_type;
2576 const std::string whichVecsLabel (
"MV::deep_copy::whichVecs");
2577 Teuchos::ArrayView<const size_t> dst_whichVectors =
2578 getMultiVectorWhichVectors (dst);
2579 const DL numWhichVecs =
static_cast<DL
> (dst_whichVectors.size ());
2580 the_whichvecs_type whichVecs (whichVecsLabel, numWhichVecs);
2581 whichVecs.template modify<HES> ();
2582 for (DL i = 0; i < numWhichVecs; ++i) {
2583 whichVecs.h_view(i) = dst_whichVectors[i];
2586 whichVecs.template sync<DES> ();
2589 Details::localDeepCopy (dst.template getLocalView<typename DN::device_type> (),
2590 src.template getLocalView<typename SN::device_type> (),
2600 dst.template sync<HES> ();
2607 typedef Kokkos::View<DL*, HES> the_whichvecs_type;
2608 Teuchos::ArrayView<const size_t> dst_whichVectors =
2609 getMultiVectorWhichVectors (dst);
2610 const DL numWhichVecs =
static_cast<DL
> (dst_whichVectors.size ());
2611 the_whichvecs_type whichVecs (
"MV::deep_copy::whichVecs",
2613 for (DL i = 0; i < numWhichVecs; ++i) {
2614 whichVecs(i) =
static_cast<DL
> (dst_whichVectors[i]);
2617 Details::localDeepCopy (dst.template getLocalView<Kokkos::HostSpace> (),
2618 src.template getLocalView<Kokkos::HostSpace> (),
2621 whichVecs, whichVecs);
2626 dst.template sync<DES> ();
2632 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2634 if (! useHostVersion) {
2637 Teuchos::ArrayView<const size_t> dst_whichVectors =
2638 getMultiVectorWhichVectors (dst);
2639 const DL dstNumWhichVecs =
2640 static_cast<DL
> (dst_whichVectors.size ());
2641 Kokkos::DualView<DL*, DES> whichVecsDst (
"MV::deep_copy::whichVecsDst",
2643 whichVecsDst.template modify<HES> ();
2644 for (DL i = 0; i < dstNumWhichVecs; ++i) {
2645 whichVecsDst.h_view(i) =
static_cast<DL
> (dst_whichVectors[i]);
2648 whichVecsDst.template sync<DES> ();
2654 Teuchos::ArrayView<const size_t> src_whichVectors =
2655 getMultiVectorWhichVectors (src);
2656 const DL srcNumWhichVecs =
2657 static_cast<DL
> (src_whichVectors.size ());
2658 Kokkos::DualView<DL*, DES> whichVecsSrc (
"MV::deep_copy::whichVecsSrc",
2660 whichVecsSrc.template modify<HES> ();
2661 for (DL i = 0; i < srcNumWhichVecs; ++i) {
2662 whichVecsSrc.h_view(i) =
static_cast<DL
> (src_whichVectors[i]);
2665 whichVecsSrc.template sync<DES> ();
2669 Details::localDeepCopy (dst.template getLocalView<typename DN::device_type> (),
2670 src.template getLocalView<typename SN::device_type> (),
2673 whichVecsDst.d_view,
2674 whichVecsSrc.d_view);
2677 Teuchos::ArrayView<const size_t> dst_whichVectors =
2678 getMultiVectorWhichVectors (dst);
2679 const DL dstNumWhichVecs =
2680 static_cast<DL
> (dst_whichVectors.size ());
2681 Kokkos::View<DL*, HES> whichVectorsDst (
"dstWhichVecs",
2683 for (DL i = 0; i < dstNumWhichVecs; ++i) {
2684 whichVectorsDst(i) = dst_whichVectors[i];
2687 Teuchos::ArrayView<const size_t> src_whichVectors =
2688 getMultiVectorWhichVectors (src);
2690 const DL srcNumWhichVecs =
2691 static_cast<DL
> (src_whichVectors.size ());
2692 Kokkos::View<DL*, HES> whichVectorsSrc (
"srcWhichVecs",
2694 for (DL i = 0; i < srcNumWhichVecs; ++i) {
2695 whichVectorsSrc(i) = src_whichVectors[i];
2700 Details::localDeepCopy (dst.template getLocalView<Kokkos::HostSpace> (),
2701 src.template getLocalView<Kokkos::HostSpace> (),
2704 whichVectorsDst, whichVectorsSrc);
2710 dst.template sync<HES> ();
2723 template<
class SC,
class LO,
class GO,
class NT>
2724 class TypeNameTraits<Tpetra::
MultiVector<SC, LO, GO, NT> > {
2726 static std::string name () {
2727 return std::string (
"Tpetra::MultiVector<") +
2728 TypeNameTraits<SC>::name () +
"," +
2729 TypeNameTraits<LO>::name () +
"," +
2730 TypeNameTraits<GO>::name () +
"," +
2731 TypeNameTraits<NT>::name () +
">";
2741 #endif // TPETRA_MULTIVECTOR_DECL_HPP Base class for distributed Tpetra objects that support data redistribution.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
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.
Scalar scalar_type
This class' first template parameter; the type of each entry in the MultiVector.
A distributed dense vector.
global_size_t getGlobalLength() const
Global number of rows in the multivector.
Node::device_type device_type
The Kokkos device type.
Teuchos::Array< size_t > whichVectors_
Indices of columns this multivector is viewing.
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.
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.
One or more distributed dense vectors.
DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node >::buffer_device_type buffer_device_type
Kokkos::Device specialization for communication buffers.
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.
MultiVector< ST, LO, GO, NT > createCopy(const MultiVector< ST, LO, GO, NT > &src)
Return a deep copy of the given MultiVector.
size_t getLocalLength() const
Local number of rows on the calling process.
int local_ordinal_type
Default value of Scalar template parameter.
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 putScalar(const T &value)
Set all values in the multivector with the given value.
Implementation details of Tpetra.
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.
virtual bool useNewInterface()
Whether this class implements the old or new interface of DistObject.
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutLeft, typename execution_space::execution_space > dual_view_type
Kokkos::DualView specialization used by this class.
std::enable_if< std::is_same< typename ViewType::value_type, mag_type >::value &&std::is_same< typename ViewType::memory_space, typename device_type::memory_space >::value >::type norm2(const ViewType &norms) const
Compute the two-norm of each vector (column), storing the result in a device view.
void sync()
Update data on device or host only if data in the other space has been marked as modified.
Node::execution_space execution_space
Type of the (new) Kokkos execution space.
std::enable_if< std::is_same< typename ViewType::value_type, mag_type >::value &&std::is_same< typename ViewType::memory_space, typename device_type::memory_space >::value >::type normInf(const ViewType &norms) const
Compute the infinity-norm of each vector (column), storing the result in a device view...
bool need_sync() const
Whether this MultiVector needs synchronization to the given space.
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.
Node node_type
This class' fourth template parameter; the Kokkos Node type.
Sets up and executes a communication plan for a Tpetra DistObject.
CombineMode
Rule for combining data in an Import or Export.
void assign(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &src)
Copy the contents of src into *this (deep copy).
Forward declaration of Tpetra::MultiVector.
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.
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.
Abstract base class for objects that can be the source of an Import or Export operation.
Kokkos::Details::InnerProductSpaceTraits< impl_scalar_type >::dot_type dot_type
Type of an inner ("dot") product result.
dual_view_type view_
The Kokkos::DualView containing the MultiVector's data.
Forward declaration of Tpetra::Vector.
::Kokkos::Compat::KokkosDeviceWrapperNode< execution_space > node_type
Default value of Node template parameter.
std::enable_if<! std::is_same< T, impl_scalar_type >::value &&std::is_convertible< T, impl_scalar_type >::value, void >::type sumIntoGlobalValue(const GlobalOrdinal gblRow, const size_t col, const T &val, const bool atomic=useAtomicUpdatesByDefault) const
Like the above sumIntoGlobalValue, but only enabled if T differs from impl_scalar_type.
void setCopyOrView(const Teuchos::DataAccess copyOrView)
Set whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
Forward declaration of Tpetra::FEMultiVector.
Implementation of Tpetra::MultiVector::clone().
std::enable_if< std::is_same< typename ViewType::value_type, mag_type >::value &&std::is_same< typename ViewType::memory_space, typename device_type::memory_space >::value >::type norm1(const ViewType &norms) const
Compute the one-norm of each vector (column), storing the result in a device view.
Classes::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > MultiVector
Alias for Tpetra::Classes::MultiVector.
Kokkos::Details::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
Kokkos::Device< typename device_type::execution_space, buffer_memory_space > buffer_device_type
Kokkos::Device specialization for communication buffers.
A parallel distribution of indices over processes.
EWhichNorm
Input argument for normImpl() (which see).
void modify()
Mark data as modified on the given device TargetDeviceType.
bool isConstantStride() const
Whether this multivector has constant stride between columns.
Forward declaration of Tpetra::Map.
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The type of the Map specialization used by this class.
LocalOrdinal local_ordinal_type
This class' second template parameter; the type of local indices.
Teuchos::DataAccess getCopyOrView() const
Get whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
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.