Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
DenseVector/HIP/Morpheus_Copy_Impl.hpp
1
24#ifndef MORPHEUS_DENSEVECTOR_HIP_COPY_IMPL_HPP
25#define MORPHEUS_DENSEVECTOR_HIP_COPY_IMPL_HPP
26
27#include <Morpheus_Macros.hpp>
28#if defined(MORPHEUS_ENABLE_HIP)
29
30#include <Morpheus_SpaceTraits.hpp>
31#include <Morpheus_FormatTraits.hpp>
32#include <Morpheus_FormatTags.hpp>
33#include <Morpheus_Spaces.hpp>
34
35#include <impl/Morpheus_HIPUtils.hpp>
36#include <impl/DenseVector/Kernels/Morpheus_Copy_Impl.hpp>
37
38namespace Morpheus {
39namespace Impl {
40
41template <typename ExecSpace, typename KeyType, typename SourceType,
42 typename DestinationType>
43void copy_by_key(
44 const KeyType keys, const SourceType& src, DestinationType& dst,
45 typename std::enable_if_t<
46 Morpheus::is_dense_vector_format_container_v<KeyType> &&
47 Morpheus::is_dense_vector_format_container_v<SourceType> &&
48 Morpheus::is_dense_vector_format_container_v<DestinationType> &&
49 Morpheus::has_custom_backend_v<ExecSpace> &&
50 Morpheus::has_hip_execution_space_v<ExecSpace> &&
51 Morpheus::has_access_v<ExecSpace, KeyType, SourceType,
52 DestinationType>>* = nullptr) {
53 using size_type = typename KeyType::size_type;
54 using index_type = typename KeyType::value_type;
55 using value_type = typename SourceType::value_type;
56
57 if (keys.size() == 0) return;
58
59 const size_t BLOCK_SIZE = 256;
60 const size_t NUM_BLOCKS = (keys.size() + BLOCK_SIZE - 1) / BLOCK_SIZE;
61
62 Kernels::copy_by_key_kernel<value_type, index_type, size_type>
63 <<<NUM_BLOCKS, BLOCK_SIZE, 0>>>(keys.size(), keys.data(), src.data(),
64 dst.data());
65
66#if defined(DEBUG) || defined(MORPHEUS_DEBUG)
67 getLastHIPError("copy_by_key_kernel: Kernel execution failed");
68#endif
69}
70
71} // namespace Impl
72} // namespace Morpheus
73
74#endif // MORPHEUS_ENABLE_HIP
75#endif // MORPHEUS_DENSEVECTOR_HIP_COPY_IMPL_HPP
Generic Morpheus interfaces.
Definition: dummy.cpp:24
constexpr bool has_access_v
Short-hand to has_access.
Definition: Morpheus_SpaceTraits.hpp:713