24#ifndef MORPHEUS_CSR_HIP_MATRIXOPERATIONS_IMPL_HPP
25#define MORPHEUS_CSR_HIP_MATRIXOPERATIONS_IMPL_HPP
27#include <Morpheus_Macros.hpp>
28#if defined(MORPHEUS_ENABLE_HIP)
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>
36#include <impl/Morpheus_HIPUtils.hpp>
37#include <impl/Csr/Kernels/Morpheus_MatrixOperations_Impl.hpp>
42template <
typename ExecSpace,
typename Matrix,
typename Vector>
44 Matrix& A,
const Vector& diagonal,
45 typename std::enable_if_t<
46 Morpheus::is_csr_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;
55 const size_type BLOCK_SIZE = 256;
56 const size_type NUM_BLOCKS = (A.nrows() + BLOCK_SIZE - 1) / BLOCK_SIZE;
58 Kernels::update_csr_diagonal_kernel<value_type, index_type, size_type>
59 <<<NUM_BLOCKS, BLOCK_SIZE, 0>>>(A.nrows(), A.row_offsets().data(),
60 A.column_indices().data(),
61 A.values().data(), diagonal.data());
62#if defined(DEBUG) || defined(MORPHEUS_DEBUG)
63 getLastHIPError(
"update_csr_diagonal_kernel: Kernel execution failed");
67template <
typename ExecSpace,
typename Matrix,
typename Vector>
69 Matrix&,
const Vector&,
70 typename std::enable_if_t<
71 Morpheus::is_csr_matrix_format_container_v<Matrix> &&
72 Morpheus::is_dense_vector_format_container_v<Vector> &&
73 Morpheus::has_custom_backend_v<ExecSpace> &&
74 Morpheus::has_hip_execution_space_v<ExecSpace> &&
75 Morpheus::has_access_v<ExecSpace, Matrix, Vector>>* =
nullptr) {
79template <
typename ExecSpace,
typename Matrix,
typename SizeType,
81void set_value(Matrix&, SizeType, SizeType, ValueType,
82 typename std::enable_if_t<
83 Morpheus::is_csr_matrix_format_container_v<Matrix> &&
84 Morpheus::has_custom_backend_v<ExecSpace> &&
85 Morpheus::has_hip_execution_space_v<ExecSpace> &&
86 Morpheus::has_access_v<ExecSpace, Matrix>>* =
nullptr) {
90template <
typename ExecSpace,
typename Matrix,
typename IndexVector,
93 Matrix&,
typename IndexVector::value_type,
const IndexVector,
94 typename IndexVector::value_type,
const IndexVector,
const ValueVector,
95 typename std::enable_if_t<
96 Morpheus::is_csr_matrix_format_container_v<Matrix> &&
97 Morpheus::is_dense_vector_format_container_v<IndexVector> &&
98 Morpheus::is_dense_vector_format_container_v<ValueVector> &&
99 Morpheus::has_custom_backend_v<ExecSpace> &&
100 Morpheus::has_hip_execution_space_v<ExecSpace> &&
101 Morpheus::has_access_v<ExecSpace, Matrix, IndexVector, ValueVector>>* =
106template <
typename ExecSpace,
typename Matrix,
typename TransposeMatrix>
108 const Matrix&, TransposeMatrix&,
109 typename std::enable_if_t<
110 Morpheus::is_csr_matrix_format_container_v<Matrix> &&
111 Morpheus::is_csr_matrix_format_container_v<TransposeMatrix> &&
112 Morpheus::has_custom_backend_v<ExecSpace> &&
113 Morpheus::has_hip_execution_space_v<ExecSpace> &&
114 Morpheus::has_access_v<ExecSpace, Matrix, TransposeMatrix>>* =
Definition: Morpheus_Exceptions.hpp:43
Generic Morpheus interfaces.
Definition: dummy.cpp:24