Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Coo/HIP/Morpheus_MatrixOperations_Impl.hpp
1
24#ifndef MORPHEUS_COO_HIP_MATRIXOPERATIONS_IMPL_HPP
25#define MORPHEUS_COO_HIP_MATRIXOPERATIONS_IMPL_HPP
26
27#include <Morpheus_Macros.hpp>
28#if defined(MORPHEUS_ENABLE_HIP)
29
30#include <Morpheus_Exceptions.hpp>
31#include <Morpheus_SpaceTraits.hpp>
32#include <Morpheus_FormatTraits.hpp>
33#include <Morpheus_FormatTags.hpp>
34#include <Morpheus_Spaces.hpp>
35
36#include <impl/Morpheus_HIPUtils.hpp>
37#include <impl/Coo/Kernels/Morpheus_MatrixOperations_Impl.hpp>
38
39namespace Morpheus {
40namespace Impl {
41
42template <typename ExecSpace, typename Matrix, typename Vector>
43void update_diagonal(
44 Matrix& A, const Vector& diagonal,
45 typename std::enable_if_t<
46 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
47 Morpheus::is_dense_vector_format_container_v<Vector> &&
48 Morpheus::has_custom_backend_v<ExecSpace> &&
49 Morpheus::has_hip_execution_space_v<ExecSpace> &&
50 Morpheus::has_access_v<ExecSpace, Matrix, Vector>>* = nullptr) {
51 using size_type = typename Matrix::size_type;
52 using index_type = typename Matrix::index_type;
53 using value_type = typename Matrix::value_type;
54
55 const size_type BLOCK_SIZE = 256;
56 const size_type NUM_BLOCKS = (A.nnnz() + BLOCK_SIZE - 1) / BLOCK_SIZE;
57
58 Kernels::update_coo_diagonal_kernel<value_type, index_type, size_type>
59 <<<NUM_BLOCKS, BLOCK_SIZE, 0>>>(A.nnnz(), A.row_indices().data(),
60 A.column_indices().data(),
61 A.values().data(), diagonal.data());
62
63#if defined(DEBUG) || defined(MORPHEUS_DEBUG)
64 getLastHIPError("update_coo_diagonal_kernel: Kernel execution failed");
65#endif
66}
67
68template <typename ExecSpace, typename Matrix, typename Vector>
69void get_diagonal(
70 Matrix&, const Vector&,
71 typename std::enable_if_t<
72 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
73 Morpheus::is_dense_vector_format_container_v<Vector> &&
74 Morpheus::has_custom_backend_v<ExecSpace> &&
75 Morpheus::has_hip_execution_space_v<ExecSpace> &&
76 Morpheus::has_access_v<ExecSpace, Matrix, Vector>>* = nullptr) {
77 throw Morpheus::NotImplementedException("get_diagonal not implemented yet");
78}
79
80template <typename ExecSpace, typename Matrix, typename SizeType,
81 typename ValueType>
82void set_value(Matrix&, SizeType, SizeType, ValueType,
83 typename std::enable_if_t<
84 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
85 Morpheus::has_custom_backend_v<ExecSpace> &&
86 Morpheus::has_hip_execution_space_v<ExecSpace> &&
87 Morpheus::has_access_v<ExecSpace, Matrix>>* = nullptr) {
88 throw Morpheus::NotImplementedException("set_value not implemented yet");
89}
90
91template <typename ExecSpace, typename Matrix, typename IndexVector,
92 typename ValueVector>
93void set_values(
94 Matrix&, typename IndexVector::value_type, const IndexVector,
95 typename IndexVector::value_type, const IndexVector, const ValueVector,
96 typename std::enable_if_t<
97 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
98 Morpheus::is_dense_vector_format_container_v<IndexVector> &&
99 Morpheus::is_dense_vector_format_container_v<ValueVector> &&
100 Morpheus::has_custom_backend_v<ExecSpace> &&
101 Morpheus::has_hip_execution_space_v<ExecSpace> &&
102 Morpheus::has_access_v<ExecSpace, Matrix, IndexVector, ValueVector>>* =
103 nullptr) {
104 throw Morpheus::NotImplementedException("set_values not implemented yet");
105}
106
107template <typename ExecSpace, typename Matrix, typename TransposeMatrix>
108void transpose(
109 const Matrix&, TransposeMatrix&,
110 typename std::enable_if_t<
111 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
112 Morpheus::is_coo_matrix_format_container_v<TransposeMatrix> &&
113 Morpheus::has_custom_backend_v<ExecSpace> &&
114 Morpheus::has_hip_execution_space_v<ExecSpace> &&
115 Morpheus::has_access_v<ExecSpace, Matrix, TransposeMatrix>>* =
116 nullptr) {
117 throw Morpheus::NotImplementedException("transpose not implemented yet");
118}
119
120} // namespace Impl
121} // namespace Morpheus
122
123#endif // MORPHEUS_ENABLE_HIP
124#endif // MORPHEUS_COO_HIP_MATRIXOPERATIONS_IMPL_HPP
Definition: Morpheus_Exceptions.hpp:43
Generic Morpheus interfaces.
Definition: dummy.cpp:24