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);
1671 void norm1 (
const Kokkos::View<mag_type*, device_type>& norms)
const;
1686 template <
typename T>
1687 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1688 norm1 (
const Kokkos::View<T*, device_type>& norms)
const 1690 const size_t numNorms = norms.dimension_0 ();
1691 Kokkos::View<mag_type*, device_type> tmpNorms (
"MV::norm1 tmp", numNorms);
1693 this->norm1 (tmpNorms);
1708 void norm1 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1722 template <
typename T>
1723 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1724 norm1 (
const Teuchos::ArrayView<T>& norms)
const 1726 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1727 const size_type sz = norms.size ();
1728 Teuchos::Array<mag_type> theNorms (sz);
1729 this->norm1 (theNorms);
1730 for (size_type i = 0; i < sz; ++i) {
1732 norms[i] = theNorms[i];
1748 void norm2 (
const Kokkos::View<mag_type*, device_type>& norms)
const;
1761 template<
typename T>
1762 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1763 norm2 (
const Kokkos::View<T*, device_type>& norms)
const 1765 const size_t numNorms = norms.dimension_0 ();
1766 Kokkos::View<mag_type*, device_type> theNorms (
"MV::norm2 tmp", numNorms);
1768 this->norm2 (theNorms);
1783 void norm2 (
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 norm2 (
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 normInf (
const Kokkos::View<mag_type*, device_type>& norms)
const;
1830 template<
typename T>
1831 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1832 normInf (
const Kokkos::View<T*, device_type>& norms)
const 1834 const size_t numNorms = norms.dimension_0 ();
1835 Kokkos::View<mag_type*, device_type> theNorms (
"MV::normInf tmp", numNorms);
1837 this->normInf (theNorms);
1851 void normInf (
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 normInf (
const Teuchos::ArrayView<T>& norms)
const 1869 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1870 const size_type sz = norms.size ();
1871 Teuchos::Array<mag_type> theNorms (sz);
1872 this->norm2 (theNorms);
1873 for (size_type i = 0; i < sz; ++i) {
1875 norms[i] = theNorms[i];
1885 void TPETRA_DEPRECATED
1887 const Teuchos::ArrayView<mag_type>& norms)
const;
1905 template <
typename T>
1906 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1909 const Teuchos::ArrayView<T>& norms)
const 1911 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1912 const size_type sz = norms.size ();
1913 Teuchos::Array<mag_type> theNorms (sz);
1914 this->normWeighted (weights, theNorms);
1915 for (size_type i = 0; i < sz; ++i) {
1917 norms[i] = theNorms[i];
1925 void meanValue (
const Teuchos::ArrayView<impl_scalar_type>& means)
const;
1927 template <
typename T>
1928 typename std::enable_if<! std::is_same<impl_scalar_type, T>::value,
void>::type
1929 meanValue (
const Teuchos::ArrayView<T>& means)
const 1931 typedef typename Teuchos::Array<T>::size_type size_type;
1932 const size_type numMeans = means.size ();
1934 Teuchos::Array<impl_scalar_type> theMeans (numMeans);
1935 this->meanValue (theMeans ());
1936 for (size_type k = 0; k < numMeans; ++k) {
1937 means[k] =
static_cast<T
> (theMeans[k]);
1947 multiply (Teuchos::ETransp transA,
1948 Teuchos::ETransp transB,
1949 const Scalar& alpha,
1952 const Scalar& beta);
1975 elementWiseMultiply (Scalar scalarAB,
1984 size_t getNumVectors()
const;
1987 size_t getLocalLength()
const;
1997 size_t getStride()
const;
2002 bool isConstantStride()
const;
2010 virtual std::string description()
const;
2041 describe (Teuchos::FancyOStream& out,
2042 const Teuchos::EVerbosityLevel verbLevel =
2043 Teuchos::Describable::verbLevel_default)
const;
2073 TEUCHOS_TEST_FOR_EXCEPTION(
2074 copyOrView == Teuchos::Copy, std::invalid_argument,
2075 "Tpetra::MultiVector::setCopyOrView: The Kokkos refactor version of " 2076 "MultiVector _only_ implements view semantics. You may not call this " 2077 "method with copyOrView = Teuchos::Copy. The only valid argument is " 2092 return Teuchos::View;
2113 template <
class DS,
class DL,
class DG,
class DN,
const bool dstClassic,
2114 class SS,
class SL,
class SG,
class SN,
const bool srcClassic>
2190 normImpl (
const Kokkos::View<mag_type*, device_type>& norms,
2204 descriptionImpl (
const std::string& className)
const;
2213 localDescribeToString (
const Teuchos::EVerbosityLevel vl)
const;
2229 describeImpl (Teuchos::FancyOStream& out,
2230 const std::string& className,
2231 const Teuchos::EVerbosityLevel verbLevel =
2232 Teuchos::Describable::verbLevel_default)
const;
2235 bool vectorIndexOutOfRange (
const size_t VectorIndex)
const;
2242 Teuchos::ArrayRCP<T>
2243 getSubArrayRCP (Teuchos::ArrayRCP<T> arr,
size_t j)
const;
2246 size_t getOrigNumLocalRows ()
const;
2249 size_t getOrigNumLocalCols ()
const;
2263 virtual size_t constantNumberOfPackets ()
const;
2270 const size_t numSameIDs,
2271 const Kokkos::DualView<const local_ordinal_type*, device_type>& permuteToLIDs,
2272 const Kokkos::DualView<const local_ordinal_type*, device_type>& permuteFromLIDs);
2276 const Kokkos::DualView<const local_ordinal_type*, device_type>& exportLIDs,
2277 Kokkos::DualView<impl_scalar_type*, device_type>& exports,
2278 const Kokkos::DualView<size_t*, device_type>& ,
2279 size_t& constantNumPackets,
2283 unpackAndCombineNew (
const Kokkos::DualView<const LocalOrdinal*, device_type>& importLIDs,
2284 const Kokkos::DualView<const impl_scalar_type*, device_type>& imports,
2285 const Kokkos::DualView<const size_t*, device_type>& ,
2286 const size_t constantNumPackets,
2294 template<
class DstMultiVectorType,
2295 class SrcMultiVectorType>
2296 Teuchos::RCP<typename MultiVectorCloner<DstMultiVectorType, SrcMultiVectorType>::dst_mv_type>
2297 MultiVectorCloner<DstMultiVectorType, SrcMultiVectorType>::
2298 clone (
const src_mv_type& X,
2299 const Teuchos::RCP<typename dst_mv_type::node_type>& node2)
2302 typedef typename src_mv_type::map_type src_map_type;
2303 typedef typename dst_mv_type::map_type dst_map_type;
2304 typedef typename dst_mv_type::node_type dst_node_type;
2305 typedef typename dst_mv_type::dual_view_type dst_dual_view_type;
2308 RCP<const src_map_type> map1 = X.getMap ();
2309 RCP<const dst_map_type> map2 = map1.is_null () ?
2310 Teuchos::null : map1->template clone<dst_node_type> (node2);
2312 const size_t lclNumRows = X.getLocalLength ();
2313 const size_t numCols = X.getNumVectors ();
2314 dst_dual_view_type Y_view (
"MV::dual_view", lclNumRows, numCols);
2316 RCP<dst_mv_type> Y (
new dst_mv_type (map2, Y_view));
2326 template <
class ST,
class LO,
class GO,
class NT, const
bool classic>
2338 template <
class DS,
class DL,
class DG,
class DN,
const bool dstClassic,
2339 class SS,
class SL,
class SG,
class SN,
const bool srcClassic>
2344 typedef typename DN::device_type DD;
2347 TEUCHOS_TEST_FOR_EXCEPTION(
2350 "Tpetra::deep_copy: Global dimensions of the two Tpetra::MultiVector " 2351 "objects do not match. src has dimensions [" << src.
getGlobalLength ()
2352 <<
"," << src.
getNumVectors () <<
"], and dst has dimensions [" 2356 TEUCHOS_TEST_FOR_EXCEPTION(
2358 "Tpetra::deep_copy: The local row counts of the two Tpetra::MultiVector " 2359 "objects do not match. src has " << src.
getLocalLength () <<
" row(s) " 2367 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2369 if (! useHostVersion) {
2371 dst.template modify<DES> ();
2373 Details::localDeepCopyConstStride (dst.template getLocalView<DES> (),
2374 src.template getLocalView<typename SN::device_type> ());
2375 dst.template sync<HES> ();
2378 dst.template modify<HES> ();
2380 Details::localDeepCopyConstStride (dst.template getLocalView<Kokkos::HostSpace> (),
2381 src.template getLocalView<Kokkos::HostSpace> ());
2382 dst.template sync<DES> ();
2386 typedef Kokkos::DualView<SL*, DD> whichvecs_type;
2387 typedef typename whichvecs_type::t_dev::execution_space DES;
2388 typedef typename whichvecs_type::t_host::execution_space HES;
2391 const SL numWhichVecs =
static_cast<SL
> (src.
whichVectors_.size ());
2392 const std::string whichVecsLabel (
"MV::deep_copy::whichVecs");
2399 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2401 if (! useHostVersion) {
2404 whichvecs_type whichVecs (whichVecsLabel, numWhichVecs);
2405 whichVecs.template modify<HES> ();
2406 for (SL i = 0; i < numWhichVecs; ++i) {
2407 whichVecs.h_view(i) =
static_cast<SL
> (src.
whichVectors_[i]);
2410 whichVecs.template sync<DES> ();
2413 dst.template modify<DES> ();
2415 Details::localDeepCopy (dst.template getLocalView<typename DN::device_type> (),
2416 src.template getLocalView<typename SN::device_type> (),
2423 dst.template sync<HES> ();
2430 typedef Kokkos::View<SL*, HES> the_whichvecs_type;
2431 the_whichvecs_type whichVecs (whichVecsLabel, numWhichVecs);
2432 for (SL i = 0; i < numWhichVecs; ++i) {
2438 Details::localDeepCopy (dst.template getLocalView<Kokkos::HostSpace> (),
2439 src.template getLocalView<Kokkos::HostSpace> (),
2442 whichVecs, whichVecs);
2444 dst.template sync<DES> ();
2451 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2453 if (! useHostVersion) {
2456 typedef Kokkos::DualView<DL*, DES> the_whichvecs_type;
2457 const std::string whichVecsLabel (
"MV::deep_copy::whichVecs");
2458 const DL numWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2459 the_whichvecs_type whichVecs (whichVecsLabel, numWhichVecs);
2460 whichVecs.template modify<HES> ();
2461 for (DL i = 0; i < numWhichVecs; ++i) {
2465 whichVecs.template sync<DES> ();
2468 Details::localDeepCopy (dst.template getLocalView<typename DN::device_type> (),
2469 src.template getLocalView<typename SN::device_type> (),
2479 dst.template sync<HES> ();
2486 typedef Kokkos::View<DL*, HES> the_whichvecs_type;
2487 const DL numWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2488 the_whichvecs_type whichVecs (
"MV::deep_copy::whichVecs", numWhichVecs);
2489 for (DL i = 0; i < numWhichVecs; ++i) {
2493 Details::localDeepCopy (dst.template getLocalView<Kokkos::HostSpace> (),
2494 src.template getLocalView<Kokkos::HostSpace> (),
2497 whichVecs, whichVecs);
2502 dst.template sync<DES> ();
2508 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2510 if (! useHostVersion) {
2513 const DL dstNumWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2514 Kokkos::DualView<DL*, DES> whichVecsDst (
"MV::deep_copy::whichVecsDst",
2516 whichVecsDst.template modify<HES> ();
2517 for (DL i = 0; i < dstNumWhichVecs; ++i) {
2518 whichVecsDst.h_view(i) =
static_cast<DL
> (dst.
whichVectors_[i]);
2521 whichVecsDst.template sync<DES> ();
2527 const DL srcNumWhichVecs =
static_cast<DL
> (src.
whichVectors_.size ());
2528 Kokkos::DualView<DL*, DES> whichVecsSrc (
"MV::deep_copy::whichVecsSrc",
2530 whichVecsSrc.template modify<HES> ();
2531 for (DL i = 0; i < srcNumWhichVecs; ++i) {
2532 whichVecsSrc.h_view(i) =
static_cast<DL
> (src.
whichVectors_[i]);
2535 whichVecsSrc.template sync<DES> ();
2539 Details::localDeepCopy (dst.template getLocalView<typename DN::device_type> (),
2540 src.template getLocalView<typename SN::device_type> (),
2543 whichVecsDst.d_view,
2544 whichVecsSrc.d_view);
2547 const DL dstNumWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2548 Kokkos::View<DL*, HES> whichVectorsDst (
"dstWhichVecs", dstNumWhichVecs);
2549 for (DL i = 0; i < dstNumWhichVecs; ++i) {
2554 const DL srcNumWhichVecs =
static_cast<DL
> (src.
whichVectors_.size ());
2555 Kokkos::View<DL*, HES> whichVectorsSrc (
"srcWhichVecs", srcNumWhichVecs);
2556 for (DL i = 0; i < srcNumWhichVecs; ++i) {
2562 Details::localDeepCopy (dst.template getLocalView<Kokkos::HostSpace> (),
2563 src.template getLocalView<Kokkos::HostSpace> (),
2566 whichVectorsDst, whichVectorsSrc);
2572 dst.template sync<HES> ();
2585 template<
class SC,
class LO,
class GO,
class NT, const
bool classic>
2586 class TypeNameTraits<Tpetra::
MultiVector<SC, LO, GO, NT, classic> > {
2588 static std::string name () {
2589 return std::string (
"Tpetra::MultiVector<") +
2590 TypeNameTraits<SC>::name () +
"," +
2591 TypeNameTraits<LO>::name () +
"," +
2592 TypeNameTraits<GO>::name () +
"," +
2593 TypeNameTraits<NT>::name () +
">";
2603 #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.
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.
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.
Describes a parallel distribution of objects 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.