10 #ifndef TPETRA_KOKKOS_REFACTOR_DETAILS_MULTI_VECTOR_LOCAL_DEEP_COPY_HPP
11 #define TPETRA_KOKKOS_REFACTOR_DETAILS_MULTI_VECTOR_LOCAL_DEEP_COPY_HPP
13 #include "Kokkos_Core.hpp"
21 template<
class DstViewType,
class SrcViewType>
23 copyConvertResolvingPossibleAliasing (
const DstViewType& dst,
24 const SrcViewType& src)
31 const ptrdiff_t dst_beg =
reinterpret_cast<ptrdiff_t
> (dst.data ());
32 const ptrdiff_t dst_end =
33 reinterpret_cast<ptrdiff_t
> (dst.data () + dst.span ());
34 const ptrdiff_t src_beg =
reinterpret_cast<ptrdiff_t
> (src.data ());
35 const ptrdiff_t src_end =
36 reinterpret_cast<ptrdiff_t
> (src.data () + src.span ());
38 if (src_beg == dst_beg && src_end == dst_end) {
41 else if (dst_end <= src_beg || src_end <= dst_beg) {
52 auto src_copy = Kokkos::create_mirror (Kokkos::HostSpace (), src);
95 template<
class DstViewType,
97 class DstWhichVecsType,
98 class SrcWhichVecsType>
101 const SrcViewType& src,
102 const bool dstConstStride,
103 const bool srcConstStride,
104 const DstWhichVecsType& dstWhichVecs,
105 const SrcWhichVecsType& srcWhichVecs)
108 using Kokkos::subview;
109 using size_type =
typename DstViewType::size_type;
111 if (dstConstStride && srcConstStride) {
112 copyConvertResolvingPossibleAliasing (dst, src);
115 const size_type numCols = dstConstStride ?
116 static_cast<size_type
> (srcWhichVecs.size ()) :
117 static_cast<size_type> (dstWhichVecs.size ());
118 for (size_type j = 0; j < numCols; ++j) {
119 const size_type dst_col = dstConstStride ? j :
120 static_cast<size_type
> (dstWhichVecs[j]);
121 const auto dst_j = subview (dst, ALL (), dst_col);
122 const size_type src_col = srcConstStride ? j :
123 static_cast<size_type
> (srcWhichVecs[j]);
124 const auto src_j = subview (src, ALL (), src_col);
126 copyConvertResolvingPossibleAliasing (dst_j, src_j);
134 template<
class DstViewType,
138 const SrcViewType& src)
140 return copyConvertResolvingPossibleAliasing (dst, src);
146 #endif // TPETRA_KOKKOS_REFACTOR_DETAILS_MULTI_VECTOR_LOCAL_DEEP_COPY_HPP
void localDeepCopyConstStride(const DstViewType &dst, const SrcViewType &src)
Implementation of Tpetra::MultiVector deep copy of local data, for when both the source and destinati...
Declare and define Tpetra::Details::copyConvert, an implementation detail of Tpetra (in particular...
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.
void copyConvert(const OutputViewType &dst, const InputViewType &src)
Copy values from the 1-D Kokkos::View src, to the 1-D Kokkos::View dst, of the same length...
void localDeepCopy(const DstViewType &dst, const SrcViewType &src, const bool dstConstStride, const bool srcConstStride, const DstWhichVecsType &dstWhichVecs, const SrcWhichVecsType &srcWhichVecs)
Implementation of Tpetra::MultiVector deep copy of local data.