42 #ifndef TPETRA_MULTIVECTOR_DECL_HPP 43 #define TPETRA_MULTIVECTOR_DECL_HPP 54 #include "Tpetra_ConfigDefs.hpp" 55 #include "Tpetra_DistObject.hpp" 58 #include "Kokkos_DualView.hpp" 59 #include "Kokkos_MultiVector.hpp" 61 #include "Teuchos_BLAS_types.hpp" 62 #include "Teuchos_DataAccess.hpp" 63 #include "Teuchos_Range1D.hpp" 65 #include "KokkosCompat_ClassicNodeAPI_Wrapper.hpp" 66 #include "Kokkos_InnerProductSpaceTraits.hpp" 67 #include "Kokkos_ArithTraits.hpp" 69 #include "Tpetra_KokkosRefactor_DistObject.hpp" 70 #include "Tpetra_KokkosRefactor_Details_MultiVectorLocalDeepCopy.hpp" 71 #include <type_traits> 75 #ifndef DOXYGEN_SHOULD_SKIP_THIS 77 template<
class LO,
class GO,
class N>
class Map;
80 template<
class S,
class LO,
class GO,
class N, const
bool classic>
class Vector;
83 template<
class S,
class LO,
class GO,
class N, const
bool classic>
class MultiVector;
84 #endif // DOXYGEN_SHOULD_SKIP_THIS 112 template<
class DstMultiVectorType,
class SrcMultiVectorType>
114 typedef DstMultiVectorType dst_mv_type;
115 typedef SrcMultiVectorType src_mv_type;
117 static Teuchos::RCP<dst_mv_type>
118 clone (
const src_mv_type& X,
119 const Teuchos::RCP<typename dst_mv_type::node_type>& node2);
144 template <
class DS,
class DL,
class DG,
class DN,
const bool dstClassic,
145 class SS,
class SL,
class SG,
class SN,
const bool srcClassic>
157 template <
class ST,
class LO,
class GO,
class NT, const
bool classic = NT::
classic>
170 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node, const
bool classic = Node::
classic>
171 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
173 const size_t numVectors);
397 class GlobalOrdinal = Details::DefaultTypes::global_ordinal_type,
399 const bool classic = Node::classic>
401 public DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>
403 static_assert (! classic,
"The 'classic' version of Tpetra was deprecated long ago, and has been removed.");
448 typedef typename Kokkos::Details::InnerProductSpaceTraits<impl_scalar_type>::dot_type
dot_type;
456 typedef typename Kokkos::Details::ArithTraits<impl_scalar_type>::mag_type
mag_type;
488 typedef Kokkos::DualView<impl_scalar_type**, Kokkos::LayoutLeft,
507 MultiVector (
const Teuchos::RCP<const map_type>& map,
508 const size_t numVecs,
509 const bool zeroOut =
true);
523 const Teuchos::DataAccess copyOrView);
540 MultiVector (
const Teuchos::RCP<const map_type>& map,
541 const Teuchos::ArrayView<const Scalar>& A,
543 const size_t NumVectors);
558 MultiVector (
const Teuchos::RCP<const map_type>& map,
559 const Teuchos::ArrayView<
const Teuchos::ArrayView<const Scalar> >&ArrayOfPtrs,
560 const size_t NumVectors);
574 MultiVector (
const Teuchos::RCP<const map_type>& map,
575 const dual_view_type& view);
615 MultiVector (
const Teuchos::RCP<const map_type>& map,
616 const typename dual_view_type::t_dev& d_view);
640 MultiVector (
const Teuchos::RCP<const map_type>& map,
641 const dual_view_type& view,
642 const dual_view_type& origView);
661 MultiVector (
const Teuchos::RCP<const map_type>& map,
662 const dual_view_type& view,
663 const Teuchos::ArrayView<const size_t>& whichVectors);
692 MultiVector (
const Teuchos::RCP<const map_type>& map,
693 const dual_view_type& view,
694 const dual_view_type& origView,
695 const Teuchos::ArrayView<const size_t>& whichVectors);
756 const map_type& subMap,
757 const size_t offset = 0);
767 template <
class Node2>
768 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >
769 clone (
const Teuchos::RCP<Node2>& node2)
const;
783 static const bool useAtomicUpdatesByDefault =
784 #ifdef KOKKOS_HAVE_SERIAL 785 ! std::is_same<execution_space, Kokkos::Serial>::value;
788 #endif // KOKKOS_HAVE_SERIAL 808 replaceGlobalValue (GlobalOrdinal globalRow,
810 const impl_scalar_type& value)
const;
830 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
833 const T& value)
const 835 replaceGlobalValue (globalRow, col, static_cast<impl_scalar_type> (value));
861 sumIntoGlobalValue (
const GlobalOrdinal globalRow,
863 const impl_scalar_type& value,
864 const bool atomic = useAtomicUpdatesByDefault)
const;
893 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
897 const bool atomic = useAtomicUpdatesByDefault)
const 899 sumIntoGlobalValue (globalRow, col, static_cast<impl_scalar_type> (value), atomic);
919 replaceLocalValue (LocalOrdinal localRow,
921 const impl_scalar_type& value)
const;
941 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
944 const T& value)
const 946 replaceLocalValue (localRow, col, static_cast<impl_scalar_type> (value));
970 sumIntoLocalValue (
const LocalOrdinal localRow,
972 const impl_scalar_type& value,
973 const bool atomic = useAtomicUpdatesByDefault)
const;
1000 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1004 const bool atomic = useAtomicUpdatesByDefault)
const 1006 sumIntoLocalValue (localRow, col, static_cast<impl_scalar_type> (value), atomic);
1010 void putScalar (
const Scalar& value);
1018 template<
typename T>
1019 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1022 putScalar (static_cast<impl_scalar_type> (value));
1107 void replaceMap (
const Teuchos::RCP<const map_type>& map);
1147 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1148 subCopy (
const Teuchos::Range1D& colRng)
const;
1151 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1152 subCopy (
const Teuchos::ArrayView<const size_t>& cols)
const;
1155 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1156 subView (
const Teuchos::Range1D& colRng)
const;
1159 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1160 subView (
const Teuchos::ArrayView<const size_t>& cols)
const;
1163 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1164 subViewNonConst (
const Teuchos::Range1D& colRng);
1167 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1168 subViewNonConst (
const Teuchos::ArrayView<const size_t>& cols);
1232 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1233 offsetView (
const Teuchos::RCP<const map_type>& subMap,
1234 const size_t offset)
const;
1253 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1254 offsetViewNonConst (
const Teuchos::RCP<const map_type>& subMap,
1255 const size_t offset);
1258 Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1259 getVector (
const size_t j)
const;
1262 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1263 getVectorNonConst (
const size_t j);
1266 Teuchos::ArrayRCP<const Scalar> getData (
size_t j)
const;
1269 Teuchos::ArrayRCP<Scalar> getDataNonConst (
size_t j);
1279 get1dCopy (
const Teuchos::ArrayView<Scalar>& A,
1280 const size_t LDA)
const;
1289 get2dCopy (
const Teuchos::ArrayView<
const Teuchos::ArrayView<Scalar> >& ArrayOfPtrs)
const;
1296 Teuchos::ArrayRCP<const Scalar> get1dView ()
const;
1299 Teuchos::ArrayRCP<Teuchos::ArrayRCP<const Scalar> > get2dView ()
const;
1306 Teuchos::ArrayRCP<Scalar> get1dViewNonConst ();
1309 Teuchos::ArrayRCP<Teuchos::ArrayRCP<Scalar> > get2dViewNonConst ();
1319 KokkosClassic::MultiVector<Scalar, Node> getLocalMV ()
const;
1332 dual_view_type getDualView ()
const;
1352 template<
class TargetDeviceType>
1354 getDualView ().template sync<TargetDeviceType> ();
1362 template<
class TargetDeviceType>
1364 getDualView ().template modify<TargetDeviceType> ();
1398 template<
class TargetDeviceType>
1399 typename Kokkos::Impl::if_c<
1401 typename device_type::memory_space,
1402 typename TargetDeviceType::memory_space>::value,
1403 typename dual_view_type::t_dev,
1404 typename dual_view_type::t_host>::type
1406 return getDualView ().template view<TargetDeviceType> ();
1428 const Teuchos::ArrayView<dot_type>& dots)
const;
1441 template <
typename T>
1442 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1444 const Teuchos::ArrayView<T> &dots)
const 1446 const size_t sz =
static_cast<size_t> (dots.size ());
1447 Teuchos::Array<dot_type> dts (sz);
1449 for (
size_t i = 0; i < sz; ++i) {
1456 template <
typename T>
1457 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1459 std::vector<T>& dots)
const 1461 const size_t sz = dots.size ();
1462 Teuchos::Array<dot_type> dts (sz);
1464 for (
size_t i = 0; i < sz; ++i) {
1489 const Kokkos::View<dot_type*, device_type>& dots)
const;
1503 template <
typename T>
1504 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1506 const Kokkos::View<T*, device_type>& dots)
const 1508 const size_t numDots = dots.dimension_0 ();
1509 Kokkos::View<dot_type*, device_type> dts (
"MV::dot tmp", numDots);
1534 void scale (
const Scalar& alpha);
1544 void scale (
const Teuchos::ArrayView<const Scalar>& alpha);
1554 void scale (
const Kokkos::View<const impl_scalar_type*, device_type>& alpha);
1565 scale (
const Scalar& alpha,
1575 update (
const Scalar& alpha,
1577 const Scalar& beta);
1586 update (
const Scalar& alpha,
1590 const Scalar& gamma);
1603 void norm1 (
const Kokkos::View<mag_type*, device_type>& norms)
const;
1618 template <
typename T>
1619 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1620 norm1 (
const Kokkos::View<T*, device_type>& norms)
const 1622 const size_t numNorms = norms.dimension_0 ();
1623 Kokkos::View<mag_type*, device_type> tmpNorms (
"MV::norm1 tmp", numNorms);
1625 this->norm1 (tmpNorms);
1640 void norm1 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1654 template <
typename T>
1655 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1656 norm1 (
const Teuchos::ArrayView<T>& norms)
const 1658 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1659 const size_type sz = norms.size ();
1660 Teuchos::Array<mag_type> theNorms (sz);
1661 this->norm1 (theNorms);
1662 for (size_type i = 0; i < sz; ++i) {
1664 norms[i] = theNorms[i];
1680 void norm2 (
const Kokkos::View<mag_type*, device_type>& norms)
const;
1693 template<
typename T>
1694 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1695 norm2 (
const Kokkos::View<T*, device_type>& norms)
const 1697 const size_t numNorms = norms.dimension_0 ();
1698 Kokkos::View<mag_type*, device_type> theNorms (
"MV::norm2 tmp", numNorms);
1700 this->norm2 (theNorms);
1715 void norm2 (
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 norm2 (
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->norm2 (theNorms);
1737 for (size_type i = 0; i < sz; ++i) {
1739 norms[i] = theNorms[i];
1749 void normInf (
const Kokkos::View<mag_type*, device_type>& norms)
const;
1762 template<
typename T>
1763 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1764 normInf (
const Kokkos::View<T*, device_type>& norms)
const 1766 const size_t numNorms = norms.dimension_0 ();
1767 Kokkos::View<mag_type*, device_type> theNorms (
"MV::normInf tmp", numNorms);
1769 this->normInf (theNorms);
1783 void normInf (
const Teuchos::ArrayView<mag_type>& norms)
const;
1797 template <
typename T>
1798 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1799 normInf (
const Teuchos::ArrayView<T>& norms)
const 1801 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1802 const size_type sz = norms.size ();
1803 Teuchos::Array<mag_type> theNorms (sz);
1804 this->norm2 (theNorms);
1805 for (size_type i = 0; i < sz; ++i) {
1807 norms[i] = theNorms[i];
1817 void TPETRA_DEPRECATED
1819 const Teuchos::ArrayView<mag_type>& norms)
const;
1837 template <
typename T>
1838 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1841 const Teuchos::ArrayView<T>& norms)
const 1843 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1844 const size_type sz = norms.size ();
1845 Teuchos::Array<mag_type> theNorms (sz);
1846 this->normWeighted (weights, theNorms);
1847 for (size_type i = 0; i < sz; ++i) {
1849 norms[i] = theNorms[i];
1857 void meanValue (
const Teuchos::ArrayView<impl_scalar_type>& means)
const;
1859 template <
typename T>
1860 typename std::enable_if<! std::is_same<impl_scalar_type, T>::value,
void>::type
1861 meanValue (
const Teuchos::ArrayView<T>& means)
const 1863 typedef typename Teuchos::Array<T>::size_type size_type;
1864 const size_type numMeans = means.size ();
1866 Teuchos::Array<impl_scalar_type> theMeans (numMeans);
1867 this->meanValue (theMeans ());
1868 for (size_type k = 0; k < numMeans; ++k) {
1869 means[k] =
static_cast<T
> (theMeans[k]);
1879 multiply (Teuchos::ETransp transA,
1880 Teuchos::ETransp transB,
1881 const Scalar& alpha,
1884 const Scalar& beta);
1907 elementWiseMultiply (Scalar scalarAB,
1916 size_t getNumVectors()
const;
1919 size_t getLocalLength()
const;
1929 size_t getStride()
const;
1934 bool isConstantStride()
const;
1942 virtual std::string description()
const;
1973 describe (Teuchos::FancyOStream& out,
1974 const Teuchos::EVerbosityLevel verbLevel =
1975 Teuchos::Describable::verbLevel_default)
const;
2005 TEUCHOS_TEST_FOR_EXCEPTION(
2006 copyOrView == Teuchos::Copy, std::invalid_argument,
2007 "Tpetra::MultiVector::setCopyOrView: The Kokkos refactor version of " 2008 "MultiVector _only_ implements view semantics. You may not call this " 2009 "method with copyOrView = Teuchos::Copy. The only valid argument is " 2024 return Teuchos::View;
2045 template <
class DS,
class DL,
class DG,
class DN,
const bool dstClassic,
2046 class SS,
class SL,
class SG,
class SN,
const bool srcClassic>
2122 normImpl (
const Kokkos::View<mag_type*, device_type>& norms,
2130 bool vectorIndexOutOfRange (
const size_t VectorIndex)
const;
2137 Teuchos::ArrayRCP<T>
2138 getSubArrayRCP (Teuchos::ArrayRCP<T> arr,
size_t j)
const;
2141 size_t getOrigNumLocalRows ()
const;
2144 size_t getOrigNumLocalCols ()
const;
2158 virtual size_t constantNumberOfPackets ()
const;
2167 const Kokkos::View<const local_ordinal_type*, execution_space>& permuteToLIDs,
2168 const Kokkos::View<const local_ordinal_type*, execution_space>& permuteFromLIDs);
2173 const Kokkos::View<const local_ordinal_type*, execution_space>& exportLIDs,
2174 Kokkos::View<impl_scalar_type*, execution_space>& exports,
2175 const Kokkos::View<size_t*, execution_space>& numPacketsPerLID,
2176 size_t& constantNumPackets,
2180 unpackAndCombineNew (
2181 const Kokkos::View<const LocalOrdinal*, execution_space>& importLIDs,
2182 const Kokkos::View<const impl_scalar_type*, execution_space>& imports,
2183 const Kokkos::View<size_t*, execution_space>& numPacketsPerLID,
2184 size_t constantNumPackets,
2188 void createViews ()
const;
2189 void createViewsNonConst (KokkosClassic::ReadWriteOption rwo);
2190 void releaseViews ()
const;
2193 typename dual_view_type::t_dev getKokkosView()
const {
return view_.d_view; }
2199 template<
class DstMultiVectorType,
2200 class SrcMultiVectorType>
2201 Teuchos::RCP<typename MultiVectorCloner<DstMultiVectorType, SrcMultiVectorType>::dst_mv_type>
2202 MultiVectorCloner<DstMultiVectorType, SrcMultiVectorType>::
2203 clone (
const src_mv_type& X,
2204 const Teuchos::RCP<typename dst_mv_type::node_type>& node2)
2206 typedef typename src_mv_type::map_type src_map_type;
2207 typedef typename dst_mv_type::map_type dst_map_type;
2208 typedef typename dst_mv_type::node_type dst_node_type;
2209 typedef typename dst_mv_type::dual_view_type dst_dual_view_type;
2212 RCP<const src_map_type> map1 = X.getMap ();
2213 RCP<const dst_map_type> map2 = map1.is_null () ?
2214 Teuchos::null : map1->template clone<dst_node_type> (node2);
2216 const size_t lclNumRows = X.getLocalLength ();
2217 const size_t numCols = X.getNumVectors ();
2218 dst_dual_view_type Y_view (
"MV::dual_view", lclNumRows, numCols);
2220 RCP<dst_mv_type> Y (
new dst_mv_type (map2, Y_view));
2230 template <
class ST,
class LO,
class GO,
class NT, const
bool classic>
2242 template <
class DS,
class DL,
class DG,
class DN,
const bool dstClassic,
2243 class SS,
class SL,
class SG,
class SN,
const bool srcClassic>
2248 typedef typename DN::device_type DD;
2251 TEUCHOS_TEST_FOR_EXCEPTION(
2254 "Tpetra::deep_copy: Global dimensions of the two Tpetra::MultiVector " 2255 "objects do not match. src has dimensions [" << src.
getGlobalLength ()
2256 <<
"," << src.
getNumVectors () <<
"], and dst has dimensions [" 2260 TEUCHOS_TEST_FOR_EXCEPTION(
2262 "Tpetra::deep_copy: The local row counts of the two Tpetra::MultiVector " 2263 "objects do not match. src has " << src.
getLocalLength () <<
" row(s) " 2272 dst.template modify<DES> ();
2274 Details::localDeepCopyConstStride (dst.
getDualView ().d_view,
2276 dst.template sync<HES> ();
2279 dst.template modify<HES> ();
2281 Details::localDeepCopyConstStride (dst.
getDualView ().h_view,
2283 dst.template sync<DES> ();
2287 typedef Kokkos::DualView<SL*, DD> whichvecs_type;
2288 typedef typename whichvecs_type::t_dev::execution_space DES;
2289 typedef typename whichvecs_type::t_host::execution_space HES;
2292 const SL numWhichVecs =
static_cast<SL
> (src.
whichVectors_.size ());
2293 const std::string whichVecsLabel (
"MV::deep_copy::whichVecs");
2303 whichvecs_type whichVecs (whichVecsLabel, numWhichVecs);
2304 whichVecs.template modify<HES> ();
2305 for (SL i = 0; i < numWhichVecs; ++i) {
2306 whichVecs.h_view(i) =
static_cast<SL
> (src.
whichVectors_[i]);
2309 whichVecs.template sync<DES> ();
2312 dst.template modify<DES> ();
2314 Details::localDeepCopy (dst.
getDualView ().d_view,
2322 dst.template sync<HES> ();
2329 typedef Kokkos::View<SL*, HES> the_whichvecs_type;
2330 the_whichvecs_type whichVecs (whichVecsLabel, numWhichVecs);
2331 for (SL i = 0; i < numWhichVecs; ++i) {
2337 Details::localDeepCopy (dst.
getDualView ().h_view,
2341 whichVecs, whichVecs);
2343 dst.template sync<DES> ();
2353 typedef Kokkos::DualView<DL*, DES> the_whichvecs_type;
2354 const std::string whichVecsLabel (
"MV::deep_copy::whichVecs");
2355 const DL numWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2356 the_whichvecs_type whichVecs (whichVecsLabel, numWhichVecs);
2357 whichVecs.template modify<HES> ();
2358 for (DL i = 0; i < numWhichVecs; ++i) {
2362 whichVecs.template sync<DES> ();
2365 Details::localDeepCopy (dst.
getDualView ().d_view,
2376 dst.template sync<HES> ();
2383 typedef Kokkos::View<DL*, HES> the_whichvecs_type;
2384 const DL numWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2385 the_whichvecs_type whichVecs (
"MV::deep_copy::whichVecs", numWhichVecs);
2386 for (DL i = 0; i < numWhichVecs; ++i) {
2390 Details::localDeepCopy (dst.
getDualView ().h_view,
2394 whichVecs, whichVecs);
2399 dst.template sync<DES> ();
2409 const DL dstNumWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2410 Kokkos::DualView<DL*, DES> whichVecsDst (
"MV::deep_copy::whichVecsDst",
2412 whichVecsDst.template modify<HES> ();
2413 for (DL i = 0; i < dstNumWhichVecs; ++i) {
2414 whichVecsDst.h_view(i) =
static_cast<DL
> (dst.
whichVectors_[i]);
2417 whichVecsDst.template sync<DES> ();
2423 const DL srcNumWhichVecs =
static_cast<DL
> (src.
whichVectors_.size ());
2424 Kokkos::DualView<DL*, DES> whichVecsSrc (
"MV::deep_copy::whichVecsSrc",
2426 whichVecsSrc.template modify<HES> ();
2427 for (DL i = 0; i < srcNumWhichVecs; ++i) {
2428 whichVecsSrc.h_view(i) =
static_cast<DL
> (src.
whichVectors_[i]);
2431 whichVecsSrc.template sync<DES> ();
2435 Details::localDeepCopy (dst.
getDualView ().d_view,
2439 whichVecsDst.d_view,
2440 whichVecsSrc.d_view);
2443 const DL dstNumWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2444 Kokkos::View<DL*, HES> whichVectorsDst (
"dstWhichVecs", dstNumWhichVecs);
2445 for (DL i = 0; i < dstNumWhichVecs; ++i) {
2450 const DL srcNumWhichVecs =
static_cast<DL
> (src.
whichVectors_.size ());
2451 Kokkos::View<DL*, HES> whichVectorsSrc (
"srcWhichVecs", srcNumWhichVecs);
2452 for (DL i = 0; i < srcNumWhichVecs; ++i) {
2458 Details::localDeepCopy (dst.
getDualView ().h_view,
2462 whichVectorsDst, whichVectorsSrc);
2468 dst.template sync<HES> ();
2481 template<
class SC,
class LO,
class GO,
class NT, const
bool classic>
2482 class TypeNameTraits<Tpetra::
MultiVector<SC, LO, GO, NT, classic> > {
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 size_t getLocalLength() const
Local number of rows on the calling process.
Node node_type
This class' fourth template parameter; the Kokkos Node type.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
std::enable_if<!std::is_same< T, impl_scalar_type >::value &&std::is_convertible< T, impl_scalar_type >::value, void >::type sumIntoGlobalValue(const GlobalOrdinal globalRow, const size_t col, const T &value, const bool atomic=useAtomicUpdatesByDefault) const
Like the above sumIntoGlobalValue, but only enabled if T differs from impl_scalar_type.
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.
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.
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.
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.
bool isConstantStride() const
Whether this multivector has constant stride between columns.
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.
Declarations for the Tpetra::Map class and related nonmember constructors.
Scalar scalar_type
This class' first template parameter; the type of each entry in the MultiVector.
dual_view_type getDualView() const
Get the Kokkos::DualView which implements local storage.
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.
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.
std::enable_if<!std::is_same< T, impl_scalar_type >::value &&std::is_convertible< T, impl_scalar_type >::value, void >::type replaceLocalValue(LocalOrdinal localRow, size_t col, const T &value) const
Like the above replaceLocalValue, but only enabled if T differs from impl_scalar_type.
Teuchos::DataAccess getCopyOrView() const
Get whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
global_size_t getGlobalLength() const
Global number of rows in the multivector.
Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
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.
Describes a parallel distribution of objects over processes.
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.
size_t getNumVectors() const
Number of columns in the 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.
EWhichNorm
Input argument for normImpl() (which see).
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.
std::enable_if<!std::is_same< T, impl_scalar_type >::value &&std::is_convertible< T, impl_scalar_type >::value, void >::type sumIntoLocalValue(LocalOrdinal localRow, size_t col, const T &value, const bool atomic=useAtomicUpdatesByDefault) const
Like the above sumIntoLocalValue, but only enabled if T differs from impl_scalar_type.