Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
DenseVector/Morpheus_Copy_Impl.hpp
1
24#ifndef MORPHEUS_DENSEVECTOR_COPY_IMPL_HPP
25#define MORPHEUS_DENSEVECTOR_COPY_IMPL_HPP
26
27#include <Morpheus_FormatTags.hpp>
28
29#include <impl/Morpheus_Utils.hpp>
30#include <impl/DenseVector/Serial/Morpheus_Copy_Impl.hpp>
31#include <impl/DenseVector/OpenMP/Morpheus_Copy_Impl.hpp>
32#include <impl/DenseVector/Cuda/Morpheus_Copy_Impl.hpp>
33#include <impl/DenseVector/HIP/Morpheus_Copy_Impl.hpp>
34
35#include <Kokkos_Core.hpp>
36
37#include <utility> // std::pair
38
39namespace Morpheus {
40namespace Impl {
41
42template <typename SourceType, typename DestinationType>
43void copy(const SourceType& src, DestinationType& dst,
44 typename std::enable_if_t<
45 Morpheus::is_dense_vector_format_container_v<SourceType> &&
46 Morpheus::is_dense_vector_format_container_v<DestinationType>>* =
47 nullptr) {
48 MORPHEUS_ASSERT(
49 dst.size() == src.size(),
50 "Destination vector must be of equal size to the source vector");
51
52 // Kokkos has src and dst the other way round
53 Kokkos::deep_copy(dst.view(), src.const_view());
54}
55
56template <typename SourceType, typename DestinationType>
57void copy(const SourceType& src, DestinationType& dst,
58 const typename SourceType::size_type src_begin,
59 const typename SourceType::size_type src_end,
60 const typename DestinationType::size_type dst_begin,
61 const typename DestinationType::size_type dst_end,
62 typename std::enable_if_t<
63 Morpheus::is_dense_vector_format_container_v<SourceType> &&
64 Morpheus::is_dense_vector_format_container_v<DestinationType>>* =
65 nullptr) {
66 auto src_sub =
67 Kokkos::subview(src.const_view(), std::make_pair(src_begin, src_end));
68 auto dst_sub =
69 Kokkos::subview(dst.view(), std::make_pair(dst_begin, dst_end));
70
71 // Kokkos has src and dst the other way round
72 Kokkos::deep_copy(dst_sub, src_sub);
73}
74
75} // namespace Impl
76} // namespace Morpheus
77
78#endif // MORPHEUS_DENSEVECTOR_COPY_IMPL_HPP
Generic Morpheus interfaces.
Definition: dummy.cpp:24